Sha256: ffe7cb4a9ef4ae9b9b494d00f30900eb84ba6bbbdb8e7bfd694c987c88d78869

Contents?: true

Size: 1.48 KB

Versions: 22

Compression:

Stored size: 1.48 KB

Contents

require 'rest_in_peace'
require 'rest_in_peace/definition_proxy/attributes_definitions'

describe RESTinPeace::DefinitionProxy::AttributesDefinitions do
  let(:target) do
    Class.new do
      include RESTinPeace
    end
  end
  let(:instance_of_target) { target.new }
  let(:definitions) { described_class.new(target) }

  subject { definitions }

  describe '#read' do
    it 'defines a getter for the given attributes' do
      expect { subject.read(:id) }.to change { instance_of_target.respond_to?(:id) }.from(false).to(true)
    end
    it 'does not define a setter for the given attributes' do
      expect { subject.read(:id) }.to_not change { instance_of_target.respond_to?(:id=) }.from(false)
    end
    specify { expect { subject.read(:id) }.to change { target.rip_attributes[:read] }.from([]).to([:id]) }
    specify { expect { subject.read(:id) }.to_not change { target.rip_attributes[:write] }.from([]) }
  end

  describe '#write' do
    it 'defines a getter for the given attributes' do
      expect { subject.write(:id) }.to change { instance_of_target.respond_to?(:id) }.from(false).to(true)
    end
    it 'defines a setter for the given attributes' do
      expect { subject.write(:id) }.to change { instance_of_target.respond_to?(:id=) }.from(false).to(true)
    end
    specify { expect { subject.write(:id) }.to change { target.rip_attributes[:read] }.from([]).to([:id]) }
    specify { expect { subject.write(:id) }.to change { target.rip_attributes[:write] }.from([]).to([:id]) }
  end
end

Version data entries

22 entries across 22 versions & 1 rubygems

Version Path
rest-in-peace-6.2.0 spec/rest_in_peace/definition_proxy/attributes_definitions_spec.rb
rest-in-peace-6.1.1 spec/rest_in_peace/definition_proxy/attributes_definitions_spec.rb
rest-in-peace-6.1.0 spec/rest_in_peace/definition_proxy/attributes_definitions_spec.rb
rest-in-peace-6.0.4 spec/rest_in_peace/definition_proxy/attributes_definitions_spec.rb
rest-in-peace-6.0.3 spec/rest_in_peace/definition_proxy/attributes_definitions_spec.rb
rest-in-peace-6.0.2 spec/rest_in_peace/definition_proxy/attributes_definitions_spec.rb
rest-in-peace-6.0.0 spec/rest_in_peace/definition_proxy/attributes_definitions_spec.rb
rest-in-peace-5.1.0 spec/rest_in_peace/definition_proxy/attributes_definitions_spec.rb
rest-in-peace-5.0.2 spec/rest_in_peace/definition_proxy/attributes_definitions_spec.rb
rest-in-peace-5.0.1 spec/rest_in_peace/definition_proxy/attributes_definitions_spec.rb
rest-in-peace-5.0.0 spec/rest_in_peace/definition_proxy/attributes_definitions_spec.rb
rest-in-peace-4.2.1 spec/rest_in_peace/definition_proxy/attributes_definitions_spec.rb
rest-in-peace-4.2.0 spec/rest_in_peace/definition_proxy/attributes_definitions_spec.rb
rest-in-peace-4.1.1 spec/rest_in_peace/definition_proxy/attributes_definitions_spec.rb
rest-in-peace-4.1.0 spec/rest_in_peace/definition_proxy/attributes_definitions_spec.rb
rest-in-peace-4.0.0 spec/rest_in_peace/definition_proxy/attributes_definitions_spec.rb
rest-in-peace-3.0.0 spec/rest_in_peace/definition_proxy/attributes_definitions_spec.rb
rest-in-peace-2.0.4 spec/rest_in_peace/definition_proxy/attributes_definitions_spec.rb
rest-in-peace-2.0.3 spec/rest_in_peace/definition_proxy/attributes_definitions_spec.rb
rest-in-peace-2.0.2 spec/rest_in_peace/definition_proxy/attributes_definitions_spec.rb