Sha256: 882d5f959a6ce130f5edc41b1af03356802ac80a866134c9109f047ae26002ca

Contents?: true

Size: 822 Bytes

Versions: 7

Compression:

Stored size: 822 Bytes

Contents

require "multi_json"

shared_examples_for "a summarizeable model" do
  describe "#summary" do
    let(:summary_endpoint) {
      [ client.target,
        "v2",
        subject.class.plural_object_name,
        subject.guid,
        "summary"
      ].join("/")
    }

    it "returns the summary endpoint payload" do
      req = stub_request(:get, summary_endpoint).to_return :status => 200,
        :body => MultiJson.encode(summary_attributes)

      expect(subject.summary).to eq(summary_attributes)
      expect(req).to have_been_requested
    end
  end

  describe "#summarize!" do
    it "defines basic attributes via #summary" do
      stub(subject).summary { summary_attributes }

      subject.summarize!

      summary_attributes.each do |k, v|
        expect(subject.send(k)).to eq v
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
cfoundry-2.2.0.rc1 spec/support/shared_examples/model_summary_examples.rb
cfoundry-2.1.2.rc1 spec/support/shared_examples/model_summary_examples.rb
cfoundry-2.1.1 spec/support/shared_examples/model_summary_examples.rb
cfoundry-2.1.0 spec/support/shared_examples/model_summary_examples.rb
cfoundry-2.0.2 spec/support/shared_examples/model_summary_examples.rb
cfoundry-2.0.1.rc1 spec/support/shared_examples/model_summary_examples.rb
cfoundry-2.0.0 spec/support/shared_examples/model_summary_examples.rb