Sha256: d8a078350a42f562a3dea3a3a7f86f615859c439669e2d37df532920713b1890

Contents?: true

Size: 837 Bytes

Versions: 36

Compression:

Stored size: 837 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

36 entries across 36 versions & 1 rubygems

Version Path
inch-0.3.3 test/unit/api/options/base_test.rb
inch-0.3.3.rc1 test/unit/api/options/base_test.rb
inch-0.3.2 test/unit/api/options/base_test.rb
inch-0.3.2.rc2 test/unit/api/options/base_test.rb
inch-0.3.2.rc1 test/unit/api/options/base_test.rb
inch-0.3.1 test/inch/api/options/base_test.rb
inch-0.3.1.rc6 test/inch/api/options/base_test.rb
inch-0.3.1.rc5 test/inch/api/options/base_test.rb
inch-0.3.1.rc4 test/inch/api/options/base_test.rb
inch-0.3.1.rc3 test/inch/api/options/base_test.rb
inch-0.3.1.rc2 test/inch/api/options/base_test.rb
inch-0.3.1.rc1 test/inch/api/options/base_test.rb
inch-0.3.0 test/inch/api/options/base_test.rb
inch-0.3.0.rc3 test/inch/api/options/base_test.rb
inch-0.3.0.rc2 test/inch/api/options/base_test.rb
inch-0.3.0.rc1 test/inch/api/options/base_test.rb