Sha256: 16e51cff89787e3892a63efca05489b1848075c7f822ef179c52779992974825
Contents?: true
Size: 1.95 KB
Versions: 2
Compression:
Stored size: 1.95 KB
Contents
require "spec_helper" module Uuids describe "Base.belongs_by_uuid_to" do context "when a corresponding _uuid column is absent" do it "raises NotImplementedError" do # The city has no "country_uuid" column expect { City.send :belongs_by_uuid_to, :country } .to raise_error { NotImplementedError } end end context ":state" do let!(:state) { State.create uuid: SecureRandom.uuid } before { City.send :belongs_by_uuid_to, :state } subject { City.new } describe "#state" do it "is defined" do expect(subject).to respond_to :state expect(subject.method(:state).arity).to eq 0 end it "corresponds to #state_uuid" do expect { subject.state_uuid = state.uuid } .to change { subject.state }.to state end end describe "#state=" do it "is defined" do expect(subject).to respond_to :state= expect(subject.method(:state=).arity).to eq 1 end it "sets the #state" do expect { subject.state = state }.to change { subject.state }.to state end it "sets the #state_uuid" do expect { subject.state = state } .to change { subject.state_uuid }.to state.uuid end it "resets the #state" do subject.state = state expect { subject.state = nil }.to change { subject.state }.to nil end it "resets the #state_uuid" do subject.state = state expect { subject.state = nil }.to change { subject.state_uuid }.to nil end end # it "resets the object uuid" do # subject.state = state # expect { subject.state = nil }.to change { subject.state_uuid }.to nil # end # it "sets the object by uuid" do # expect { subject.state_uuid = state.uuid } # .to change { subject.state }.to state # end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
uuids-5.0.0 | spec/tests/lib/base/belongs_by_uuid_to_spec.rb |
uuids-4.1.8 | spec/uuids/lib/base/belongs_by_uuid_to_spec.rb |