diff options
| author | Alban Peignier | 2017-12-20 09:47:30 +0100 |
|---|---|---|
| committer | GitHub | 2017-12-20 09:47:30 +0100 |
| commit | c13540b1b10451c9b26045cbfcb5ec397d1ddbc0 (patch) | |
| tree | aad16c680a6f0dfe407d0306d381cdd71fab86d5 /spec | |
| parent | fe7f4003569630a73980e87c370d4130e1d18098 (diff) | |
| parent | 79c64f5f5cd550671c4f8dd81c26100137f05f4d (diff) | |
| download | chouette-core-c13540b1b10451c9b26045cbfcb5ec397d1ddbc0.tar.bz2 | |
Merge pull request #157 from af83/5311-stop-area-type-customizable
Make customizable StopArea type. Refs #5311
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 |
