Sha256: fb0ceb5fe2a2ca709057c09d2224c305a9f97b980ba1568ef3ae22aac538f618

Contents?: true

Size: 1.06 KB

Versions: 4

Compression:

Stored size: 1.06 KB

Contents

# TODO: This will not work until we solve issue #62.
# Until then, these tests are pending.

# rubocop:disable RSpec/DescribeClass
shared_examples_for '.save with nested model' do |required_hash, nested_model_key, nested_model_hash, nested_entity|
  describe '.save with nested model' do
    let( :repository ){ described_class.new }
    let( :new_hash ) do
      required_hash.merge( nested_model_key => nested_entity )
    end
    let( :response ) do
      VCR.use_cassette( "#{ vcr_dir }/save_with_nested_model" ) do
        model = described_class::MODEL.new( new_hash )
        repository.save( model )
      end
    end

    it 'does not raise any errors' do
      expect{ response }.not_to raise_error
    end

    describe 'returned entity\'s nested model' do
      subject(:returned_nested_model){ response.send(nested_model_key).first }

      it 'has the wanted attributes' do
        nested_model_hash.each do |attribute, value|
          expect(returned_nested_model.send(attribute)).to eq(value)
        end
      end
    end
  end
end
# rubocop:enable RSpec/DescribeClass

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
fortnox-api-0.5.2 spec/fortnox/api/repositories/examples/save_with_nested_model.rb
fortnox-api-0.5.1 spec/fortnox/api/repositories/examples/save_with_nested_model.rb
fortnox-api-0.5.0 spec/fortnox/api/repositories/examples/save_with_nested_model.rb
fortnox-api-0.4.0 spec/fortnox/api/repositories/examples/save_with_nested_model.rb