spec/sugar-high/arguments_spec.rb in sugar-high-0.4.5 vs spec/sugar-high/arguments_spec.rb in sugar-high-0.4.5.2
- old
+ new
@@ -18,10 +18,46 @@
context 'Array' do
it "should return arg list with 'hello', 'you'" do
[:hello, ['you']].args.should == ['hello', 'you']
end
+
+ describe '#last_arg' do
+ context 'Last arg with default hello' do
+ it "should return the default :hello" do
+ [3,4].last_arg(:hello).should == :hello
+ end
+
+ it "should return the :hello => 'abe' " do
+ [{:hi => :def}, 3, 4, :hi => 'abe'].last_arg.should == {:hi => 'abe'}
+ [{:hi => :def}, [3,4, :hi => 'abe']].last_arg.should == {:hi => 'abe'}
+ end
+ end
+ end
+
+ describe '#last_option' do
+ it "should return the last hash" do
+ [3,4, :x => 3, :y => 5].last_option.should == {:x => 3, :y => 5}
+ end
+ end
+
+ describe "Last argument value" do
+ context 'Last arg with default hello' do
+ it "should return the arg value 'abe' " do
+ [3,4, :hi => 'abe'].last_arg_value(:hi => :def).should == 'abe'
+ [[3,4, :hi => 'abe']].last_arg_value(:hi => :def).should == 'abe'
+ end
+
+ it "should return the arg value :def " do
+ [:hello => 'abe', :good => true].last_arg_value(:hi => :def).should == :def
+ end
+
+ it "should return the arg value :def " do
+ [3,4].last_arg_value(:hi => :def).should == :def
+ end
+ end
+ end
end
describe "Last argument" do
context 'Last arg with default hello' do
it "should return the default :hello" do
@@ -29,10 +65,10 @@
end
it "should return the :hello => 'abe' " do
last_arg({:hi => :def}, 3,4, :hi => 'abe').should == {:hi => 'abe'}
last_arg({:hi => :def}, [3,4, :hi => 'abe']).should == {:hi => 'abe'}
- end
+ end
end
end
describe "Last argument value" do
context 'Last arg with default hello' do