Skip to content

Instantly share code, notes, and snippets.

@erubboli
Created April 29, 2011 16:36
Show Gist options
  • Save erubboli/948593 to your computer and use it in GitHub Desktop.
Save erubboli/948593 to your computer and use it in GitHub Desktop.
failing_spec.rb
require 'spec_helper'
describe 'rspec' do
it { true.should be_true }
it "mock methods" do
my_obj = double('obj', {:my_method => 2})
my_obj.send('my_method').should == 2
end
it "mock hyphen methods" do
my_obj = double('obj', {:'method-with-hyphen'=>2})
my_obj.send('method-with-hyphen').should == 2
end
end
@erubboli
Copy link
Author

  1. rspec mock hyphen methods
    Failure/Error: my_obj = double('obj', {:'method-with-hyphen'=>2})
    /Users/erubboli/.rvm/gems/ruby-1.9.2-p180@upage/gems/rspec-mocks-2.6.0.rc2/lib/rspec/mocks/method_double.rb:78: syntax error, unexpected '-', expecting ';' or '\n'
    def method-with-hyphen(*args, &block)
    ^
    /Users/erubboli/.rvm/gems/ruby-1.9.2-p180@upage/gems/rspec-mocks-2.6.0.rc2/lib/rspec/mocks/method_double.rb:80: syntax error, unexpected keyword_end, expecting $end

    ./spec/lib/t.rb:11:in `block (2 levels) in <top (required)>'

@erubboli
Copy link
Author

fixed stubbing 'method_missing'

my_obj = double('obj', {"method_missing"=>2})

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment