diff options
Diffstat (limited to 'spec')
| -rw-r--r-- | spec/factories/chouette_stop_areas.rb | 2 | ||||
| -rw-r--r-- | spec/models/chouette/area_type_spec.rb | 32 |
2 files changed, 33 insertions, 1 deletions
diff --git a/spec/factories/chouette_stop_areas.rb b/spec/factories/chouette_stop_areas.rb index 8b64c227b..7f937e361 100644 --- a/spec/factories/chouette_stop_areas.rb +++ b/spec/factories/chouette_stop_areas.rb @@ -3,7 +3,7 @@ FactoryGirl.define do sequence(:objectid) { |n| "FR:#{n}:ZDE:#{n}:STIF" } sequence(:name) { |n| "stop_area_#{n}" } sequence(:registration_number) { |n| "test-#{n}" } - area_type { Chouette::StopArea.area_type.values.sample } + area_type { Chouette::AreaType.all.sample } latitude {10.0 * rand} longitude {10.0 * rand} diff --git a/spec/models/chouette/area_type_spec.rb b/spec/models/chouette/area_type_spec.rb new file mode 100644 index 000000000..470e3a066 --- /dev/null +++ b/spec/models/chouette/area_type_spec.rb @@ -0,0 +1,32 @@ +require "rails_helper" + +RSpec.describe Chouette::AreaType do + + describe "::ALL" do + it "includes all supported types" do + expect(Chouette::AreaType::ALL).to match_array( %i(zdep zder zdlp zdlr lda) ) + end + end + + describe ".find" do + it "returns nil if the given code is unknown" do + expect(Chouette::AreaType.find('dummy')).to be_nil + end + + it "returns an AreaType associated to the code" do + expect(Chouette::AreaType.find('zdep').code).to eq :zdep + end + end + + describe ".options" do + before do + Chouette::AreaType.reset_caches! + end + + it "returns an array with label and code for each type" do + allow(Chouette::AreaType).to receive(:all).and_return(%i{zdep lda}) + expect(Chouette::AreaType.options).to eq([["ZDEp", :zdep], ["LDA", :lda]]) + end + end + +end |
