Skip to content

Instantly share code, notes, and snippets.

@lachie
Created February 18, 2015 05:41
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 lachie/92e4ef09d32ef0d2cfe3 to your computer and use it in GitHub Desktop.
Save lachie/92e4ef09d32ef0d2cfe3 to your computer and use it in GitHub Desktop.
Hm, I thought this would work
source 'https://rubygems.org'
gem 'rspec', '~> 3.1.0'
> bundle install
> bundle exec rspec spec.rb
doing the thing thing
F
Failures:
1) Hello does the verification
Failure/Error: expect(hello).to receive(:do_the_thing).with('thing')
(Double "Hello").do_the_thing("thing")
expected: 1 time with arguments: ("thing")
received: 0 times
# ./spec.rb:17:in `block (2 levels) in <top (required)>'
Finished in 0.00385 seconds (files took 0.05977 seconds to load)
1 example, 1 failure
Failed examples:
rspec ./spec.rb:15 # Hello does the verification
require 'rubygems'
require 'bundler/setup'
require 'rspec'
require 'rspec/mocks'
module Hello
extend self
def do_the_thing(arg1)
puts "doing the thing #{arg1}"
end
end
describe 'Hello' do
it "does the verification" do
hello = class_double('Hello')
expect(hello).to receive(:do_the_thing).with('thing')
Hello.do_the_thing('thing')
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment