diff options
| author | Marc Florisson | 2014-01-22 17:41:04 +0100 |
|---|---|---|
| committer | Marc Florisson | 2014-01-22 17:41:04 +0100 |
| commit | c9437fc2e96f415e38c1e72fa10337769381f289 (patch) | |
| tree | 199b39a7c8c5cc2cfef539f73f73c1b5fbea8a72 /spec | |
| parent | 4e71abdc01f9f04ce6eec1989fa756ffc823fd65 (diff) | |
| download | chouette-core-c9437fc2e96f415e38c1e72fa10337769381f289.tar.bz2 | |
merge branch validation
Diffstat (limited to 'spec')
29 files changed, 936 insertions, 389 deletions
diff --git a/spec/controllers/exports_controller_spec.rb b/spec/controllers/exports_controller_spec.rb index e7a49a8e8..fd7b182d7 100644 --- a/spec/controllers/exports_controller_spec.rb +++ b/spec/controllers/exports_controller_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe ImportsController do +describe ExportsController do login_user describe "GET 'new'" do diff --git a/spec/controllers/import_tasks_controller_spec.rb b/spec/controllers/import_tasks_controller_spec.rb new file mode 100644 index 000000000..d9b8b7660 --- /dev/null +++ b/spec/controllers/import_tasks_controller_spec.rb @@ -0,0 +1,34 @@ +require 'spec_helper' + +describe ImportTasksController do + login_user + shared_examples_for "referential dependant" do + it "assigns referential as @referential" do + assigns[:referential].should == referential + end + end + + describe "GET /new" do + before(:each) do + get :new, + :referential_id => referential.id + end + it_behaves_like "referential dependant" + it "should assign import_task with NeptuneImport instance" do + assigns[:import_task].class.should == NeptuneImport + end + it "should assign import_task with Neptune format" do + assigns[:import_task].format.should == ImportTask.new.format + end + it "should assign import_task with refrential.id" do + assigns[:import_task].referential_id.should == referential.id + end + it "should assign import_task with logged in user id" do + assigns[:import_task].user_id.should == referential.organisation.users.first.id + end + it "should assign import_task with logged in user name" do + assigns[:import_task].user_name.should == referential.organisation.users.first.name + end + end + +end diff --git a/spec/controllers/imports_controller_spec.rb b/spec/controllers/imports_controller_spec.rb deleted file mode 100644 index 8e2582a99..000000000 --- a/spec/controllers/imports_controller_spec.rb +++ /dev/null @@ -1,41 +0,0 @@ -require 'spec_helper' - -describe ImportsController do - login_user - - describe "GET 'new'" do - it "returns http success" do - pending - get 'new' - response.should be_success - end - end - - describe "POST 'create'" do - before(:each) do - post :create, - :referential_id => referential.id, - :import => { :resources => Rack::Test::UploadedFile.new( "spec/fixtures/neptune.zip", 'application/zip', false)} - end - - it "assigns import.referential as @referential" do - assigns[:import].referential.should == referential - end - - it "assigns referential as @referential" do - assigns[:referential].should == referential - end - it "shoud redirect to imports" do - response.should redirect_to referential_imports_path(referential) - end - end - - describe "GET 'index'" do - it "returns http success" do - pending - get 'index' - response.should be_success - end - end - -end diff --git a/spec/controllers/rule_parameter_sets_controller_spec.rb b/spec/controllers/rule_parameter_sets_controller_spec.rb new file mode 100644 index 000000000..99a522581 --- /dev/null +++ b/spec/controllers/rule_parameter_sets_controller_spec.rb @@ -0,0 +1,34 @@ +require 'spec_helper' + +describe RuleParameterSetsController do + login_user + let(:mode){"air"} + + shared_examples_for "referential dependant" do + it "assigns referential as @referential" do + assigns[:referential].should == referential + end + end + + describe "GET /index" do + before(:each) do + get :index, + :referential_id => referential.id + end + it_behaves_like "referential dependant" + end + + describe "GET /new" do + before(:each) do + get :new, + :referential_id => referential.id + end + it_behaves_like "referential dependant" + it "should assign rule_parameter_set with default params" do + RuleParameterSet.default_params.each do |k,v| + assigns[:rule_parameter_set].send( k ).should == v + end + assigns[:rule_parameter_set].referential_id.should == referential.id + end + end +end diff --git a/spec/factories.rb b/spec/factories.rb index 681400443..205f020bb 100644 --- a/spec/factories.rb +++ b/spec/factories.rb @@ -13,6 +13,14 @@ FactoryGirl.define do f.time_zone "Europe/Paris" end + factory :rule_parameter_set do |f| + f.sequence(:name) { |n| "Test #{n}" } + f.association :referential + f.after_create do |rsp| + rsp.parameters = RuleParameterSet.default_for_all_modes( rsp.referential).parameters + end + end + factory :user do |f| f.association :organisation f.sequence(:name) { |n| "chouette#{n}" } @@ -21,16 +29,15 @@ FactoryGirl.define do f.password_confirmation "secret" end - factory :import do |f| + factory :import_task do |f| + f.user_name "dummy" + f.user_id 123 + f.no_save false + f.format "Neptune" f.resources { Rack::Test::UploadedFile.new 'spec/fixtures/neptune.zip', 'application/zip', false } f.referential { Referential.find_by_slug("first") } end - factory :import_log_message do |f| - f.association :import - f.sequence(:key) { "key_#{n}" } - end - factory :kml_export do |f| f.referential { Referential.find_by_slug("first") } end @@ -49,9 +56,18 @@ FactoryGirl.define do f.duration 1 end - factory :file_validation do |f| - f.resources { Rack::Test::UploadedFile.new 'spec/fixtures/neptune.zip', 'application/zip', false } - f.association :organisation + factory :compliance_check_result do |f| + f.association :compliance_check_task + f.rule_code "2-NEPTUNE-StopArea-6" + f.severity "warning" + f.status "nok" + end + + factory :compliance_check_task do |f| + f.user_id 1 + f.user_name "Dummy" + f.status "pending" + f.referential { Referential.find_by_slug("first") } end factory :file_validation_log_message do |f| diff --git a/spec/models/compliance_check_result_spec.rb b/spec/models/compliance_check_result_spec.rb new file mode 100644 index 000000000..4d73d8ad3 --- /dev/null +++ b/spec/models/compliance_check_result_spec.rb @@ -0,0 +1,68 @@ +require 'spec_helper' + +describe ComplianceCheckResult do + + subject { Factory( :compliance_check_result)} + + describe "#indice" do + context "when 1-NEPTUNE-XML-1 result" do + before(:each) do + subject.rule_code = "1-NEPTUNE-XML-1" + end + its(:indice) { should == 1 } + end + context "when 2-NETEX-AccessLink-2 result" do + before(:each) do + subject.rule_code = "2-NETEX-AccessLink-2" + end + its(:indice) { should == 2 } + end + end + + describe "#data_type" do + context "when 1-NEPTUNE-XML-1 result" do + before(:each) do + subject.rule_code = "1-NEPTUNE-XML-1" + end + its(:data_type) { should == "XML" } + end + context "when 2-NETEX-AccessLink-2 result" do + before(:each) do + subject.rule_code = "2-NETEX-AccessLink-2" + end + its(:data_type) { should == "AccessLink" } + end + end + + describe "#format" do + context "when 1-NEPTUNE-XML-1 result" do + before(:each) do + subject.rule_code = "1-NEPTUNE-XML-1" + end + its(:format) { should == "NEPTUNE" } + end + context "when 2-NETEX-AccessLink-2 result" do + before(:each) do + subject.rule_code = "2-NETEX-AccessLink-2" + end + its(:format) { should == "NETEX" } + end + end + + describe "#level" do + context "when 1-NEPTUNE-XML-1 result" do + before(:each) do + subject.rule_code = "1-NEPTUNE-XML-1" + end + its(:level) { should == 1 } + end + context "when 2-NEPTUNE-AccessLink-2 result" do + before(:each) do + subject.rule_code = "2-NEPTUNE-AccessLink-2" + end + its(:level) { should == 2 } + end + end + +end + diff --git a/spec/models/compliance_check_task_spec.rb b/spec/models/compliance_check_task_spec.rb new file mode 100644 index 000000000..e06554fe4 --- /dev/null +++ b/spec/models/compliance_check_task_spec.rb @@ -0,0 +1,283 @@ +require 'spec_helper' + +describe ComplianceCheckTask do + + subject { Factory( :compliance_check_task ) } + + RSpec::Matchers.define :be_log_message do |expected| + match do |actual| + actual and expected.all? { |k,v| actual[k.to_s] == v } + end + end + + describe "#destroy" do + let(:import_task){ Factory( :import_task )} + context "with an import_task" do + before(:each) do + subject.import_task = import_task + end + it "should destroy import_task" do + subject.destroy + ImportTask.exists?( import_task.id).should be_false + end + end + context "without any import_task" do + before(:each) do + subject.import_task = nil + end + it "should not raise exception" do + subject.destroy + subject.should be_destroyed + end + end + end + + describe "#levels" do + let(:import_task){ Factory( :import_task )} + context "when validation is without import" do + it "should not return levels 1 and 2" do + subject.levels.include?(1).should be_false + subject.levels.include?(2).should be_false + end + context "when parameter_set is defined" do + before(:each) do + subject.parameter_set = "dummy" + end + it "should return level 3" do + subject.levels.include?(3).should be_true + end + end + context "when parameter_set is not defined" do + before(:each) do + subject.parameter_set = nil + end + it "should not return level 3" do + subject.levels.include?(3).should_not be_true + end + end + end + context "when validation is done with an import" do + before(:each) do + subject.import_task = import_task + end + it "should return levels 1 and 2" do + subject.levels.include?(1).should be_true + subject.levels.include?(2).should be_true + end + context "when parameter_set is defined" do + before(:each) do + subject.parameter_set = "dummy" + end + it "should return level 3" do + subject.levels.include?(3).should be_true + end + end + context "when parameter_set is not defined" do + before(:each) do + subject.parameter_set = nil + end + it "should not return level 3" do + subject.levels.include?(3).should_not be_true + end + end + end + + end + + describe "#chouette_command" do + it "should be a Chouette::Command instance" do + subject.send( :chouette_command).class.should == Chouette::Command + end + it "should have schema same as referential.slug" do + subject.send( :chouette_command).schema.should == subject.referential.slug + end + end + + describe "#validate" do + let(:compliance_check_task){ Factory(:compliance_check_task) } + let(:chouette_command) { "dummy" } + context "for failing validation" do + before(:each) do + chouette_command.stub!( :run!).and_raise( "dummy") + compliance_check_task.stub!( :chouette_command => chouette_command) + end + it "should have status 'failed'" do + compliance_check_task.validate + compliance_check_task.status.should == "failed" + end + end + context "for successful validation" do + before(:each) do + compliance_check_task.stub!( :chouette_command => mock( :run! => true )) + end + it "should have status 'completed'" do + compliance_check_task.validate + compliance_check_task.status.should == "completed" + end + end + end + + describe "#validate" do + let(:compliance_check_task){ Factory(:compliance_check_task) } + let(:command_args){ "dummy" } + before(:each) do + compliance_check_task.stub!( :chouette_command => mock( :run! => true )) + compliance_check_task.stub!( :chouette_command_args => command_args) + end + it "should call chouette_command.run! with :c => 'import', :id => id" do + compliance_check_task.send( :chouette_command).should_receive( :run! ).with( command_args) + compliance_check_task.validate + end + end + + describe "#delayed_validate" do + let( :import_task){ Factory.build(:import_task) } + before(:each) do + subject.stub!( :delay => mock( :validate => true)) + end + it "should not call delay#validate if import_task defined" do + subject.import_task = import_task + subject.delay.should_not_receive( :validate) + subject.delayed_validate + end + it "should call delay#validate if import_task blank" do + subject.import_task = nil + subject.delay.should_receive( :validate) + subject.delayed_validate + end + + end + + describe "#define_default_attributes" do + it "should keep status if defined" do + subject.status = "dummy" + subject.define_default_attributes + subject.status.should == "dummy" + end + it "should set status to pending if not defined" do + subject.status = nil + subject.define_default_attributes + subject.status.should == "pending" + end + context "when rule_parameter_set is nil" do + before(:each) do + subject.stub!( :rule_parameter_set => nil) + subject.parameter_set = "dummy" + subject.parameter_set_name = "dummy" + end + it "should keep parameter_set_name" do + subject.define_default_attributes + subject.parameter_set_name.should == "dummy" + end + it "should keep parameter_set" do + subject.define_default_attributes + subject.parameter_set.should == "dummy" + end + end + context "when rule_parameter_set is defined" do + let( :rule_parameter_set ){ Factory( :rule_parameter_set ) } + before(:each) do + subject.stub!( :rule_parameter_set => rule_parameter_set) + subject.parameter_set = "dummy" + subject.parameter_set_name = "dummy" + end + it "should set parameter_set_name to rule_parameter_set.name" do + subject.define_default_attributes + subject.parameter_set_name.should == rule_parameter_set.name + end + it "should keep set parameter_set to rule_parameter_set.parameters" do + subject.define_default_attributes + subject.parameter_set.should == rule_parameter_set.parameters + end + end + end + + describe "#rule_parameter_set" do + context "when rule_parameter_set_id is blank" do + before(:each) do + subject.rule_parameter_set_id = "" + end + it "should return nil" do + subject.rule_parameter_set.should be_nil + end + end + context "when rule_parameter_set_id is not blank" do + let( :rule_parameter_set ){ Factory( :rule_parameter_set ) } + before(:each) do + subject.rule_parameter_set_id = rule_parameter_set.id + end + it "should return rule_parameter_set instance" do + subject.rule_parameter_set.should == rule_parameter_set + end + end + end + + describe "#rule_parameter_set_archived" do + context "when parameter_set is blank" do + before(:each) do + subject.parameter_set = nil + end + it "should return nil" do + subject.rule_parameter_set_archived.should be_nil + end + end + context "when parameter_set is blank" do + before(:each) do + subject.parameter_set = { :speed => 30, :distance => 5 } + end + it "should return RuleParameterSet#parameters same as parameter_set" do + subject.rule_parameter_set_archived.parameters.should == subject.parameter_set + end + it "should return RuleParameterSet#name same as parameter_set_name" do + subject.rule_parameter_set_archived.name.should == subject.parameter_set_name + end + end + + end + +# describe "#validate" do +# +# before(:each) do +# subject.stub :validator => mock(:validate => true) +# end +# +# it "should create a ComplianceCheckResult :started when started" do +# subject.validate +# subject.compliance_check_results.first.should be_log_message(:key => "started") +# end +# +# it "should create a ComplianceCheckResult :completed when completed" do +# subject.validate +# subject.compliance_check_results.last.should be_log_message(:key => "completed") +# end +# +# it "should create a ComplianceCheckResult :failed when failed" do +# pending +# # subject.loader.stub(:export).and_raise("export failed") +# subject.validate +# subject.compliance_check_results.last.should be_log_message(:key => "failed") +# end +# +# end + + describe ".create" do + let( :new_compliance_check_task){ Factory.build( :compliance_check_task) } + + it "should call #define_default_attributes" do + new_compliance_check_task.should_receive( :define_default_attributes) + new_compliance_check_task.save + end + + it "should call #delayed_validate" do + new_compliance_check_task.should_not_receive( :delayed_validate) + new_compliance_check_task.save + end + + end + + it_behaves_like TypeIdsModelable do + let(:type_ids_model) { subject} + end + +end + diff --git a/spec/models/csv_import_spec.rb b/spec/models/csv_import_spec.rb index e169afb5f..3dad39aeb 100644 --- a/spec/models/csv_import_spec.rb +++ b/spec/models/csv_import_spec.rb @@ -2,18 +2,13 @@ require 'spec_helper' describe CsvImport do - describe "#objectid_prefix" do + describe "#object_id_prefix" do - it "should be included in options" do - subject.objectid_prefix = "dummy" - subject.options.should include "objectid_prefix" => "dummy" - end + it "should be included in import_options" do + subject.object_id_prefix = "dummy" + subject.parameter_set["object_id_prefix"].should == "dummy" + end - it "should be included in import_options" do - subject.objectid_prefix = "dummy" - subject.import_options.should include :objectid_prefix => "dummy" - end - - end + end end diff --git a/spec/models/export_spec.rb b/spec/models/export_spec.rb index fb83236b0..cc8c045f1 100644 --- a/spec/models/export_spec.rb +++ b/spec/models/export_spec.rb @@ -9,7 +9,7 @@ describe Export do actual and expected.all? { |k,v| actual[k.to_s] == v } end end - + describe "#export" do before(:each) do @@ -36,7 +36,7 @@ describe Export do end describe "#options" do - + it "should be empty by default" do subject.options.should be_empty end @@ -44,7 +44,7 @@ describe Export do end describe ".types" do - + it "should return available Export implementations" do Export.types.should =~ %w{NeptuneExport CsvExport GtfsExport NetexExport KmlExport} end @@ -52,99 +52,15 @@ describe Export do end describe ".new" do - + it "should use type attribute to create a subclass" do Export.new(:type => "NeptuneExport").should be_an_instance_of(NeptuneExport) end end - describe "#references" do - - it "should be empty if references_type is nil" do - subject.references_type = nil - subject.references.should be_empty - end - - it "should be empty if reference_ids is blank" do - subject.reference_ids = "" - subject.references.should be_empty - end - - end - - describe "#references=" do - - context "with Lines" do - - let(:lines) { create_list :line, 3 } - - before(:each) do - subject.references = lines - end - - it "should use 'Chouette::Line' as references_type" do - subject.references_type.should == 'Chouette::Line' - end - - it "should use line identifiers as raw reference_ids" do - subject.raw_reference_ids.should == lines.map(&:id).join(',') - end - - end - - end - - describe "#references_relation" do - - it "should be 'lines' when relation_type is 'Chouette::Line'" do - subject.references_type = "Chouette::Line" - subject.references_relation.should == "lines" - end - - it "should be 'networks' when relation_type is 'Chouette::Network'" do - subject.references_type = "Chouette::Network" - subject.references_relation.should == "networks" - end - - it "should be nil when relation_type is blank" do - subject.references_type = "" - subject.references_relation.should be_nil - end - - it "should be nil when relation_type is 'dummy'" do - subject.references_type = "dummy" - subject.references_relation.should be_nil - end - - end - - describe "#reference_ids" do - - it "should parse raw_reference_ids and returns ids" do - subject.stub :raw_reference_ids => "1,2,3" - subject.reference_ids.should == [1,2,3] - end - - it "should be empty if raw_reference_ids is blank" do - subject.stub :raw_reference_ids => "" - subject.reference_ids.should be_empty - end - - end - - describe "#reference_ids=" do - - it "should join ids with comma" do - subject.reference_ids = [1,2,3] - subject.raw_reference_ids.should == "1,2,3" - end - - it "should be nil if records is blank" do - subject.reference_ids = [] - subject.raw_reference_ids.should be_nil - end - + it_behaves_like TypeIdsModelable do + let(:type_ids_model) { subject} end end diff --git a/spec/models/gtfs_import_spec.rb b/spec/models/gtfs_import_spec.rb index f22a2d20d..e1a1ac48e 100644 --- a/spec/models/gtfs_import_spec.rb +++ b/spec/models/gtfs_import_spec.rb @@ -2,74 +2,49 @@ require 'spec_helper' describe GtfsImport do - describe "#objectid_prefix" do - - it "should be included in options" do - subject.objectid_prefix = "dummy" - subject.options.should include "objectid_prefix" => "dummy" - end - - it "should be included in import_options" do - subject.objectid_prefix = "dummy" - subject.import_options.should include :objectid_prefix => "dummy" - end - - end - - describe "#max_distance_for_commercial" do - - it "should be included in options" do - subject.max_distance_for_commercial = 300 - subject.options.should include "max_distance_for_commercial" => 300 - end - - it "should be included in import_options" do - subject.max_distance_for_commercial = 300 - subject.import_options.should include :max_distance_for_commercial => 300 - end - - end - - describe "#max_distance_for_connection_link" do - - it "should be included in options" do - subject.max_distance_for_connection_link = 300 - subject.options.should include "max_distance_for_connection_link" => 300 - end - - it "should be included in import_options" do - subject.max_distance_for_connection_link = 300 - subject.import_options.should include :max_distance_for_connection_link => 300 - end - - end - - describe "#ignore_last_word" do - - it "should be included in options" do - subject.ignore_last_word = true - subject.options.should include "ignore_last_word" => true - end - - it "should be included in import_options" do - subject.ignore_last_word = true - subject.import_options.should include :ignore_last_word => true - end - - end - - describe "#ignore_end_chars" do - - it "should be included in options" do - subject.ignore_end_chars = 2 - subject.options.should include "ignore_end_chars" => 2 - end - - it "should be included in import_options" do - subject.ignore_end_chars = 2 - subject.import_options.should include :ignore_end_chars => 2 - end - - end + describe "#object_id_prefix" do + + it "should be included in import_options" do + subject.object_id_prefix = "dummy" + subject.parameter_set["object_id_prefix"].should == "dummy" + end + + end + + describe "#max_distance_for_commercial" do + + it "should be included in import_options" do + subject.max_distance_for_commercial = 300 + subject.parameter_set["max_distance_for_commercial"].should == 300 + end + + end + + describe "#max_distance_for_connection_link" do + + it "should be included in import_options" do + subject.max_distance_for_connection_link = 300 + subject.parameter_set["max_distance_for_connection_link"].should == 300 + end + + end + + describe "#ignore_last_word" do + + it "should be included in import_options" do + subject.ignore_last_word = true + subject.parameter_set["ignore_last_word"].should == true + end + + end + + describe "#ignore_end_chars" do + + it "should be included in import_options" do + subject.ignore_end_chars = 2 + subject.parameter_set["ignore_end_chars"].should == 2 + end + + end end diff --git a/spec/models/import_log_message_spec.rb b/spec/models/import_log_message_spec.rb deleted file mode 100644 index dab951255..000000000 --- a/spec/models/import_log_message_spec.rb +++ /dev/null @@ -1,16 +0,0 @@ -require 'spec_helper' - -describe ImportLogMessage do - - describe "#attributes" do - - subject { create :import_log_message } - - it "should read json stored in database" do - subject.update_attribute :arguments, { "key" => "value"} - subject.raw_attributes.should == { "key" => "value"}.to_json - end - - end - -end diff --git a/spec/models/import_spec.rb b/spec/models/import_spec.rb deleted file mode 100644 index bbf6725d7..000000000 --- a/spec/models/import_spec.rb +++ /dev/null @@ -1,61 +0,0 @@ -require 'spec_helper' - -describe Import do - - subject { create :import } - - RSpec::Matchers.define :be_log_message do |expected| - match do |actual| - actual and expected.all? { |k,v| actual[k.to_s] == v } - end - end - - describe "#import" do - - before(:each) do - subject.stub :loader => mock(:import => true) - end - - it "should create a ImportLogmessage :started when started" do - subject.import - subject.log_messages.first.should be_log_message(:key => "started") - end - - it "should create a ImportLogmessage :completed when completed" do - subject.import - subject.log_messages.last.should be_log_message(:key => "completed") - end - - it "should create a ImportLogmessage :failed when failed" do - subject.loader.stub(:import).and_raise("import failed") - subject.import - subject.log_messages.last.should be_log_message(:key => "failed") - end - - end - - describe "#options" do - - it "should be nil by default" do - subject.options.should be_nil - end - - end - - describe ".types" do - - it "should return available Import implementations" do - Import.types.should =~ %w{NeptuneImport CsvImport GtfsImport NetexImport} - end - - end - - describe ".new" do - - it "should use type attribute to create a subclass" do - Import.new(:type => "NeptuneImport").should be_an_instance_of(NeptuneImport) - end - - end - -end diff --git a/spec/models/import_task_spec.rb b/spec/models/import_task_spec.rb new file mode 100644 index 000000000..542ccd739 --- /dev/null +++ b/spec/models/import_task_spec.rb @@ -0,0 +1,196 @@ +require 'spec_helper' + +describe ImportTask do + + subject { build :import_task } + + describe ".new" do + + it "should use type attribute to create a subclass" do + ImportTask.new(:format => "Neptune").should be_an_instance_of(NeptuneImport) + ImportTask.new(:format => "Gtfs").should be_an_instance_of(GtfsImport) + ImportTask.new(:format => "Netex").should be_an_instance_of(NetexImport) + ImportTask.new(:format => "Csv").should be_an_instance_of(CsvImport) + + NeptuneImport.new.should be_an_instance_of(NeptuneImport) + GtfsImport.new.should be_an_instance_of(GtfsImport) + NetexImport.new.should be_an_instance_of(NetexImport) + CsvImport.new.should be_an_instance_of(CsvImport) + end + + end + + describe "#delayed_import" do + before(:each) do + subject.stub!( :delay => mock( :import => true)) + end + it "should call delay#import" do + subject.delay.should_receive( :import) + subject.send :delayed_import + end + end + + describe ".create" do + before(:each) do + subject.stub!( :save_resources => true ) + end + it "should call save_resource" do + subject.should_receive( :save_resources) + subject.send :save + end + it "should update file_path with #saved_resources" do + subject.send :save + ImportTask.find( subject.id).file_path.should == subject.send( :saved_resources) + end + it "should have a compliance_check_task" do + subject.send :save + ImportTask.find( subject.id).compliance_check_task.should_not be_nil + end + end + + describe "#compliance_check_task" do + let(:rule_parameter_set){ Factory( :rule_parameter_set) } + let(:import_task){ Factory(:import_task, :rule_parameter_set_id => rule_parameter_set.id) } + let(:compliance_check_task){ import_task.compliance_check_task } + + it "should have same #referential as import_task" do + compliance_check_task.referential.should == import_task.referential + end + + it "should have same #rule_parameter_set_id as import_task" do + compliance_check_task.rule_parameter_set_id.should == import_task.rule_parameter_set_id + end + + it "should have same #user_id as import_task" do + compliance_check_task.user_id.should == import_task.user_id + end + + it "should have same #user_name as import_task" do + compliance_check_task.user_name.should == import_task.user_name + end + end + + describe "#file_path_extension" do + let(:import_task){ Factory(:import_task) } + context "zip file to import" do + before(:each) do + import_task.file_path = "aaa/bbb.zip" + end + it "should return zip" do + import_task.file_path_extension.should == "zip" + end + end + context "xml file to import" do + before(:each) do + import_task.file_path = "aaa/bbb.xml" + end + it "should return xml" do + import_task.file_path_extension.should == "xml" + end + end + context "csv file to import" do + before(:each) do + import_task.file_path = "aaa/bbb.csv" + end + it "should return csv" do + import_task.file_path_extension.should == "basic" + end + end + + end + + context "options attributes" do + let(:import_task){ Factory(:import_task) } + describe "#no_save" do + it "should read parameter_set['no_save']" do + import_task.parameter_set[ "no_save"] = "dummy" + import_task.no_save.should == "dummy" + end + end + describe "#format" do + it "should read parameter_set['format']" do + import_task.parameter_set[ "format"] = "dummy" + import_task.format.should == "dummy" + end + end + describe "#file_path" do + it "should read parameter_set['file_path']" do + import_task.parameter_set[ "file_path"] = "dummy" + import_task.file_path.should == "dummy" + end + end + describe "#no_save=" do + it "should read parameter_set['no_save']" do + import_task.no_save = "dummy" + import_task.parameter_set[ "no_save"].should == false + end + end + describe "#format=" do + it "should read parameter_set['format']" do + import_task.format = "dummy" + import_task.parameter_set[ "format"].should == "dummy" + end + end + describe "#file_path=" do + it "should read parameter_set['file_path']" do + import_task.file_path = "dummy" + import_task.parameter_set[ "file_path"].should == "dummy" + end + end + end + + describe "#chouette_command" do + it "should be a Chouette::Command instance" do + subject.send( :chouette_command).class.should == Chouette::Command + end + it "should have schema same as referential.slug" do + subject.send( :chouette_command).schema.should == subject.referential.slug + end + end + + describe "#import" do + let(:import_task){ Factory(:import_task) } + let(:chouette_command) { "dummy" } + context "for failing import" do + before(:each) do + chouette_command.stub!( :run!).and_raise( "dummy") + import_task.stub!( :chouette_command => chouette_command) + end + it "should have status 'failed'" do + import_task.import + import_task.status.should == "failed" + end + it "should have status 'failed' for compliance_check_task" do + import_task.import + import_task.compliance_check_task.status.should == "failed" + end + end + context "for successful import" do + before(:each) do + import_task.stub!( :chouette_command => mock( :run! => true )) + end + it "should have status 'completed'" do + import_task.import + import_task.status.should == "completed" + end + it "should have status 'completed' for compliance_check_task" do + import_task.import + import_task.status.should == "completed" + end + end + end + + describe "#import" do + let(:import_task){ Factory(:import_task) } + let(:command_args){ "dummy" } + before(:each) do + import_task.stub!( :chouette_command => mock( :run! => true )) + import_task.stub!( :chouette_command_args => command_args) + end + it "should call chouette_command.run! with :c => 'import', :id => id" do + import_task.send( :chouette_command).should_receive( :run! ).with( command_args) + import_task.import + end + end + +end diff --git a/spec/models/rule_parameter_set_spec.rb b/spec/models/rule_parameter_set_spec.rb new file mode 100644 index 000000000..bf785d6f7 --- /dev/null +++ b/spec/models/rule_parameter_set_spec.rb @@ -0,0 +1,49 @@ +require 'spec_helper' + +describe RuleParameterSet do + + describe ".mode_of_mode_attribute" do + it "should retreive attribute name" do + subject.class.attribute_of_mode_attribute("dummy1_mode_dummy2").should == "dummy1" + end + it "should retreive mode" do + subject.class.mode_of_mode_attribute("dummy1_mode_dummy2").should == "dummy2" + end + end + + RuleParameterSet.mode_attribute_prefixes.each do |prefix| + RuleParameterSet.all_modes.map do |mode| + "#{prefix}_mode_#{mode}".tap do |attribute| + describe "##{attribute}=" do + it "should store value on parameters hash" do + subject.send( "#{attribute}=".to_sym, 1234) + subject.send( attribute.to_sym).should == 1234 + subject.parameters["mode_#{mode}"][ prefix].should == 1234 + end + end + it { should allow_mass_assignment_of attribute.to_sym} + end + end + end + + RuleParameterSet.general_attributes.each do |attribute| + describe "##{attribute}=" do + it "should store value on parameters hash" do + subject.send( "#{attribute}=".to_sym, 1234) + subject.send( attribute.to_sym).should == 1234 + subject.parameters[ attribute].should == 1234 + end + end + it { should allow_mass_assignment_of attribute.to_sym} + end + + describe "#referential" do + it { should validate_presence_of(:referential) } + it { should allow_mass_assignment_of :referential_id } + end + + describe "#name" do + it { should validate_presence_of(:name) } + it { should allow_mass_assignment_of :name } + end +end diff --git a/spec/requests/companies_spec.rb b/spec/requests/companies_spec.rb index dbacd4a71..fdcff4cab 100644 --- a/spec/requests/companies_spec.rb +++ b/spec/requests/companies_spec.rb @@ -4,12 +4,11 @@ require 'spec_helper' describe "Companies" do login_user - let(:companies) { Array.new(2) { create :company } } + let!(:companies) { Array.new(2) { create :company } } subject { companies.first } describe "list" do it "display companies" do - pending visit referential_companies_path(referential) page.should have_content(companies.first.name) page.should have_content(companies.last.name) @@ -19,7 +18,6 @@ describe "Companies" do describe "show" do it "display company" do - pending visit referential_companies_path(referential) click_link "#{companies.first.name}" page.should have_content(companies.first.name) @@ -29,7 +27,6 @@ describe "Companies" do describe "new" do it "creates company and return to show" do - pending visit referential_companies_path(referential) click_link "Ajouter un transporteur" fill_in "Nom", :with => "Company 1" @@ -42,7 +39,6 @@ describe "Companies" do describe "edit and return to show" do it "edit company" do - pending visit referential_company_path(referential, subject) click_link "Modifier ce transporteur" fill_in "Nom", :with => "Company Modified" diff --git a/spec/requests/connection_links_spec.rb b/spec/requests/connection_links_spec.rb index 48b5aa41d..74fe17c2e 100644 --- a/spec/requests/connection_links_spec.rb +++ b/spec/requests/connection_links_spec.rb @@ -4,12 +4,11 @@ require 'spec_helper' describe "ConnectionLinks" do login_user - let(:connection_links) { Array.new(2) { create(:connection_link) } } + let!(:connection_links) { Array.new(2) { create(:connection_link) } } subject { connection_links.first } describe "list" do it "display connection_links" do - pending visit referential_connection_links_path(referential) page.should have_content(connection_links.first.name) page.should have_content(connection_links.last.name) @@ -19,14 +18,12 @@ describe "ConnectionLinks" do describe "show" do it "display connection_link" do - pending visit referential_connection_links_path(referential) click_link "#{connection_links.first.name}" page.should have_content(connection_links.first.name) end it "display map" do - pending ": map not yet implemented" subject.stub(:stop_areas).and_return(Array.new(2) { Factory(:stop_area) }) visit referential_connection_links_path(referential) click_link "#{connection_links.first.name}" @@ -37,7 +34,6 @@ describe "ConnectionLinks" do describe "new" do it "creates connection_link and return to show" do - pending visit referential_connection_links_path(referential) click_link "Ajouter une correspondance" fill_in "Nom", :with => "ConnectionLink 1" @@ -49,7 +45,6 @@ describe "ConnectionLinks" do describe "edit and return to show" do it "edit connection_link" do - pending visit referential_connection_link_path(referential, subject) click_link "Modifier cette correspondance" fill_in "Nom", :with => "ConnectionLink Modified" diff --git a/spec/requests/lines_spec.rb b/spec/requests/lines_spec.rb index 10d653f30..b851f522a 100644 --- a/spec/requests/lines_spec.rb +++ b/spec/requests/lines_spec.rb @@ -4,14 +4,13 @@ require 'spec_helper' describe "Lines" do login_user - let(:network) { Factory(:network) } - let(:company) { Factory(:company) } - let(:lines) { referential; Array.new(2) { Factory(:line, :network => network, :company => company) } } + let!(:network) { Factory(:network) } + let!(:company) { Factory(:company) } + let!(:lines) { Array.new(2) { Factory(:line_with_stop_areas, :network => network, :company => company) } } subject { lines.first } describe "list" do it "display lines" do - pending visit referential_lines_path(referential) page.should have_content(lines.first.name) page.should have_content(lines.last.name) @@ -22,16 +21,12 @@ describe "Lines" do describe "show" do it "display line" do - pending - 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 - pending - 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') @@ -41,13 +36,11 @@ describe "Lines" do describe "new" do it "creates line and return to show" do - pending - 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" + fill_in "Numéro d'enregistrement", :with => "1" + fill_in "Identifiant Neptune", :with => "test:Line:999" click_button("Créer ligne") page.should have_content("Line 1") end @@ -55,8 +48,6 @@ describe "Lines" do describe "edit and return to show" do it "edit line" do - pending - 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" diff --git a/spec/requests/networks_spec.rb b/spec/requests/networks_spec.rb index ff020dca6..662e5e830 100644 --- a/spec/requests/networks_spec.rb +++ b/spec/requests/networks_spec.rb @@ -4,13 +4,11 @@ require 'spec_helper' describe "Networks" do login_user - let(:networks) { Array.new(2) { Factory(:network) } } + let!(:networks) { Array.new(2) { Factory(:network) } } subject { networks.first } describe "list" do it "display networks" do - pending - visit referential_networks_path(referential) page.should have_content(networks.first.name) page.should have_content(networks.last.name) @@ -20,8 +18,6 @@ describe "Networks" do describe "show" do it "display network" do - pending - subject.stub(:stop_areas).and_return(Array.new(2) { Factory(:stop_area) }) visit referential_networks_path(referential) click_link "#{networks.first.name}" @@ -29,8 +25,6 @@ describe "Networks" do end it "display map" do - pending - subject.stub(:stop_areas).and_return(Array.new(2) { Factory(:stop_area) }) visit referential_networks_path(referential) click_link "#{networks.first.name}" @@ -41,8 +35,6 @@ describe "Networks" do describe "new" do it "creates network and return to show" do - pending - subject.stub(:stop_areas).and_return(Array.new(2) { Factory(:stop_area) }) visit referential_networks_path(referential) click_link "Ajouter un réseau" @@ -56,8 +48,6 @@ describe "Networks" do describe "edit and return to show" do it "edit network" do - pending - subject.stub(:stop_areas).and_return(Array.new(2) { Factory(:stop_area) }) visit referential_network_path(referential, subject) click_link "Modifier ce réseau" @@ -68,23 +58,15 @@ describe "Networks" do 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) - # 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) - # 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 + # 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_network_path(referential, subject) + # click_link "Supprimer ce réseau" + # page.evaluate_script('window.confirm = function() { return true; }') + # click_button "Valider" + # page.should have_no_content(subject.name) + # end - end + # end end diff --git a/spec/requests/referentials_spec.rb b/spec/requests/referentials_spec.rb index 9203de16d..c57192d9b 100644 --- a/spec/requests/referentials_spec.rb +++ b/spec/requests/referentials_spec.rb @@ -22,8 +22,6 @@ describe "Referentials" do retrieve_referential_by_slug("bb")] } it "should show n referentials" do - pending - visit referentials_path page.should have_content(referentials.first.name) page.should have_content(referentials.last.name) diff --git a/spec/requests/routes_spec.rb b/spec/requests/routes_spec.rb index 3ba1985eb..5e24b8492 100644 --- a/spec/requests/routes_spec.rb +++ b/spec/requests/routes_spec.rb @@ -4,9 +4,9 @@ require 'spec_helper' describe "Routes" do login_user - let(:line) { Factory(:line) } - let(:route) { Factory(:route, :line => line) } - let(:route2) { Factory(:route, :line => line) } + let!(:line) { Factory(:line) } + let!(:route) { Factory(:route, :line => line) } + let!(:route2) { Factory(:route, :line => line) } describe "from lines page to a line page" do it "display line's routes" do diff --git a/spec/requests/stop_areas_spec.rb b/spec/requests/stop_areas_spec.rb index 5d4e3afb3..ef3ca9275 100644 --- a/spec/requests/stop_areas_spec.rb +++ b/spec/requests/stop_areas_spec.rb @@ -4,30 +4,25 @@ require 'spec_helper' describe "StopAreas" do login_user - let(:stop_areas) { Array.new(2) { Factory(:stop_area) } } + let!(:stop_areas) { Array.new(2) { Factory(:stop_area) } } subject { stop_areas.first } describe "list" do it "display stop_areas" do - pending visit referential_stop_areas_path(referential) page.should have_content(stop_areas.first.name) page.should have_content(stop_areas.last.name) - end - + end end - describe "show" do it "display stop_area" do - pending visit referential_stop_areas_path(referential) click_link "#{stop_areas.first.name}" page.should have_content(stop_areas.first.name) end it "display map" do - pending visit referential_stop_areas_path(referential) click_link "#{stop_areas.first.name}" page.should have_selector("#map", :class => 'stop_area') @@ -37,12 +32,11 @@ describe "StopAreas" do describe "new" do it "creates stop_area and return to show" do - pending visit referential_stop_areas_path(referential) click_link "Ajouter un arrêt" fill_in "Nom", :with => "StopArea 1" fill_in "Numéro d'enregistrement", :with => "test-1" - #fill_in "Identifiant Neptune", :with => "test:StopArea:1" + fill_in "Identifiant Neptune", :with => "test:StopArea:1" click_button("Créer arrêt") page.should have_content("StopArea 1") end @@ -50,7 +44,6 @@ describe "StopAreas" do describe "edit and return to show" do it "edit stop_area" do - pending visit referential_stop_area_path(referential, subject) click_link "Modifier cet arrêt" fill_in "Nom", :with => "StopArea Modified" diff --git a/spec/requests/time_tables_spec.rb b/spec/requests/time_tables_spec.rb index c935587b3..412dcece6 100644 --- a/spec/requests/time_tables_spec.rb +++ b/spec/requests/time_tables_spec.rb @@ -4,12 +4,11 @@ require 'spec_helper' describe "TimeTables" do login_user - let(:time_tables) { Array.new(2) { create(:time_table) } } + let!(:time_tables) { Array.new(2) { create(:time_table) } } subject { time_tables.first } describe "list" do it "display time_tables" do - pending visit referential_time_tables_path(referential) page.should have_content(time_tables.first.comment) page.should have_content(time_tables.last.comment) @@ -19,7 +18,6 @@ describe "TimeTables" do describe "show" do it "display time_table" do - pending visit referential_time_tables_path(referential) click_link "#{time_tables.first.comment}" page.should have_content(time_tables.first.comment) @@ -29,7 +27,6 @@ describe "TimeTables" do describe "new" do it "creates time_table and return to show" do - pending visit referential_time_tables_path(referential) click_link "Ajouter un calendrier" fill_in "Description", :with => "TimeTable 1" @@ -41,7 +38,6 @@ describe "TimeTables" do describe "edit and return to show" do it "edit time_table" do - pending visit referential_time_table_path(referential, subject) click_link "Modifier ce calendrier" fill_in "Description", :with => "TimeTable Modified" diff --git a/spec/support/devise.rb b/spec/support/devise.rb index b50f3a71a..8713e96fa 100644 --- a/spec/support/devise.rb +++ b/spec/support/devise.rb @@ -3,7 +3,7 @@ module DeviseRequestHelper def login_user organisation = Organisation.find_by_name("first") || create(:organisation, :name => "first") - @user ||= create(:user, :organisation => organisation) + @user ||= create(:user, :organisation => organisation) @user.confirm! login_as @user, :scope => :user # post_via_redirect user_session_path, 'user[email]' => @user.email, 'user[password]' => @user.password @@ -22,7 +22,7 @@ module DeviseRequestHelper login_user end after(:each) do - Warden.test_reset! + Warden.test_reset! end end diff --git a/spec/support/type_ids_modelable_spec.rb b/spec/support/type_ids_modelable_spec.rb new file mode 100644 index 000000000..d5a3f7042 --- /dev/null +++ b/spec/support/type_ids_modelable_spec.rb @@ -0,0 +1,100 @@ +require 'spec_helper' + +shared_examples_for TypeIdsModelable do + context 'class methods' do + it 'should be a TypeIdsModelable class' do + described_class.type_ids_modelable_class?.should be_true + end + describe ".references_relation" do + it "shoud demodulize, underscore and puralize" do + described_class.references_relation( Chouette::StopArea).should == "stop_areas" + end + end + end + + context 'with an instance' do + describe "#references" do + it "should be empty if references_type is nil" do + type_ids_model.references_type = nil + type_ids_model.references.should be_empty + end + it "should be empty if reference_ids is blank" do + type_ids_model.reference_ids = "" + type_ids_model.references.should be_empty + end + end + describe "#references=" do + let(:lines) { create_list :line, 3 } + + context "when references defined" do + before(:each) do + type_ids_model.references = lines + end + it "should set reference_ids to [data_a.id]" do + type_ids_model.reference_ids.should == lines.map(&:id) + end + it "should set references_type to EffectiveDataTypeA" do + type_ids_model.references_type.should == 'Chouette::Line' + end + end + context "when references blank" do + before(:each) do + type_ids_model.references = "" + end + it "should set reference_ids to []" do + type_ids_model.reference_ids.should == [] + end + it "should set references_type to nil" do + type_ids_model.references_type.should be_nil + end + end + end + + describe "#references_relation" do + it "should be 'lines' when relation_type is 'Chouette::Line'" do + type_ids_model.references_type = "Chouette::Line" + type_ids_model.references_relation.should == "lines" + end + + it "should be 'networks' when relation_type is 'Chouette::Network'" do + type_ids_model.references_type = "Chouette::Network" + type_ids_model.references_relation.should == "networks" + end + + it "should be nil when relation_type is blank" do + type_ids_model.references_type = "" + type_ids_model.references_relation.should be_nil + end + + it "should be nil when relation_type is 'dummy'" do + type_ids_model.references_type = "dummy" + type_ids_model.references_relation.should be_nil + end + end + + describe "#reference_ids" do + it "should parse raw_reference_ids and returns ids" do + type_ids_model.stub :raw_reference_ids => "1,2,3" + type_ids_model.reference_ids.should == [1,2,3] + end + + it "should be empty if raw_reference_ids is blank" do + type_ids_model.stub :raw_reference_ids => "" + type_ids_model.reference_ids.should be_empty + end + end + + describe "#reference_ids=" do + it "should join ids with comma" do + type_ids_model.reference_ids = [1,2,3] + type_ids_model.raw_reference_ids.should == "1,2,3" + end + it "should be nil if records is blank" do + type_ids_model.reference_ids = [] + type_ids_model.raw_reference_ids.should be_nil + end + end + end + + +end diff --git a/spec/views/imports/index.html.erb_spec.rb b/spec/views/import_tasks/index.html.erb_spec.rb index c0f2d3462..c0f2d3462 100644 --- a/spec/views/imports/index.html.erb_spec.rb +++ b/spec/views/import_tasks/index.html.erb_spec.rb diff --git a/spec/views/import_tasks/new.html.erb_spec.rb b/spec/views/import_tasks/new.html.erb_spec.rb new file mode 100644 index 000000000..002832dc9 --- /dev/null +++ b/spec/views/import_tasks/new.html.erb_spec.rb @@ -0,0 +1,15 @@ +require 'spec_helper' + +describe "import_tasks/new.html.erb" do + + assign_referential + let!(:import_task) { assign(:import_task, ImportTask.new) } + + let!(:available_imports) { assign(:available_imports, []) } + + it "should display a radio button to choose import type" do + render + rendered.should have_selector("input", :type => "select", :name => "import_task[format]") + end + +end diff --git a/spec/views/imports/new.html.erb_spec.rb b/spec/views/imports/new.html.erb_spec.rb deleted file mode 100644 index 081999c60..000000000 --- a/spec/views/imports/new.html.erb_spec.rb +++ /dev/null @@ -1,15 +0,0 @@ -require 'spec_helper' - -describe "imports/new.html.erb" do - - assign_referential - let!(:import) { assign(:import, NeptuneImport.new) } - - let!(:available_imports) { assign(:available_imports, []) } - - it "should display a radio button to choose import type" do - render - rendered.should have_selector("input", :type => "radio", :name => "import[type]") - end - -end diff --git a/spec/views/rule_parameter_sets/index.html.erb_spec.rb b/spec/views/rule_parameter_sets/index.html.erb_spec.rb new file mode 100644 index 000000000..0f50ea387 --- /dev/null +++ b/spec/views/rule_parameter_sets/index.html.erb_spec.rb @@ -0,0 +1,22 @@ +require 'spec_helper' + +describe "/rule_parameter_sets/index" do + + assign_referential + let!(:rule_parameter_sets) { assign :rule_parameter_sets, [ Factory(:rule_parameter_set), + Factory(:rule_parameter_set)] } + + it "should render a show link for each rule_parameter_set" do + render + rule_parameter_sets.each do |rule_parameter_set| + rendered.should have_selector(".rule_parameter_set a[href='#{view.referential_rule_parameter_set_path(referential, rule_parameter_set)}']", :text => rule_parameter_set.name) + end + end + + it "should render a link to create a new rule_parameter_set" do + render + view.content_for(:sidebar).should have_selector(".actions a[href='#{new_referential_rule_parameter_set_path(referential)}']") + end + +end + diff --git a/spec/views/rule_parameter_sets/new.html.erb_spec.rb b/spec/views/rule_parameter_sets/new.html.erb_spec.rb new file mode 100644 index 000000000..4670ecceb --- /dev/null +++ b/spec/views/rule_parameter_sets/new.html.erb_spec.rb @@ -0,0 +1,26 @@ +require 'spec_helper' + +describe "/rule_parameter_sets/new" do + + assign_referential + let!(:rule_parameter_set) { assign :rule_parameter_set, build( :rule_parameter_set, :referential => referential) } + + describe "form" do + + it "should render input for name" do + render + rendered.should have_selector("form") do + with_selector "input[type=text][name=?]", rule_parameter_set.name + end + end + it "should render input div for added_mode_parameter_set" do + render + rendered.should have_selector("form") do + with_selector "#added_mode_parameter_set" + end + end + + end + +end + |
