Created
September 19, 2012 02:31
-
-
Save moro/3747312 to your computer and use it in GitHub Desktop.
unit_test_spec.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class A | |
def foo(num) | |
%w[one two three][num - 1] | |
end | |
end | |
describe A do | |
describe "#foo" do | |
RSpec::Matchers.define :do_foo do |args| | |
match do |instance| | |
instance.foo(args) == @expectation | |
end | |
chain :to do |expectation| | |
@expectation = expectation | |
end | |
end | |
subject(:instance) { A.new } | |
it { should do_foo(1).to('one') } | |
it { should do_foo(2).to('two') } | |
it { should do_foo(3).to('three') } | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment