Skip to content

Instantly share code, notes, and snippets.

@JunichiIto
Created June 29, 2015 23:06
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/e796cc34fcf5522f1912 to your computer and use it in GitHub Desktop.
Save JunichiIto/e796cc34fcf5522f1912 to your computer and use it in GitHub Desktop.
require 'spec_helper'
class Foo
def self.bar(*args)
raise 'Should be stubbed.'
end
end
describe 'Large args' do
example do
# RSpec 3.x
# https://relishapp.com/rspec/rspec-mocks/v/3-3/docs/setting-constraints/matching-arguments
# expect(Foo).to receive(:bar) do |*args|
# array = args[0]
# expect(array).to eq [1, 2, 3]
# hash = args[1]
# expect(hash).to eq a: 1, b: 2, c: 3
# end
# RSpec 2.x
# https://relishapp.com/rspec/rspec-mocks/v/2-9/docs/message-expectations
Foo.should_receive(:bar) do |*args|
array = args[0]
expect(array).to eq [1, 2, 3]
hash = args[1]
expect(hash).to eq a: 1, b: 2, c: 3
end
Foo.bar([1, 2, 3], {a: 1, b: 2, c: 3})
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment