Skip to content

Instantly share code, notes, and snippets.

@jgraichen
Created December 28, 2013 14:05
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 jgraichen/8159849 to your computer and use it in GitHub Desktop.
Save jgraichen/8159849 to your computer and use it in GitHub Desktop.
Run with RSpec mocks on Ruby 2.1 results in segfault. Run with `rspec test.rb`.
module A
def valid?(context)
true
end
end
module B
def valid?(*args)
super
end
end
class C
include A
include B
def save!
return false unless valid? :create
true
end
end
describe C do
let(:model) { C.new }
describe 'save!' do
subject { -> { model.save! } }
it 'should validate with `create` context' do
expect(model).to receive(:valid?).with(:create).and_call_original
subject.call
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment