Sha256: 40b45e84e1b0f7f06c5e9222d6a07558123accda686c0e17aaed66fba0a412a5

Contents?: true

Size: 1.18 KB

Versions: 1

Compression:

Stored size: 1.18 KB

Contents

require 'spec_helper'
require 'fortnox/api/models/invoice'

describe Fortnox::API::Model::Invoice do
  shared_examples 'having value objects' do |value_object_class|
    context "when having an #{value_object_class}" do
      it "returns the correct object" do
        value_object = value_object_class.new
        invoice = described_class.new( attribute => value_object )
        expect(invoice.send(attribute)).to eq(value_object)
      end
    end
  end

  describe 'association with Fortnox::API::Model::Row' do
    context 'when having an Invoice Row' do
      it 'returns the correct Row' do
        row = Fortnox::API::Model::Row.new
        invoice = described_class.new( invoice_rows: [row] )
        expect(invoice.invoice_rows).to eq([row])
      end
    end
  end

  describe 'association with Fortnox::API::Model::EmailInformation' do
    include_examples 'having value objects', Fortnox::API::Model::EmailInformation do
      let( :attribute ){ :email_information }
    end
  end

  describe 'association with Fortnox::API::Model::EDIInformation' do
    include_examples 'having value objects', Fortnox::API::Model::EDIInformation do
      let( :attribute ){ :edi_information }
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
fortnox-api-0.1.0 spec/fortnox/api/models/invoice_spec.rb