Skip to content

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Experiment using two different mocking frameworks
require 'flexmock/dual'
RSpec.configure do |config|
config.mock_with FlexMock.flexmock_and(:rspec)
end
describe "Dual Mocking" do
before do
@rm = mock("with rspec")
@rm.should_receive(:foo)
@fm = flexmock("with flexmock")
@fm.should_receive(:bar).once
end
it "satisfies both" do
@rm.foo
@fm.bar
end
# The following three spec will fail,
# due to one or more of the mocking
# frameworks complaining about expectations.
it "only rspec is happy" do
@rm.foo
end
it "only flexmock is happy" do
@fm.bar
end
it "neither are happy" do
end
end
require 'flexmock/rspec'
class FlexMock
module Dual
module DummyAdaptor
def setup_mocks_for_rspec
end
def verify_mocks_for_rspec
end
def teardown_mocks_for_rspec
end
end
module DualMocksAdaptor
include DummyAdaptor
include FlexMock::MockContainer
def self.framework_name; :dual_mocks end
include FlexMock::MockContainer
def setup_mocks_for_rspec
super
end
def verify_mocks_for_rspec
flexmock_verify
super
end
def teardown_mocks_for_rspec
flexmock_close
super
end
end
end
def self.flexmock_and(other)
require "rspec/core/mocking/with_#{other}"
FlexMock::Dual::DualMocksAdaptor.send(:include, RSpec::Core::MockFrameworkAdapter)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.