Sha256: 0dde98e6a46de1c1b1016ec74676ae4141891f583fc452a008aeb2f491b2947f

Contents?: true

Size: 725 Bytes

Versions: 4

Compression:

Stored size: 725 Bytes

Contents

require File.dirname(__FILE__) + '/../../spec_helper'

describe "extracting options from arguments" do
  def the_method(*args)
    [extract_options_from_args!(args), args]
  end
  
  it "should extract the hash if the last item is a hash" do
    opts,args = the_method(:one, :two, :key => :value)
    opts.should == { :key => :value }
    args.should == [:one, :two]
  end
  
  it "should return nil for the opts if no hash is provided" do
    opts,args = the_method(:one, :two)
    opts.should be_nil
    args.should == [:one, :two]
  end
  
  it "should return two hashes" do
    opts,args = the_method({ :one => :two }, { :key => :value })
    opts.should == {:key => :value}
    args.should == [{:one => :two}]
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
merb-0.5.0 spec/merb/core_ext/kernel_spec.rb
merb-0.5.1 spec/merb/core_ext/kernel_spec.rb
merb-0.5.2 spec/merb/core_ext/kernel_spec.rb
merb-0.5.3 spec/merb/core_ext/kernel_spec.rb