diff options
Diffstat (limited to 'spec')
| -rw-r--r-- | spec/factories/chouette_companies.rb | 5 | ||||
| -rw-r--r-- | spec/factories/chouette_lines.rb | 1 | ||||
| -rw-r--r-- | spec/factories/chouette_networks.rb | 5 | ||||
| -rw-r--r-- | spec/factories/chouette_stop_areas.rb | 14 | ||||
| -rw-r--r-- | spec/requests/companies_spec.rb | 14 | ||||
| -rw-r--r-- | spec/requests/lines_spec.rb | 15 | ||||
| -rw-r--r-- | spec/requests/networks_spec.rb | 14 | ||||
| -rw-r--r-- | spec/requests/referentials_spec.rb | 47 | ||||
| -rw-r--r-- | spec/spec_helper.rb | 15 | ||||
| -rw-r--r-- | spec/views/companies/edit.html.erb_spec.rb | 25 | ||||
| -rw-r--r-- | spec/views/companies/index.html.erb_spec.rb | 17 | ||||
| -rw-r--r-- | spec/views/companies/new.html.erb_spec.rb | 8 | ||||
| -rw-r--r-- | spec/views/companies/show.html.erb_spec.rb | 20 | ||||
| -rw-r--r-- | spec/views/networks/edit.html.erb_spec.rb | 10 | ||||
| -rw-r--r-- | spec/views/networks/index.html.erb_spec.rb | 2 | ||||
| -rw-r--r-- | spec/views/networks/new.html.erb_spec.rb | 8 | ||||
| -rw-r--r-- | spec/views/networks/show.html.erb_spec.rb | 20 |
17 files changed, 149 insertions, 91 deletions
diff --git a/spec/factories/chouette_companies.rb b/spec/factories/chouette_companies.rb index db6ed2b1e..dacbc5766 100644 --- a/spec/factories/chouette_companies.rb +++ b/spec/factories/chouette_companies.rb @@ -1,3 +1,4 @@ -Factory.define :company, :class => "Chouette::Company" do |f| - f.sequence(:name) { |n| "Company #{n}" } +Factory.define :company, :class => "Chouette::Company" do |company| + company.sequence(:name) { |n| "Company #{n}" } + company.sequence(:objectid) { |n| "Company:#{n}" } end diff --git a/spec/factories/chouette_lines.rb b/spec/factories/chouette_lines.rb index b43583330..5fff06778 100644 --- a/spec/factories/chouette_lines.rb +++ b/spec/factories/chouette_lines.rb @@ -1,5 +1,6 @@ Factory.define :line, :class => "Chouette::Line" do |line| line.sequence(:name) { |n| "Line #{n}" } + line.sequence(:objectid) { |n| "Line:#{n}" } line.association :network, :factory => :network line.association :company, :factory => :company end diff --git a/spec/factories/chouette_networks.rb b/spec/factories/chouette_networks.rb index 343070868..dbcdab9ed 100644 --- a/spec/factories/chouette_networks.rb +++ b/spec/factories/chouette_networks.rb @@ -1,3 +1,4 @@ -Factory.define :network, :class => "Chouette::Network" do |f| - f.sequence(:name) { |n| "Network #{n}" } +Factory.define :network, :class => "Chouette::Network" do |network| + network.sequence(:name) { |n| "Network #{n}" } + network.sequence(:objectid) { |n| "Network:#{n}" } end diff --git a/spec/factories/chouette_stop_areas.rb b/spec/factories/chouette_stop_areas.rb index 315b84679..ede1c7767 100644 --- a/spec/factories/chouette_stop_areas.rb +++ b/spec/factories/chouette_stop_areas.rb @@ -1,7 +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 +# 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/requests/companies_spec.rb b/spec/requests/companies_spec.rb new file mode 100644 index 000000000..b7a938977 --- /dev/null +++ b/spec/requests/companies_spec.rb @@ -0,0 +1,14 @@ +require 'spec_helper' + +describe "Companies" do + let!(:referential) { Factory(:referential) } + let!(:companies) { Array.new(2) { Factory(:company) } } + + describe "GET /companies" do + it "works! (now write some real specs)" do + # Run the generator again with the --webrat flag if you want to use webrat methods/matchers + visit referential_companies_path(referential) + page.should have_content(companies.first.name) + end + end +end diff --git a/spec/requests/lines_spec.rb b/spec/requests/lines_spec.rb new file mode 100644 index 000000000..8633ee220 --- /dev/null +++ b/spec/requests/lines_spec.rb @@ -0,0 +1,15 @@ +require 'spec_helper' + +describe "Lines" do + let!(:referential) { Factory(:referential) } + let!(:lines) { Array.new(2) { Factory(:line) } } + + describe "GET /lines" do + it "works! (now write some real specs)" do + # Run the generator again with the --webrat flag if you want to use webrat methods/matchers + visit referential_lines_path(referential) + page.should have_content(lines.first.name) + end + end + +end diff --git a/spec/requests/networks_spec.rb b/spec/requests/networks_spec.rb new file mode 100644 index 000000000..17386b00a --- /dev/null +++ b/spec/requests/networks_spec.rb @@ -0,0 +1,14 @@ +require 'spec_helper' + +describe "Networks" do + let!(:referential) { Factory(:referential) } + let!(:networks) { Array.new(2) { Factory(:network) } } + + describe "GET /networks" do + it "works! (now write some real specs)" do + # Run the generator again with the --webrat flag if you want to use webrat methods/matchers + visit referential_networks_path(referential) + page.should have_content(networks.first.name) + end + end +end diff --git a/spec/requests/referentials_spec.rb b/spec/requests/referentials_spec.rb index 1fcd4f8a3..c3ed49234 100644 --- a/spec/requests/referentials_spec.rb +++ b/spec/requests/referentials_spec.rb @@ -1,14 +1,43 @@ +# -*- coding: utf-8 -*- require 'spec_helper' describe "Referentials" do + + describe "index" do + let!(:referentials) { Array.new(2) { Factory(:referential) } } + + it "should show n referentials" do + visit referentials_path + page.should have_content(referentials.first.name) + page.should have_content(referentials.last.name) + end + + end - # 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 + describe "create" do + + it "should" do + visit new_referential_path + fill_in "Nom", :with => "Test" + fill_in "Code", :with => "test" + click_button "Créer Référentiel" + + Referential.where(:name => "Test").should_not be_nil + # CREATE SCHEMA + end + + end + + describe "destroy" do + let(:referential) { Factory(:referential, :slug => "Referential destroyed") } + + it "should" do + visit referential_path(referential) + click_link "Supprimer" + Referential.where(:slug => "Referential destroyed").should be_nil + # DELETE SCHEMA + end + + end -end
\ No newline at end of file +end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 41ce1fde6..bb5f59026 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -3,12 +3,14 @@ ENV["RAILS_ENV"] ||= 'test' require File.expand_path("../../config/environment", __FILE__) require 'rspec/rails' require 'rspec/autorun' +require 'capybara/rspec' # 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| + DatabaseCleaner.logger = Rails.logger # ## Mock Framework # # If you prefer to use mocha, flexmock or RR, uncomment the appropriate line: @@ -30,4 +32,17 @@ RSpec.configure do |config| # rspec-rails. config.infer_base_class_for_anonymous_controllers = false + config.before(:suite) do + DatabaseCleaner.strategy = :transaction + DatabaseCleaner.clean_with( :truncation, {:except => %w[spatial_ref_sys geometry_columns]} ) + end + + config.before(:each) do + DatabaseCleaner.start + end + + config.after(:each) do + DatabaseCleaner.clean + end + end diff --git a/spec/views/companies/edit.html.erb_spec.rb b/spec/views/companies/edit.html.erb_spec.rb index 98216eb52..ef3418279 100644 --- a/spec/views/companies/edit.html.erb_spec.rb +++ b/spec/views/companies/edit.html.erb_spec.rb @@ -1,16 +1,14 @@ require 'spec_helper' -describe "/lines/edit" do +describe "/companies/edit" do let!(:referential) { assign(:referential, Factory(:referential)) } - let!(:network) { Factory(:network) } - let!(:company) { Factory(:company) } - let!(:line) { assign(:line, Factory(:line, :network => network, :company => company)) } - let!(:lines) { Array.new(2) { Factory(:line, :network => network, :company => company) } } + let!(:company) { assign(:company, Factory(:company)) } + let!(:companies) { Array.new(2) { Factory(:company) } } describe "test" do - it "should render h2 with the group name" do + it "should render h2 with the company name" do render - rendered.should have_selector("h2", :text => Regexp.new(line.name)) + rendered.should have_selector("h2", :text => Regexp.new(company.name)) end end @@ -18,18 +16,9 @@ describe "/lines/edit" 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 + with_tag "input[type=text][name='company[name]'][value=?]", company.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/companies/index.html.erb_spec.rb b/spec/views/companies/index.html.erb_spec.rb index a290080eb..9f4b00649 100644 --- a/spec/views/companies/index.html.erb_spec.rb +++ b/spec/views/companies/index.html.erb_spec.rb @@ -1,27 +1,20 @@ require 'spec_helper' -describe "/lines/index" do +describe "/companies/index" do let!(:referential) { assign( :referential, Factory(:referential) ) } - let!(:network) { Factory(:network) } - let!(:company) { Factory(:company) } - let!(:lines) { assign( :lines, Array.new(2) { Factory(:line, :network => network, :company => company) } ) } - - before :each do - rendered.stub(:collection).and_return( lines.order_by [[:number, :asc]] ) - view.stub(:link_to_order).and_return( "#" ) - end + let!(:companies) { assign( :companies, Array.new(2) { Factory(:company) } ) } it "should render a show link for each group" do render - lines.each do |line| - rendered.should have_selector(".line a[href='#{view.referential_line_path(referential, line)}']", :text => line.name) + companies.each do |company| + rendered.should have_selector(".company a[href='#{view.referential_company_path(referential, company)}']", :text => company.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_referential_line_path(referential)}']") + view.content_for(:sidebar).should have_selector(".actions a[href='#{new_referential_company_path(referential)}']") end end diff --git a/spec/views/companies/new.html.erb_spec.rb b/spec/views/companies/new.html.erb_spec.rb index 48f36a036..5030dcdba 100644 --- a/spec/views/companies/new.html.erb_spec.rb +++ b/spec/views/companies/new.html.erb_spec.rb @@ -1,17 +1,15 @@ require 'spec_helper' -describe "/lines/new" do +describe "/companies/new" do let!(:referential) { assign(:referential, Factory(:referential)) } - let!(:network) { Factory(:network) } - let!(:company) { Factory(:company) } - let!(:line) { assign(:line, Factory.build(:line, :network => network, :company => company )) } + let!(:company) { assign(:company, Factory.build(:company)) } 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 + with_selector "input[type=text][name=?]", company.name end end diff --git a/spec/views/companies/show.html.erb_spec.rb b/spec/views/companies/show.html.erb_spec.rb index 9d5b53cd3..2e35a3fb7 100644 --- a/spec/views/companies/show.html.erb_spec.rb +++ b/spec/views/companies/show.html.erb_spec.rb @@ -1,28 +1,28 @@ require 'spec_helper' -describe "/lines/show" do +describe "/companies/show" do let!(:referential) { assign(:referential, Factory(:referential)) } - let!(:line) { assign(:line, Factory(:line)) } + let!(:company) { assign(:company, Factory(:company)) } - it "should render h2 with the line name" do + it "should render h2 with the company name" do render - rendered.should have_selector("h2", :text => Regexp.new(line.name)) + rendered.should have_selector("h2", :text => Regexp.new(company.name)) end - # it "should display a map with class 'line'" do + # it "should display a map with class 'company'" do # render - # rendered.should have_selector("#map", :class => 'line') + # rendered.should have_selector("#map", :class => 'company') # end - it "should render a link to edit the line" do + it "should render a link to edit the company" do render - view.content_for(:sidebar).should have_selector(".actions a[href='#{view.edit_referential_line_path(referential, line)}']") + view.content_for(:sidebar).should have_selector(".actions a[href='#{view.edit_referential_company_path(referential, company)}']") end - it "should render a link to remove the line" do + it "should render a link to remove the company" do render - view.content_for(:sidebar).should have_selector(".actions a[href='#{view.referential_line_path(referential, line)}'][class='remove']") + view.content_for(:sidebar).should have_selector(".actions a[href='#{view.referential_company_path(referential, company)}'][class='remove']") end end diff --git a/spec/views/networks/edit.html.erb_spec.rb b/spec/views/networks/edit.html.erb_spec.rb index a64fc6860..5274f479a 100644 --- a/spec/views/networks/edit.html.erb_spec.rb +++ b/spec/views/networks/edit.html.erb_spec.rb @@ -3,7 +3,6 @@ require 'spec_helper' describe "/networks/edit" do let!(:referential) { assign(:referential, Factory(:referential)) } let!(:network) { assign(:network, Factory(:network) ) } - let!(:networks) { Array.new(2) { Factory(:network) } } describe "test" do it "should render h2 with the group name" do @@ -20,14 +19,5 @@ describe "/networks/edit" do end end - it "should render a checkbox for each network" do - render - networks.each do |network| - rendered.should have_selector("form") do - with_tag "input[type='checkbox'][value=?]", network.id - end - end - - end end end diff --git a/spec/views/networks/index.html.erb_spec.rb b/spec/views/networks/index.html.erb_spec.rb index 2ad218ca6..bad1ffd9d 100644 --- a/spec/views/networks/index.html.erb_spec.rb +++ b/spec/views/networks/index.html.erb_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe "/lines/index" do +describe "/networks/index" do let!(:referential) { assign( :referential, Factory(:referential) ) } let!(:networks) { assign( :networks, Array.new(2) { Factory(:network) } ) } diff --git a/spec/views/networks/new.html.erb_spec.rb b/spec/views/networks/new.html.erb_spec.rb index 48f36a036..6651f6b56 100644 --- a/spec/views/networks/new.html.erb_spec.rb +++ b/spec/views/networks/new.html.erb_spec.rb @@ -1,17 +1,15 @@ require 'spec_helper' -describe "/lines/new" do +describe "/networks/new" do let!(:referential) { assign(:referential, Factory(:referential)) } - let!(:network) { Factory(:network) } - let!(:company) { Factory(:company) } - let!(:line) { assign(:line, Factory.build(:line, :network => network, :company => company )) } + let!(:network) { assign(:network, Factory.build(: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 + with_selector "input[type=text][name=?]", network.name end end diff --git a/spec/views/networks/show.html.erb_spec.rb b/spec/views/networks/show.html.erb_spec.rb index 9d5b53cd3..e4b2093de 100644 --- a/spec/views/networks/show.html.erb_spec.rb +++ b/spec/views/networks/show.html.erb_spec.rb @@ -1,28 +1,28 @@ require 'spec_helper' -describe "/lines/show" do +describe "/networks/show" do let!(:referential) { assign(:referential, Factory(:referential)) } - let!(:line) { assign(:line, Factory(:line)) } + let!(:network) { assign(:network, Factory(:network)) } - it "should render h2 with the line name" do + it "should render h2 with the network name" do render - rendered.should have_selector("h2", :text => Regexp.new(line.name)) + rendered.should have_selector("h2", :text => Regexp.new(network.name)) end - # it "should display a map with class 'line'" do + # it "should display a map with class 'network'" do # render - # rendered.should have_selector("#map", :class => 'line') + # rendered.should have_selector("#map", :class => 'network') # end - it "should render a link to edit the line" do + it "should render a link to edit the network" do render - view.content_for(:sidebar).should have_selector(".actions a[href='#{view.edit_referential_line_path(referential, line)}']") + view.content_for(:sidebar).should have_selector(".actions a[href='#{view.edit_referential_network_path(referential, network)}']") end - it "should render a link to remove the line" do + it "should render a link to remove the network" do render - view.content_for(:sidebar).should have_selector(".actions a[href='#{view.referential_line_path(referential, line)}'][class='remove']") + view.content_for(:sidebar).should have_selector(".actions a[href='#{view.referential_network_path(referential, network)}'][class='remove']") end end |
