Sha256: dcd4193fa57cbf9fddc50f9e0378a5b0f9f34335899da8807b7f119b812046ef

Contents?: true

Size: 832 Bytes

Versions: 34

Compression:

Stored size: 832 Bytes

Contents

require File.expand_path(File.dirname(__FILE__) + '/../../../test_helper')

describe ::Inch::API::Options::Base do
  class APIOptionsTest < ::Inch::API::Options::Base
    attribute :foo, :bar
    attribute :baz
    attribute :qux
  end

  it 'should work with a Hash or Struct' do
    @options_hash = { foo: 'foo', baz: 42 }
    @options_struct = OpenStruct.new(@options_hash)

    @options1 = APIOptionsTest.new @options_hash
    @options2 = APIOptionsTest.new @options_struct

    assert_equal 'foo', @options1.foo
    assert_equal 'foo', @options2.foo
    assert_equal 42, @options1.baz
    assert_equal 42, @options2.baz
  end

  it 'should return default values' do
    @options_hash = { baz: 42 }
    @options = APIOptionsTest.new @options_hash

    assert_equal :bar, @options.foo
    assert_equal 42, @options.baz
  end
end

Version data entries

34 entries across 34 versions & 1 rubygems

Version Path
inch-0.9.0.rc1 test/unit/api/options/base_test.rb
inch-0.8.0 test/unit/api/options/base_test.rb
inch-0.8.0.rc2 test/unit/api/options/base_test.rb
inch-0.8.0.rc1 test/unit/api/options/base_test.rb
inch-0.7.1 test/unit/api/options/base_test.rb
inch-0.7.0 test/unit/api/options/base_test.rb
inch-0.6.4 test/unit/api/options/base_test.rb
inch-0.6.3 test/unit/api/options/base_test.rb
inch-0.6.2 test/unit/api/options/base_test.rb
inch-0.6.1 test/unit/api/options/base_test.rb
inch-0.6.0 test/unit/api/options/base_test.rb
inch-0.6.0.rc6 test/unit/api/options/base_test.rb
inch-0.6.0.rc5 test/unit/api/options/base_test.rb
inch-0.6.0.rc4 test/unit/api/options/base_test.rb
inch-0.6.0.rc3 test/unit/api/options/base_test.rb
inch-0.6.0.rc2 test/unit/api/options/base_test.rb
inch-0.6.0.rc1 test/unit/api/options/base_test.rb
inch-0.5.10 test/unit/api/options/base_test.rb
inch-0.5.9 test/unit/api/options/base_test.rb
inch-0.5.8 test/unit/api/options/base_test.rb