diff options
Diffstat (limited to 'spec')
| -rw-r--r-- | spec/controllers/referentials_controller_spec.rb | 5 | ||||
| -rw-r--r-- | spec/factories/chouette_lines.rb | 4 | ||||
| -rw-r--r-- | spec/factories/chouette_stop_areas.rb | 7 | ||||
| -rw-r--r-- | spec/factories/referential.rb | 4 | ||||
| -rw-r--r-- | spec/helpers/referentials_helper_spec.rb | 15 | ||||
| -rw-r--r-- | spec/models/referential_spec.rb | 8 | ||||
| -rw-r--r-- | spec/requests/referentials_spec.rb | 14 | ||||
| -rw-r--r-- | spec/spec_helper.rb | 32 | ||||
| -rw-r--r-- | spec/views/lines/edit.html.erb_spec.rb | 33 | ||||
| -rw-r--r-- | spec/views/lines/index.html.erb_spec.rb | 25 | ||||
| -rw-r--r-- | spec/views/lines/new.html.erb_spec.rb | 17 | ||||
| -rw-r--r-- | spec/views/lines/show.html.erb_spec.rb | 30 | ||||
| -rw-r--r-- | spec/views/referentials/edit.html.erb_spec.rb | 5 | ||||
| -rw-r--r-- | spec/views/referentials/new.html.erb_spec.rb | 17 | ||||
| -rw-r--r-- | spec/views/referentials/show.html.erb_spec.rb | 12 |
15 files changed, 228 insertions, 0 deletions
diff --git a/spec/controllers/referentials_controller_spec.rb b/spec/controllers/referentials_controller_spec.rb new file mode 100644 index 000000000..eba195a1f --- /dev/null +++ b/spec/controllers/referentials_controller_spec.rb @@ -0,0 +1,5 @@ +require 'spec_helper' + +describe ReferentialsController do + +end diff --git a/spec/factories/chouette_lines.rb b/spec/factories/chouette_lines.rb new file mode 100644 index 000000000..913b88538 --- /dev/null +++ b/spec/factories/chouette_lines.rb @@ -0,0 +1,4 @@ +Factory.define :chouette_line, :class => "Chouette::Line" do |f| + f.sequence(:name) { |n| "Line #{n}" } + f.objectid +end
\ No newline at end of file diff --git a/spec/factories/chouette_stop_areas.rb b/spec/factories/chouette_stop_areas.rb new file mode 100644 index 000000000..315b84679 --- /dev/null +++ b/spec/factories/chouette_stop_areas.rb @@ -0,0 +1,7 @@ +Factory.define :chouette_stop_area, :class => "Chouette::StopArea" do |f| + f.latitude 10 * rand + f.longitude 10 * rand + f.sequence(:name) { |n| "StopArea #{n}" } + f.areatype "CommercialStopPoint" + f.objectid +end
\ No newline at end of file diff --git a/spec/factories/referential.rb b/spec/factories/referential.rb new file mode 100644 index 000000000..4bdacb8c7 --- /dev/null +++ b/spec/factories/referential.rb @@ -0,0 +1,4 @@ +Factory.define :referential, :class => "Referential" do |f| + f.sequence(:name) { |n| "Referential #{n}" } + f.sequence(:slug) { |n| "referential_#{n}" } +end
\ No newline at end of file diff --git a/spec/helpers/referentials_helper_spec.rb b/spec/helpers/referentials_helper_spec.rb new file mode 100644 index 000000000..883116983 --- /dev/null +++ b/spec/helpers/referentials_helper_spec.rb @@ -0,0 +1,15 @@ +require 'spec_helper' + +# Specs in this file have access to a helper object that includes +# the ReferentialsHelper. For example: +# +# describe ReferentialsHelper do +# describe "string concat" do +# it "concats two strings with spaces" do +# helper.concat_strings("this","that").should == "this that" +# end +# end +# end +describe ReferentialsHelper do + pending "add some examples to (or delete) #{__FILE__}" +end diff --git a/spec/models/referential_spec.rb b/spec/models/referential_spec.rb new file mode 100644 index 000000000..363fe237f --- /dev/null +++ b/spec/models/referential_spec.rb @@ -0,0 +1,8 @@ +require 'spec_helper' + +describe Referential do + + it { should validate_presence_of(:name) } + it { should validate_presence_of(:slug) } + +end
\ No newline at end of file diff --git a/spec/requests/referentials_spec.rb b/spec/requests/referentials_spec.rb new file mode 100644 index 000000000..1fcd4f8a3 --- /dev/null +++ b/spec/requests/referentials_spec.rb @@ -0,0 +1,14 @@ +require 'spec_helper' + +describe "Referentials" do + + # describe "create" do + # get new_referential_path + # fill_in "Nom", :with => "Test" + # fill_in "Slug", :with => "test" + # click_button "Créer" + + # Referential.where(:name => "Test").should_not be_nil + # end + +end
\ No newline at end of file diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb new file mode 100644 index 000000000..e66d9802c --- /dev/null +++ b/spec/spec_helper.rb @@ -0,0 +1,32 @@ +# This file is copied to spec/ when you run 'rails generate rspec:install' +ENV["RAILS_ENV"] ||= 'test' +require File.expand_path("../../config/environment", __FILE__) +require 'rspec/rails' +require 'rspec/autorun' + +# Requires supporting ruby files with custom matchers and macros, etc, +# in spec/support/ and its subdirectories. +Dir[Rails.root.join("spec/support/**/*.rb")].each {|f| require f} + +RSpec.configure do |config| + # ## Mock Framework + # + # If you prefer to use mocha, flexmock or RR, uncomment the appropriate line: + # + # config.mock_with :mocha + # config.mock_with :flexmock + # config.mock_with :rr + + # Remove this line if you're not using ActiveRecord or ActiveRecord fixtures + config.fixture_path = "#{::Rails.root}/spec/fixtures" + + # If you're not using ActiveRecord, or you'd prefer not to run each of your + # examples within a transaction, remove the following line or assign false + # instead of true. + config.use_transactional_fixtures = true + + # If true, the base class of anonymous controllers will be inferred + # automatically. This will be the default behavior in future versions of + # rspec-rails. + config.infer_base_class_for_anonymous_controllers = false +end diff --git a/spec/views/lines/edit.html.erb_spec.rb b/spec/views/lines/edit.html.erb_spec.rb new file mode 100644 index 000000000..f889410ee --- /dev/null +++ b/spec/views/lines/edit.html.erb_spec.rb @@ -0,0 +1,33 @@ +require 'spec_helper' + +describe "/lines/edit" do + let!(:network) { assign(:network, Factory(:network)) } + let!(:line) { assign(:line, Factory(:line, :network => network)) } + let!(:lines) { Array.new(2) { Factory(:line, :network => network) } } + + describe "test" do + it "should render h2 with the group name" do + render + rendered.should have_selector("h2", :text => Regexp.new(line.name)) + end + end + + describe "form" do + it "should render input for name" do + render + rendered.should have_selector("form") do + with_tag "input[type=text][name='line[name]'][value=?]", line.name + end + end + + it "should render a checkbox for each line" do + render + lines.each do |line| + rendered.should have_selector("form") do + with_tag "input[type='checkbox'][value=?]", line.id + end + end + + end + end +end diff --git a/spec/views/lines/index.html.erb_spec.rb b/spec/views/lines/index.html.erb_spec.rb new file mode 100644 index 000000000..dee3565f4 --- /dev/null +++ b/spec/views/lines/index.html.erb_spec.rb @@ -0,0 +1,25 @@ +require 'spec_helper' + +describe "/lines/index" do + + let!(:network) { assign( :network, Factory(:network) ) } + let!(:lines) { assign( :lines, Array.new(2) { Factory(:line, :network => network) } ) } + + before :each do + rendered.stub(:collection).and_return( lines.order_by [[:code, :asc]] ) + view.stub(:link_to_order).and_return( "#" ) + end + + it "should render a show link for each group" do + render + lines.each do |line| + rendered.should have_selector(".line a[href='#{view.line_path(line)}']", :text => line.name) + end + end + + it "should render a link to create a new group" do + render + view.content_for(:sidebar).should have_selector(".actions a[href='#{new_network_line_path(network)}']") + end + +end diff --git a/spec/views/lines/new.html.erb_spec.rb b/spec/views/lines/new.html.erb_spec.rb new file mode 100644 index 000000000..b50f73356 --- /dev/null +++ b/spec/views/lines/new.html.erb_spec.rb @@ -0,0 +1,17 @@ +require 'spec_helper' + +describe "/lines/new" do + let!(:network) { assign(:network, Factory(:network)) } + let!(:line) { assign(:line, Factory.build(:line, :network => network)) } + + describe "form" do + + it "should render input for name" do + render + rendered.should have_selector("form") do + with_selector "input[type=text][name=?]", line.name + end + end + + end +end diff --git a/spec/views/lines/show.html.erb_spec.rb b/spec/views/lines/show.html.erb_spec.rb new file mode 100644 index 000000000..14f315333 --- /dev/null +++ b/spec/views/lines/show.html.erb_spec.rb @@ -0,0 +1,30 @@ +require 'spec_helper' + +describe "/lines/show" do + + let!(:network) { assign(:network, Factory(:network)) } + let!(:line) { assign(:line, Factory(:line, :network => network)) } + let!(:map) { assign(:map, LineMap.new(line) ) } + + it "should render h2 with the line name" do + render + rendered.should have_selector("h2", :text => Regexp.new(line.name)) + end + + it "should display a map with class 'line'" do + render + rendered.should have_selector("#map", :class => 'line') + end + + it "should render a link to edit the line" do + render + view.content_for(:sidebar).should have_selector(".actions a[href='#{view.edit_line_path(line)}']") + end + + it "should render a link to remove the line" do + render + view.content_for(:sidebar).should have_selector(".actions a[href='#{view.line_path(line)}'][class='remove']") + end + +end + diff --git a/spec/views/referentials/edit.html.erb_spec.rb b/spec/views/referentials/edit.html.erb_spec.rb new file mode 100644 index 000000000..3c2fbc5c3 --- /dev/null +++ b/spec/views/referentials/edit.html.erb_spec.rb @@ -0,0 +1,5 @@ +require 'spec_helper' + +describe "referentials/edit.html.erb" do + pending "add some examples to (or delete) #{__FILE__}" +end diff --git a/spec/views/referentials/new.html.erb_spec.rb b/spec/views/referentials/new.html.erb_spec.rb new file mode 100644 index 000000000..dccd990cb --- /dev/null +++ b/spec/views/referentials/new.html.erb_spec.rb @@ -0,0 +1,17 @@ +require 'spec_helper' + +describe "referentials/new.html.erb" do + + let!(:referential) { assign(:referential, Referential.new) } + + it "should have a textfield for name" do + render + rendered.should have_selector("input", :name => "referential[name]") + end + + it "should have a textfield for slug" do + render + rendered.should have_selector("input", :name => "referential[slug]") + end + +end diff --git a/spec/views/referentials/show.html.erb_spec.rb b/spec/views/referentials/show.html.erb_spec.rb new file mode 100644 index 000000000..2f3a64568 --- /dev/null +++ b/spec/views/referentials/show.html.erb_spec.rb @@ -0,0 +1,12 @@ +require 'spec_helper' + +describe "referentials/show.html.erb" do + let!(:referential) { assign(:referential, Factory(:referential)) } + + it "should have a title with name" do + render + puts render + rendered.should have_selector("h2", :text => Regexp.new(referential.name)) + end + +end |
