Sha256: ce348e819927115afa301a8f97cf9ce34fd6755c60c457e197951a8d5c2e7bab

Contents?: true

Size: 973 Bytes

Versions: 5

Compression:

Stored size: 973 Bytes

Contents

require 'spec_helper'

describe G5Updatable::BelongsToLocation do
  describe "#location" do
    let(:location_uid) { "https://example.com/location_uid" }
    let(:favorite_food) { FavoriteFood.new(location_uid: location_uid) }
    subject { favorite_food.location }

    context "when the assocaited location_uid exists" do
      let!(:location) { FactoryGirl.create(:location, uid: location_uid) }
      it { should eq(location) }

      context "when the location_uid changes after it has already been fetched" do
        let!(:new_location) { FactoryGirl.create(:location) }
        before do
          favorite_food.location
          favorite_food.location_uid = new_location.uid
        end

        it { should eq(new_location) }
      end
    end

    context "when the assocaited location_uid does not exist" do
      it "raises a helpful exception" do
        expect { subject }.to raise_error(ActiveRecord::RecordNotFound, /example/)
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
g5_updatable-0.3.5 spec/concerns/g5_updatable/belongs_to_location_spec.rb
g5_updatable-0.3.4 spec/concerns/g5_updatable/belongs_to_location_spec.rb
g5_updatable-0.3.3 spec/concerns/g5_updatable/belongs_to_location_spec.rb
g5_updatable-0.3.2 spec/concerns/g5_updatable/belongs_to_location_spec.rb
g5_updatable-0.3.1 spec/concerns/g5_updatable/belongs_to_location_spec.rb