Created
December 28, 2013 14:05
-
-
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`.
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
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