Sha256: b9614c81bfd5922b118760d638884cec026c8a5db7b443b559c5e36a2b4123f7

Contents?: true

Size: 872 Bytes

Versions: 38

Compression:

Stored size: 872 Bytes

Contents

require File.join(File.dirname(__FILE__), '..', 'test_helper')

class PrivateHelpersTest < ActiveSupport::TestCase # :nodoc:
  include Shoulda::Private
  context "get_options!" do
    should "remove opts from args" do
      args = [:a, :b, {}]
      get_options!(args)
      assert_equal [:a, :b], args
    end

    should "return wanted opts in order" do
      args = [{:one => 1, :two => 2}]
      one, two = get_options!(args, :one, :two)
      assert_equal 1, one
      assert_equal 2, two
    end

    should "raise ArgumentError if given unwanted option" do
      args = [{:one => 1, :two => 2}]
      assert_raises ArgumentError do
        get_options!(args, :one)
      end
    end
    
    should "return single wanted option" do
      args = [:a, :b, {:class => Object}]
      klass = get_options!(args,:class)
      assert_equal Object, klass
    end
  end
end

Version data entries

38 entries across 38 versions & 10 rubygems

Version Path
auser-poolparty-1.3.0 vendor/gems/shoulda/test/other/private_helpers_test.rb
auser-poolparty-1.3.1 vendor/gems/shoulda/test/other/private_helpers_test.rb
auser-poolparty-1.3.10 vendor/gems/shoulda/test/other/private_helpers_test.rb
auser-poolparty-1.3.11 vendor/gems/shoulda/test/other/private_helpers_test.rb
auser-poolparty-1.3.12 vendor/gems/shoulda/test/other/private_helpers_test.rb
auser-poolparty-1.3.13 vendor/gems/shoulda/test/other/private_helpers_test.rb
auser-poolparty-1.3.14 vendor/gems/shoulda/test/other/private_helpers_test.rb
auser-poolparty-1.3.15 vendor/gems/shoulda/test/other/private_helpers_test.rb
auser-poolparty-1.3.16 vendor/gems/shoulda/test/other/private_helpers_test.rb
auser-poolparty-1.3.17 vendor/gems/shoulda/test/other/private_helpers_test.rb
auser-poolparty-1.3.2 vendor/gems/shoulda/test/other/private_helpers_test.rb
auser-poolparty-1.3.3 vendor/gems/shoulda/test/other/private_helpers_test.rb
auser-poolparty-1.3.4 vendor/gems/shoulda/test/other/private_helpers_test.rb
auser-poolparty-1.3.5 vendor/gems/shoulda/test/other/private_helpers_test.rb
auser-poolparty-1.3.6 vendor/gems/shoulda/test/other/private_helpers_test.rb
auser-poolparty-1.3.7 vendor/gems/shoulda/test/other/private_helpers_test.rb
auser-poolparty-1.3.8 vendor/gems/shoulda/test/other/private_helpers_test.rb
fairchild-poolparty-1.3.17 vendor/gems/shoulda/test/other/private_helpers_test.rb
fairchild-poolparty-1.3.5 vendor/gems/shoulda/test/other/private_helpers_test.rb
iGEL-shoulda-2.10.2 test/other/private_helpers_test.rb