diff options
| author | Luc Donnet | 2012-04-25 10:40:15 +0200 |
|---|---|---|
| committer | Luc Donnet | 2012-04-25 10:40:15 +0200 |
| commit | 07b8f918639b6095f0f0bb700ca310deaa18841c (patch) | |
| tree | 68d6a319164a0d633ed7052fa482c93788c3930c /spec | |
| parent | fcac578e38f4e620113b3b877e27b952cf4caa95 (diff) | |
| download | chouette-core-07b8f918639b6095f0f0bb700ca310deaa18841c.tar.bz2 | |
Add spec request for lines networks and companies
Diffstat (limited to 'spec')
| -rw-r--r-- | spec/factories.rb | 16 | ||||
| -rw-r--r-- | spec/requests/companies_spec.rb | 41 | ||||
| -rw-r--r-- | spec/requests/lines_spec.rb | 56 | ||||
| -rw-r--r-- | spec/requests/networks_spec.rb | 74 |
4 files changed, 170 insertions, 17 deletions
diff --git a/spec/factories.rb b/spec/factories.rb index f0d8cc86b..91ee3e0f0 100644 --- a/spec/factories.rb +++ b/spec/factories.rb @@ -33,16 +33,16 @@ FactoryGirl.define do network.sequence(:name) { |n| "Network #{n}" } network.sequence(:objectid) { |n| "test:GroupOfLine:#{n}" } network.sequence(:registration_number) { |n| "test-#{n}" } - end - # factory :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 + factory :stop_area, :class => "Chouette::StopArea" do |stop_area| + stop_area.sequence(:name) { |n| "StopArea #{n}" } + stop_area.latitude 10 + stop_area.longitude 10 + stop_area.areatype "CommercialStopPoint" + stop_area.sequence(:registration_number) { |n| "test-#{n}" } + stop_area.sequence(:objectid) { |n| "test:StopArea:#{n}" } + end factory :referential do |f| f.sequence(:name) { |n| "Test #{n}" } diff --git a/spec/requests/companies_spec.rb b/spec/requests/companies_spec.rb index 77a08743b..d464fd307 100644 --- a/spec/requests/companies_spec.rb +++ b/spec/requests/companies_spec.rb @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- require 'spec_helper' describe "Companies" do @@ -5,11 +6,47 @@ describe "Companies" do let!(:referential) { create(:referential).switch } let!(:companies) { referential; Array.new(2) { create(:company) } } + subject { companies.first } - describe "GET /companies" do - it "should display company names" do + describe "list" do + it "display companies" do visit referential_companies_path(referential) page.should have_content(companies.first.name) + page.should have_content(companies.last.name) + end + + end + + describe "show" do + it "display company" do + visit referential_companies_path(referential) + click_link "#{companies.first.name}" + page.should have_content(companies.first.name) + end + + end + + describe "new" do + it "creates company and return to show" do + visit referential_companies_path(referential) + click_link "Ajouter un transporteur" + fill_in "Nom", :with => "Company 1" + fill_in "Numéro d'enregistrement", :with => "test-1" + fill_in "Identifiant Neptune", :with => "test:Company:1" + click_button("Créer Transporteur") + page.should have_content("Company 1") + end + end + + describe "edit and return to show" do + it "edit company" do + visit referential_company_path(referential, subject) + click_link "Modifier ce transporteur" + fill_in "Nom", :with => "Company Modified" + fill_in "Numéro d'enregistrement", :with => "test-1" + click_button("Modifier Transporteur") + page.should have_content("Company Modified") end end + end diff --git a/spec/requests/lines_spec.rb b/spec/requests/lines_spec.rb index 00048361c..3a5e4d507 100644 --- a/spec/requests/lines_spec.rb +++ b/spec/requests/lines_spec.rb @@ -1,16 +1,64 @@ +# -*- coding: utf-8 -*- require 'spec_helper' describe "Lines" do login_user let!(:referential) { create(:referential).switch } - let!(:lines) { referential; Array.new(2) { create(:line) } } + let!(:network) { Factory(:network) } + let!(:company) { Factory(:company) } + let!(:lines) { referential; Array.new(2) { Factory(:line, :network => network, :company => company) } } + subject { lines.first } - 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 + describe "list" do + it "display lines" do visit referential_lines_path(referential) page.should have_content(lines.first.name) + page.should have_content(lines.last.name) + end + + end + + + describe "show" do + it "display line" do + subject.stub(:stop_areas).and_return(Array.new(2) { Factory(:stop_area) }) + visit referential_lines_path(referential) + click_link "#{lines.first.name}" + page.should have_content(lines.first.name) + end + + it "display map" do + subject.stub(:stop_areas).and_return(Array.new(2) { Factory(:stop_area) }) + visit referential_lines_path(referential) + click_link "#{lines.first.name}" + page.should have_selector("#map", :class => 'line') + end + + end + + describe "new" do + it "creates line and return to show" do + subject.stub(:stop_areas).and_return(Array.new(2) { Factory(:stop_area) }) + visit referential_lines_path(referential) + click_link "Ajouter une ligne" + fill_in "Nom", :with => "Line 1" + fill_in "Numéro d'enregistrement", :with => "test-1" + fill_in "Identifiant Neptune", :with => "test:Line:1" + click_button("Créer Ligne") + page.should have_content("Line 1") + end + end + + describe "edit and return to show" do + it "edit line" do + subject.stub(:stop_areas).and_return(Array.new(2) { Factory(:stop_area) }) + visit referential_line_path(referential, subject) + click_link "Modifier cette ligne" + fill_in "Nom", :with => "Line Modified" + fill_in "Numéro d'enregistrement", :with => "test-1" + click_button("Modifier Ligne") + page.should have_content("Line Modified") end end diff --git a/spec/requests/networks_spec.rb b/spec/requests/networks_spec.rb index dddf6e09b..b48f0312c 100644 --- a/spec/requests/networks_spec.rb +++ b/spec/requests/networks_spec.rb @@ -1,15 +1,83 @@ +# -*- coding: utf-8 -*- require 'spec_helper' describe "Networks" do login_user let!(:referential) { create(:referential).switch } - let!(:networks) { referential; Array.new(2) { create(:network) } } + let!(:networks) { referential; Array.new(2) { Factory(:network) } } + subject { networks.first } - describe "GET /networks" do - it "works! (now write some real specs)" do + describe "list" do + it "display networks" do visit referential_networks_path(referential) page.should have_content(networks.first.name) + page.should have_content(networks.last.name) end + + end + + describe "show" do + it "display network" do + subject.stub(:stop_areas).and_return(Array.new(2) { Factory(:stop_area) }) + visit referential_networks_path(referential) + click_link "#{networks.first.name}" + page.should have_content(networks.first.name) + end + + it "display map" do + subject.stub(:stop_areas).and_return(Array.new(2) { Factory(:stop_area) }) + visit referential_networks_path(referential) + click_link "#{networks.first.name}" + page.should have_selector("#map", :class => 'network') + end + + end + + describe "new" do + it "creates network and return to show" do + subject.stub(:stop_areas).and_return(Array.new(2) { Factory(:stop_area) }) + visit referential_networks_path(referential) + click_link "Ajouter un réseau" + fill_in "Nom", :with => "Network 1" + fill_in "Numéro d'enregistrement", :with => "test-1" + fill_in "Identifiant Neptune", :with => "test:GroupOfLine:1" + click_button("Créer Réseau") + page.should have_content("Network 1") + end + end + + describe "edit and return to show" do + it "edit network" do + subject.stub(:stop_areas).and_return(Array.new(2) { Factory(:stop_area) }) + visit referential_network_path(referential, subject) + click_link "Modifier ce réseau" + fill_in "Nom", :with => "Network Modified" + fill_in "Numéro d'enregistrement", :with => "test-1" + click_button("Modifier Réseau") + page.should have_content("Network Modified") + end + end + + describe "delete", :js => true do + it "delete network and return to the list" do + # subject.stub(:stop_areas).and_return(Array.new(2) { Factory(:stop_area) }) + + # visit referential_networks_path(referential) + # puts page.body + # click_link "#{networks.first.name}" + # click_link "Modifier ce réseau" + # fill_in "Nom", :with => "Network 1" + # fill_in "Numéro d'enregistrement", :with => "test-1" + # click_button("Modifier Réseau") + # page.should have_content("Network 1") + # visit referential_network_path(referential, subject) + # puts page.body.inspect + # click_link "Supprimer ce réseau" + # page.evaluate_script('window.confirm = function() { return true; }') + # click_button "Valider" + # page.should have_no_content("Network 1") + end + end end |
