update to RSpec 3.0

This commit is contained in:
Josh Holtrop 2014-06-25 14:11:39 -04:00
parent 31c63790f9
commit 2099aaa6e0
2 changed files with 57 additions and 53 deletions

View File

@ -6,19 +6,23 @@ PATH
GEM GEM
remote: https://rubygems.org/ remote: https://rubygems.org/
specs: specs:
diff-lcs (1.2.4) diff-lcs (1.2.5)
json (1.8.1) json (1.8.1)
rake (10.3.2) rake (10.3.2)
rdoc (4.1.1) rdoc (4.1.1)
json (~> 1.4) json (~> 1.4)
rspec (2.13.0) rspec (3.0.0)
rspec-core (~> 2.13.0) rspec-core (~> 3.0.0)
rspec-expectations (~> 2.13.0) rspec-expectations (~> 3.0.0)
rspec-mocks (~> 2.13.0) rspec-mocks (~> 3.0.0)
rspec-core (2.13.1) rspec-core (3.0.2)
rspec-expectations (2.13.0) rspec-support (~> 3.0.0)
diff-lcs (>= 1.1.3, < 2.0) rspec-expectations (3.0.2)
rspec-mocks (2.13.1) diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.0.0)
rspec-mocks (3.0.2)
rspec-support (~> 3.0.0)
rspec-support (3.0.2)
PLATFORMS PLATFORMS
ruby ruby

View File

