Sha256: 26e697748762e40590ea7dc98451673c93425ff6ad29cbffa426d7915f3004cf

Contents?: true

Size: 1.02 KB

Versions: 16

Compression:

Stored size: 1.02 KB

Contents

require 'rails_helper'

describe LHS::Record do
  before(:each) do
    class Record < LHS::Record
      endpoint 'http://datastore/records/:id'
    end
    stub_request(:get, "http://datastore/records/1")
      .to_return(body: attrbitutes.to_json)
  end

  let(:record) { Record.find(1) }
  let(:attrbitutes) do
    {
      name: 'Steve',
      kind: {
        animal: {
          type: 'Monkey'
        }
      }
    }
  end

  let(:output) { "Record##{record.object_id}\n:name => \"Steve\"\n:kind => {:animal=>{:type=>\"Monkey\"}}" }

  context 'inspect' do
    it 'prints the record on the terminal: each attrbitute on a new line' do
      expect(record.inspect).to eq(output)
    end

    context 'with custom setters that do no touch raw data' do
      before do
        class Record
          attr_accessor :listing
        end
      end

      let(:record) { Record.new(attrbitutes.merge(listing: double('listing'))) }

      it 'does not print what is not in raw' do
        expect(record.inspect).to eq(output)
      end
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
lhs-7.0.3 spec/record/inspect_spec.rb
lhs-7.0.2 spec/record/inspect_spec.rb
lhs-7.0.1 spec/record/inspect_spec.rb
lhs-7.0.0 spec/record/inspect_spec.rb
lhs-6.8.2 spec/record/inspect_spec.rb
lhs-6.8.1 spec/record/inspect_spec.rb
lhs-6.8.0 spec/record/inspect_spec.rb
lhs-6.7.2 spec/record/inspect_spec.rb
lhs-6.7.1 spec/record/inspect_spec.rb
lhs-6.7.0 spec/record/inspect_spec.rb
lhs-6.6.2 spec/record/inspect_spec.rb
lhs-6.6.1 spec/record/inspect_spec.rb
lhs-6.6.0 spec/record/inspect_spec.rb
lhs-6.5.0 spec/record/inspect_spec.rb
lhs-6.4.0 spec/record/inspect_spec.rb
lhs-6.3.1 spec/record/inspect_spec.rb