Skip to content

Instantly share code, notes, and snippets.

@jgraichen
Created Dec 28, 2013
Embed
What would you like to do?
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