Sha256: 59df5343bc104f3111aa4430298502e58fad5271aeb108a94c3613af324dae69

Contents?: true

Size: 1.38 KB

Versions: 6

Compression:

Stored size: 1.38 KB

Contents

require 'spec_helper'
require 'dry-struct'
require 'fortnox/api/types'

describe Fortnox::API::Types::Nullable, type: :type do
  subject{ TestStruct }

  describe 'String' do
    using_test_class do
      class TestStruct < Dry::Struct
        attribute :string, Fortnox::API::Types::Nullable::String
      end
    end

    it{ is_expected.to have_nullable(:string, 'A simple message', 0, '0') }
  end

  describe 'Float' do
    using_test_class do
      class TestStruct < Dry::Struct
        attribute :float, Fortnox::API::Types::Nullable::Float
      end
    end

    it{ is_expected.to have_nullable(:float, 14.0, 'Not a Float!', 0.0) }
  end

  describe 'Integer' do
    using_test_class do
      class TestStruct < Dry::Struct
        attribute :integer, Fortnox::API::Types::Nullable::Integer
      end
    end

    it{ is_expected.to have_nullable(:integer, 14, 14.0, 14) }
  end

  describe 'Boolean' do
    using_test_class do
      class TestStruct < Dry::Struct
        attribute :boolean, Fortnox::API::Types::Nullable::Boolean
      end
    end

    it{ is_expected.to have_nullable(:boolean, true, 'Not a Boolean!', false) }
  end

  describe 'Date' do
    using_test_class do
      class TestStruct < Dry::Struct
        attribute :date, Fortnox::API::Types::Nullable::Date
      end
    end

    it{ is_expected.to have_nullable_date(:date, Date.new(2016, 1, 1), 'Not a Date!') }
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
fortnox-api-0.5.2 spec/fortnox/api/types/nullable_spec.rb
fortnox-api-0.5.1 spec/fortnox/api/types/nullable_spec.rb
fortnox-api-0.5.0 spec/fortnox/api/types/nullable_spec.rb
fortnox-api-0.4.0 spec/fortnox/api/types/nullable_spec.rb
fortnox-api-0.3.0 spec/fortnox/api/types/nullable_spec.rb
fortnox-api-0.2.0 spec/fortnox/api/types/nullable_spec.rb