Sha256: 71808874c50c8729557beaa2b93bca803e2e16790b06c5610d3c09c5364d55bc
Contents?: true
Size: 1.65 KB
Versions: 1
Compression:
Stored size: 1.65 KB
Contents
require 'rest_in_peace' describe RESTinPeace do let(:struct) { Struct.new(:name) } let(:extended_class) do Class.new(struct) do include RESTinPeace end end let(:attributes) { { name: 'test' } } let(:instance) { extended_class.new(attributes) } describe '::api' do subject { extended_class } specify { expect(subject).to respond_to(:api).with(0).arguments } end describe '::rest_in_peace' do subject { extended_class } specify { expect(subject).to respond_to(:rest_in_peace).with(0).arguments } let(:definition_proxy) { object_double(RESTinPeace::DefinitionProxy) } it 'evaluates the given block inside the definition proxy' do allow(RESTinPeace::DefinitionProxy).to receive(:new).with(subject).and_return(definition_proxy) expect(definition_proxy).to receive(:instance_eval) do |&block| expect(block).to be_instance_of(Proc) end subject.rest_in_peace { } end end describe '#api' do subject { instance } specify { expect(subject).to respond_to(:api).with(0).arguments } end describe '#to_h' do subject { instance } specify { expect(subject).to respond_to(:to_h).with(0).arguments } end describe '#initialize' do subject { instance } specify { expect(subject.name).to eq('test') } context 'unknown params' do let(:attributes) { { name: 'test42', email: 'yolo@example.org' } } specify { expect(subject.name).to eq('test42') } specify { expect { subject.email }.to raise_error(NoMethodError) } end context 'not given param' do let(:attributes) { {} } specify { expect(subject.name).to eq(nil) } end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
rest-in-peace-1.1.0 | spec/rest_in_peace_spec.rb |