@ -6,8 +6,8 @@ describe Yawpa do
options = { } options = { }
params = ['one', 'two', 'three', 'four'] params = ['one', 'two', 'three', 'four']
opts, args = Yawpa.parse(params, options) opts, args = Yawpa.parse(params, options)
opts.should eq({}) expect(opts).to eq({})
args.should eq(params) expect(args).to eq(params)
end end
it "raises an exception when an invalid option is passed" do it "raises an exception when an invalid option is passed" do
@ -24,10 +24,10 @@ describe Yawpa do
} }
params = ['--one', 'arg', '--two', 'arg2'] params = ['--one', 'arg', '--two', 'arg2']
opts, args = Yawpa.parse(params, options) opts, args = Yawpa.parse(params, options)
opts.include?(:one).should be_true expect(opts.include?(:one)).to be_truthy
opts.include?(:two).should be_true expect(opts.include?(:two)).to be_truthy
opts.include?(:three).should be_false expect(opts.include?(:three)).to be_falsey
args.should eq(['arg', 'arg2']) expect(args).to eq(['arg', 'arg2'])
end end
it "returns an option's value when nargs = 1" do it "returns an option's value when nargs = 1" do
@ -36,8 +36,8 @@ describe Yawpa do
} }
params = ['--opt', 'val', 'arg'] params = ['--opt', 'val', 'arg']
opts, args = Yawpa.parse(params, options) opts, args = Yawpa.parse(params, options)
opts[:opt].should eq('val') expect(opts[:opt]).to eq('val')
args.should eq(['arg']) expect(args).to eq(['arg'])
end end
it "returns an option's values when nargs = 2" do it "returns an option's values when nargs = 2" do
@ -46,8 +46,8 @@ describe Yawpa do
} }
params = ['--opt', 'val1', 'val2'] params = ['--opt', 'val1', 'val2']
opts, args = Yawpa.parse(params, options) opts, args = Yawpa.parse(params, options)
opts[:opt].should eq(['val1', 'val2']) expect(opts[:opt]).to eq(['val1', 'val2'])
args.should be_empty expect(args).to be_empty
end end
it "raises an exception when not enough arguments for an option are given" do it "raises an exception when not enough arguments for an option are given" do
@ -64,8 +64,8 @@ describe Yawpa do
} }
params = ['--opt=thevalue', 'arg'] params = ['--opt=thevalue', 'arg']
opts, args = Yawpa.parse(params, options) opts, args = Yawpa.parse(params, options)
opts[:opt].should eq('thevalue') expect(opts[:opt]).to eq('thevalue')
args.should eq(['arg']) expect(args).to eq(['arg'])
end end
it "uses --opt=val for the first option argument when nargs > 1" do it "uses --opt=val for the first option argument when nargs > 1" do
@ -74,8 +74,8 @@ describe Yawpa do
} }
params = ['--opt=val1', 'val2', 'arg'] params = ['--opt=val1', 'val2', 'arg']
opts, args = Yawpa.parse(params, options) opts, args = Yawpa.parse(params, options)
opts[:opt].should eq(['val1', 'val2']) expect(opts[:opt]).to eq(['val1', 'val2'])
args.should eq(['arg']) expect(args).to eq(['arg'])
end end
it "returns the last set value when an option is passed twice" do it "returns the last set value when an option is passed twice" do
@ -84,8 +84,8 @@ describe Yawpa do
} }
params = ['--opt', 'val1', 'arg1', '--opt', 'val2', 'arg2'] params = ['--opt', 'val1', 'arg1', '--opt', 'val2', 'arg2']
opts, args = Yawpa.parse(params, options) opts, args = Yawpa.parse(params, options)
opts[:opt].should eq('val2') expect(opts[:opt]).to eq('val2')
args.should eq(['arg1', 'arg2']) expect(args).to eq(['arg1', 'arg2'])
end end
it "accepts strings as keys for option configuration" do it "accepts strings as keys for option configuration" do
@ -94,8 +94,8 @@ describe Yawpa do
} }
params = ['xxx', '--crazy-option', 'yyy', 'zzz'] params = ['xxx', '--crazy-option', 'yyy', 'zzz']
opts, args = Yawpa.parse(params, options) opts, args = Yawpa.parse(params, options)
opts['crazy-option'].should eq('yyy') expect(opts['crazy-option']).to eq('yyy')
args.should eq(['xxx', 'zzz']) expect(args).to eq(['xxx', 'zzz'])
end end
it "accepts short options corresponding to a long option" do it "accepts short options corresponding to a long option" do
@ -104,8 +104,8 @@ describe Yawpa do
} }
params = ['-o', 'qqq'] params = ['-o', 'qqq']
opts, args = Yawpa.parse(params, options) opts, args = Yawpa.parse(params, options)
opts[:option].should be_true expect(opts[:option]).to be_truthy
args.should eq(['qqq']) expect(args).to eq(['qqq'])
end end
it "returns option argument at next position for a short option" do it "returns option argument at next position for a short option" do
@ -114,8 +114,8 @@ describe Yawpa do
} }
params = ['-o', 'val', 'rrr'] params = ['-o', 'val', 'rrr']
opts, args = Yawpa.parse(params, options) opts, args = Yawpa.parse(params, options)
opts[:option].should eq('val') expect(opts[:option]).to eq('val')
args.should eq(['rrr']) expect(args).to eq(['rrr'])
end end
it "returns option argument immediately following short option" do it "returns option argument immediately following short option" do
@ -124,8 +124,8 @@ describe Yawpa do
} }
params = ['-oval', 'rrr'] params = ['-oval', 'rrr']
opts, args = Yawpa.parse(params, options) opts, args = Yawpa.parse(params, options)
opts[:option].should eq('val') expect(opts[:option]).to eq('val')
args.should eq(['rrr']) expect(args).to eq(['rrr'])
end end
it "handles globbed-together short options" do it "handles globbed-together short options" do
@ -137,11 +137,11 @@ describe Yawpa do
} }
params = ['-abc', 'xyz'] params = ['-abc', 'xyz']
opts, args = Yawpa.parse(params, options) opts, args = Yawpa.parse(params, options)
opts[:a].should be_true expect(opts[:a]).to be_truthy
opts[:b].should be_true expect(opts[:b]).to be_truthy
opts[:c].should be_true expect(opts[:c]).to be_truthy
opts[:d].should be_nil expect(opts[:d]).to be_nil
args.should eq(['xyz']) expect(args).to eq(['xyz'])
end end
it "handles globbed-together short options with values following" do it "handles globbed-together short options with values following" do
@ -153,11 +153,11 @@ describe Yawpa do
} }
params = ['-abcfoo', 'bar'] params = ['-abcfoo', 'bar']
opts, args = Yawpa.parse(params, options) opts, args = Yawpa.parse(params, options)
opts[:a].should be_true expect(opts[:a]).to be_truthy
opts[:b].should be_true expect(opts[:b]).to be_truthy
opts[:c].should eq('foo') expect(opts[:c]).to eq('foo')
opts[:d].should be_nil expect(opts[:d]).to be_nil
args.should eq(['bar']) expect(args).to eq(['bar'])
end end
it "handles globbed-together short options with multiple values following" do it "handles globbed-together short options with multiple values following" do
@ -169,11 +169,11 @@ describe Yawpa do
} }
params = ['-abcfoo', 'bar', 'baz'] params = ['-abcfoo', 'bar', 'baz']
opts, args = Yawpa.parse(params, options) opts, args = Yawpa.parse(params, options)
opts[:a].should be_true expect(opts[:a]).to be_truthy
opts[:b].should be_true expect(opts[:b]).to be_truthy
opts[:c].should eq(['foo', 'bar', 'baz']) expect(opts[:c]).to eq(['foo', 'bar', 'baz'])
opts[:d].should be_nil expect(opts[:d]).to be_nil
args.should be_empty expect(args).to be_empty
end end
it "raises an error on an unknown short option" do it "raises an error on an unknown short option" do
@ -198,8 +198,8 @@ describe Yawpa do
} }
params = ['--option', 'VALUE', '-o', 'NEW_VALUE'] params = ['--option', 'VALUE', '-o', 'NEW_VALUE']
opts, args = Yawpa.parse(params, options) opts, args = Yawpa.parse(params, options)
opts[:option].should eq('NEW_VALUE') expect(opts[:option]).to eq('NEW_VALUE')
args.should be_empty expect(args).to be_empty
end end
it "ignores options after arguments in posix_order mode" do it "ignores options after arguments in posix_order mode" do
@ -209,9 +209,9 @@ describe Yawpa do
} }
params = ['--one', 'arg', '--two'] params = ['--one', 'arg', '--two']
opts, args = Yawpa.parse(params, options, posix_order: true) opts, args = Yawpa.parse(params, options, posix_order: true)
opts[:one].should be_true expect(opts[:one]).to be_truthy
opts[:two].should be_false expect(opts[:two]).to be_falsey
args.should eq(['arg', '--two']) expect(args).to eq(['arg', '--two'])
end end
end end
end end