Created
June 29, 2015 23:06
-
-
Save JunichiIto/e796cc34fcf5522f1912 to your computer and use it in GitHub Desktop.
Sample spec for https://twitter.com/tagomoris/status/615481658045673472
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
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