Sha256: 0ae3f548cd6d2f78bae06aa8821a0e9de22f114b2923e64074002d5bd6ad71e2

Contents?: true

Size: 1.41 KB

Versions: 8

Compression:

Stored size: 1.41 KB

Contents

# frozen_string_literal: true

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

8 entries across 8 versions & 1 rubygems

Version Path
fortnox-api-0.8.0 spec/fortnox/api/types/nullable_spec.rb
fortnox-api-0.7.2 spec/fortnox/api/types/nullable_spec.rb
fortnox-api-0.7.1 spec/fortnox/api/types/nullable_spec.rb
fortnox-api-0.7.0 spec/fortnox/api/types/nullable_spec.rb
fortnox-api-0.6.3 spec/fortnox/api/types/nullable_spec.rb
fortnox-api-0.6.2 spec/fortnox/api/types/nullable_spec.rb
fortnox-api-0.6.1 spec/fortnox/api/types/nullable_spec.rb
fortnox-api-0.6.0 spec/fortnox/api/types/nullable_spec.rb