spec/rspec/mocks/matchers/receive_spec.rb in rspec-mocks-3.0.0.beta1 vs spec/rspec/mocks/matchers/receive_spec.rb in rspec-mocks-3.0.0.beta2
- old
+ new
@@ -3,14 +3,10 @@
module RSpec
module Mocks
describe Matchers::Receive do
include_context "with syntax", :expect
- def verify_all
- ::RSpec::Mocks.space.verify_all
- end
-
describe "expectations/allowances on any instance recorders" do
include_context "with syntax", [:expect, :should]
it "warns about allow(Klass.any_instance).to receive..." do
expect(RSpec).to receive(:warning).with(/allow.*any_instance.*is probably not what you meant.*allow_any_instance_of.*instead/)
@@ -91,10 +87,28 @@
wrapped.to receive("foo").with(2) { :b }
expect(receiver.foo(1)).to eq(:a)
expect(receiver.foo(2)).to eq(:b)
end
+
+ it 'allows do...end blocks to be passed to the fluent interface methods without getting a warning' do
+ expect(RSpec).not_to receive(:warning)
+
+ wrapped.to receive(:foo).with(1) do
+ :a
+ end
+
+ expect(receiver.foo(1)).to eq(:a)
+ end
+
+ it 'makes { } blocks trump do...end blocks when passed to a fluent interface method' do
+ wrapped.to receive(:foo).with(1) { :curly } do
+ :do_end
+ end
+
+ expect(receiver.foo(1)).to eq(:curly)
+ end
end
shared_examples_for "an expect syntax allowance" do |*options|
it_behaves_like "a receive matcher", *options
@@ -205,11 +219,11 @@
let(:object) { klass.new :bar }
it "removes the method double" do
target.to receive(:foo).and_return(:baz)
expect {
- ::RSpec::Mocks.space.verify_all
+ verify_all
}.to change { object.foo }.from(:baz).to(:bar)
end
end
describe "allow(...).to receive" do
@@ -400,6 +414,5 @@
end
end
end
end
end
-