Skip to content

Instantly share code, notes, and snippets.

@JunichiIto
Created November 9, 2018 04:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JunichiIto/2de0fa87a0cf26ca918a6a628e9da83c to your computer and use it in GitHub Desktop.
Save JunichiIto/2de0fa87a0cf26ca918a6a628e9da83c to your computer and use it in GitHub Desktop.
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