Created
November 9, 2018 04:43
-
-
Save JunichiIto/2de0fa87a0cf26ca918a6a628e9da83c to your computer and use it in GitHub Desktop.
Sample spec for https://twitter.com/miyohide/status/1060727244719501312
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
RSpec.describe do | |
example do | |
dbl = double | |
allow(dbl).to receive(:x) do |*args| | |
case args.size | |
when 1 then 'foo' | |
when 2 then 'bar' | |
end | |
end | |
expect(dbl.x(10)).to eq 'foo' | |
expect(dbl.x(10, 20)).to eq 'bar' | |
end | |
example do | |
dbl = double | |
allow(dbl).to receive(:x) do |arg| | |
case arg | |
when 1 then 'foo' | |
when 2 then 'bar' | |
end | |
end | |
expect(dbl.x(1)).to eq 'foo' | |
expect(dbl.x(2)).to eq 'bar' | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment