Sha256: e0a0046c9cb39e27366e9d421bc688ec963b4e38cfba346dc440b23c757f6bba

Contents?: true

Size: 1.09 KB

Versions: 27

Compression:

Stored size: 1.09 KB

Contents

require "spec_helper"

describe CFoundry::V1::ModelMagic do
  let(:client) { v1_fake_client }
  let(:mymodel) { v1_fake_model }
  let(:guid) { random_string("my-object-guid") }
  let(:myobject) { mymodel.new(guid, client) }

  describe "#read_manifest" do
    context "with an attribute with different read/write locations" do
      let(:mymodel) do
        v1_fake_model do
          attribute :foo, :string, :read => :x, :write => [:y, :z]
        end
      end

      before do
        stub(client.base).my_fake_model { { :x => "abc" } }
      end

      it "reads from the write location" do
        expect {
          myobject.foo = "def"
        }.to change { myobject.read_manifest[:foo] }.from("abc").to("def")
      end
    end
  end

  describe "#write_manifest" do
    context "with a read-only attribute" do
      let(:mymodel) do
        v1_fake_model do
          attribute :foo, :string, :read_only => true
        end
      end

      it "does not include the attribute" do
        myobject.fake(:foo => "bar")
        expect(myobject.write_manifest).to_not include :foo
      end
    end
  end
end

Version data entries

27 entries across 27 versions & 2 rubygems

Version Path
static-1.0.3 vendor/cfoundry-0.5.2/spec/cfoundry/v1/model_magic_spec.rb
cfoundry-0.6.1.rc4 spec/cfoundry/v1/model_magic_spec.rb
cfoundry-0.5.3.rc7 spec/cfoundry/v1/model_magic_spec.rb
static-1.0.1 vendor/cfoundry-0.5.2/spec/cfoundry/v1/model_magic_spec.rb
cfoundry-0.6.1.rc3 spec/cfoundry/v1/model_magic_spec.rb
cfoundry-0.6.1.rc2 spec/cfoundry/v1/model_magic_spec.rb
cfoundry-0.6.1.rc1 spec/cfoundry/v1/model_magic_spec.rb
cfoundry-0.6.0 spec/cfoundry/v1/model_magic_spec.rb
cfoundry-0.6.0.rc6 spec/cfoundry/v1/model_magic_spec.rb
cfoundry-0.6.0.rc5 spec/cfoundry/v1/model_magic_spec.rb
cfoundry-0.5.3.rc6 spec/cfoundry/v1/model_magic_spec.rb
cfoundry-0.6.0.rc4 spec/cfoundry/v1/model_magic_spec.rb
cfoundry-0.6.0.rc3 spec/cfoundry/v1/model_magic_spec.rb
cfoundry-0.6.0.rc2 spec/cfoundry/v1/model_magic_spec.rb
cfoundry-0.6.0.rc1 spec/cfoundry/v1/model_magic_spec.rb
cfoundry-0.5.3.rc5 spec/cfoundry/v1/model_magic_spec.rb
cfoundry-0.5.3.rc4 spec/cfoundry/v1/model_magic_spec.rb
cfoundry-0.5.3.rc3 spec/cfoundry/v1/model_magic_spec.rb
cfoundry-0.5.3.rc2 spec/cfoundry/v1/model_magic_spec.rb
cfoundry-0.5.3.rc1 spec/cfoundry/v1/model_magic_spec.rb