Sha256: 9d2ebd4abd73038e168a0af248cbbd2f2507d8a238a42510dda3434e150d4b25

Contents?: true

Size: 827 Bytes

Versions: 90

Compression:

Stored size: 827 Bytes

Contents

require '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

90 entries across 60 versions & 10 rubygems

Version Path
apl-library-0.0.90 vendor/bundle/ruby/2.1.0/gems/apl-library-0.0.90/vendor/bundle/ruby/1.9.1/gems/shoulda-2.11.3/test/other/private_helpers_test.rb
apl-library-0.0.90 vendor/bundle/ruby/1.9.1/gems/shoulda-2.11.3/test/other/private_helpers_test.rb
apl-library-0.0.90 vendor/bundle/ruby/2.1.0/gems/apl-library-0.0.90/vendor/bundle/ruby/2.1.0/gems/shoulda-2.11.3/test/other/private_helpers_test.rb
apl-library-0.0.90 vendor/bundle/ruby/2.1.0/gems/shoulda-2.11.3/test/other/private_helpers_test.rb
dirty_history-0.7.3 dirty_history/ruby/1.9.1/gems/shoulda-2.11.3/test/other/private_helpers_test.rb
dirty_history-0.7.2 dirty_history/ruby/1.9.1/gems/shoulda-2.11.3/test/other/private_helpers_test.rb
dirty_history-0.7.1 dirty_history/ruby/1.9.1/gems/shoulda-2.11.3/test/other/private_helpers_test.rb
dirty_history-0.7.0 dirty_history/ruby/1.9.1/gems/shoulda-2.11.3/test/other/private_helpers_test.rb
dirty_history-0.6.7 dirty_history/ruby/1.9.1/gems/shoulda-2.11.3/test/other/private_helpers_test.rb
dirty_history-0.6.6 dirty_history/ruby/1.9.1/gems/shoulda-2.11.3/test/other/private_helpers_test.rb
dirty_history-0.6.5 dirty_history/ruby/1.9.1/gems/shoulda-2.11.3/test/other/private_helpers_test.rb
dirty_history-0.6.4 dirty_history/ruby/1.9.1/gems/shoulda-2.11.3/test/other/private_helpers_test.rb
dirty_history-0.6.3 dirty_history/ruby/1.9.1/gems/shoulda-2.11.3/test/other/private_helpers_test.rb
challah-0.6.2 vendor/bundle/gems/shoulda-2.11.3/test/other/private_helpers_test.rb
dirty_history-0.6.2 dirty_history/ruby/1.9.1/gems/shoulda-2.11.3/test/other/private_helpers_test.rb
dirty_history-0.6.1 dirty_history/ruby/1.9.1/gems/shoulda-2.11.3/test/other/private_helpers_test.rb
dirty_history-0.6.0 dirty_history/ruby/1.9.1/gems/shoulda-2.11.3/test/other/private_helpers_test.rb
challah-0.6.1 vendor/bundle/gems/shoulda-2.11.3/test/other/private_helpers_test.rb
dirty_history-0.5.4 dirty_history/ruby/1.9.1/gems/shoulda-2.11.3/test/other/private_helpers_test.rb
challah-0.6.0 vendor/bundle/gems/shoulda-2.11.3/test/other/private_helpers_test.rb