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
remote: https://rubygems.org/
specs:
diff-lcs (1.2.4)
diff-lcs (1.2.5)
json (1.8.1)
rake (10.3.2)
rdoc (4.1.1)
json (~> 1.4)
rspec (2.13.0)
rspec-core (~> 2.13.0)
rspec-expectations (~> 2.13.0)
rspec-mocks (~> 2.13.0)
rspec-core (2.13.1)
rspec-expectations (2.13.0)
diff-lcs (>= 1.1.3, < 2.0)
rspec-mocks (2.13.1)
rspec (3.0.0)
rspec-core (~> 3.0.0)
rspec-expectations (~> 3.0.0)
rspec-mocks (~> 3.0.0)
rspec-core (3.0.2)
rspec-support (~> 3.0.0)
rspec-expectations (3.0.2)
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
ruby

View File

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