Permalink
Browse files

Merge pull request #28 from xaviershay/fix_use_of_should

Make things work for projects that disable the `should` syntax.
  • Loading branch information...
2 parents 308ef46 + 2900178 commit 1edd05f637689e9dae4b1820e8fc65c47749cf23 @xaviershay committed Jan 6, 2013
Showing with 23 additions and 1 deletion.
  1. +5 −1 lib/rspec/fire.rb
  2. +18 −0 spec/fire_double_spec.rb
View
6 lib/rspec/fire.rb
@@ -159,9 +159,13 @@ def with(*args, &block)
protected
+ def expect(value)
+ ::RSpec::Expectations::ExpectationTarget.new(value)
+ end
+
def ensure_arity(actual)
@double.with_doubled_class do |klass|
- klass.__send__(@method_finder, @sym).should support_arity(actual)
+ expect(klass.__send__(@method_finder, @sym)).to support_arity(actual)
end
end
View
18 spec/fire_double_spec.rb
@@ -203,6 +203,24 @@ def fail_for_arguments(expected, actual)
double.stub(:foo).and_return("bar")
double.foo.should eq("bar")
end
+
+ def with_isolated_syntax_change
+ original_syntax = ::RSpec::Matchers.configuration.syntax
+ yield
+ ensure
+ ::RSpec::Matchers.configuration.syntax = original_syntax
+ end
+
+ it 'works when the `should` syntax is disabled' do
+ with_isolated_syntax_change do
+ ::RSpec::Matchers.configuration.syntax = :expect
+ expect(5).not_to respond_to(:should, :should_not)
+
+ double = fire_double("TestObject")
+ double.should_receive(:defined_method_one_arg).with(8)
+ double.defined_method_one_arg(8)
+ end
+ end
end
describe '#fire_class_double' do

0 comments on commit 1edd05f

Please sign in to comment.