spec/models/chouette/access_link_spec.rb in ninoxe-1.1.5 vs spec/models/chouette/access_link_spec.rb in ninoxe-1.2.0

- old
+ new

@@ -1,17 +1,21 @@ require 'spec_helper' -describe Chouette::AccessLink do - subject { Factory(:access_link) } +describe Chouette::AccessLink, :type => :model do + subject { create(:access_link) } - it { should validate_uniqueness_of :objectid } - its(:objectid) { should be_kind_of(Chouette::ObjectId) } + it { is_expected.to validate_uniqueness_of :objectid } - it { should validate_presence_of :name } - it { should validate_presence_of :link_type } - it { should validate_presence_of :link_orientation } + describe '#objectid' do + subject { super().objectid } + it { is_expected.to be_kind_of(Chouette::ObjectId) } + end + it { is_expected.to validate_presence_of :name } + it { is_expected.to validate_presence_of :link_type } + it { is_expected.to validate_presence_of :link_orientation } + describe "#access_link_type" do def self.legacy_link_types %w{Underground Mixed Overground} end @@ -19,21 +23,21 @@ legacy_link_types.each do |link_type| context "when link_type is #{link_type}" do access_link_type = Chouette::ConnectionLinkType.new(link_type.underscore) it "should be #{access_link_type}" do subject.link_type = link_type - subject.access_link_type.should == access_link_type + expect(subject.access_link_type).to eq(access_link_type) end end end end describe "#access_link_type=" do it "should change link_type with ConnectionLinkType#name" do subject.access_link_type = "underground" - subject.link_type.should == "Underground" + expect(subject.link_type).to eq("Underground") end end describe "#link_orientation_type" do @@ -45,33 +49,33 @@ legacy_link_orientations.each do |link_orientation| context "when link_orientation is #{link_orientation}" do link_orientation_type = Chouette::LinkOrientationType.new(link_orientation.underscore) it "should be #{link_orientation_type}" do subject.link_orientation = link_orientation - subject.link_orientation_type.should == link_orientation_type + expect(subject.link_orientation_type).to eq(link_orientation_type) end end end end describe "#link_orientation_type=" do it "should change link_orientation with LinkOrientationType#name" do subject.link_orientation_type = "access_point_to_stop_area" - subject.link_orientation.should == "AccessPointToStopArea" + expect(subject.link_orientation).to eq("AccessPointToStopArea") end end describe "#link_key" do it "should calculate link_key for access to area" do subject.link_orientation_type = "access_point_to_stop_area" - subject.link_key.should == "A_#{subject.access_point.id}-S_#{subject.stop_area.id}" + expect(subject.link_key).to eq("A_#{subject.access_point.id}-S_#{subject.stop_area.id}") end it "should calculate link_key for area to access" do subject.link_orientation_type = "stop_area_to_access_point" - subject.link_key.should == "S_#{subject.stop_area.id}-A_#{subject.access_point.id}" + expect(subject.link_key).to eq("S_#{subject.stop_area.id}-A_#{subject.access_point.id}") end end end