Permalink
Browse files

a little more refactoring

  • Loading branch information...
dchelimsky committed Apr 16, 2012
1 parent 381c7c8 commit 764680c8d306d0070b94f542405cb6cadda02207
Showing with 4 additions and 8 deletions.
  1. +4 −8 lib/rspec/mocks/message_expectation.rb
@@ -136,8 +136,7 @@ def and_raise(exception=Exception)
# car.stub(:go).and_throw(:out_of_gas)
# car.stub(:go).and_throw(:out_of_gas, :level => 0.1)
def and_throw(symbol, object = nil)
- @args_to_throw << symbol
- @args_to_throw << object if object
+ @args_to_throw = [symbol, object].compact
end
# Tells the object to yield one or more args to a block when the message
@@ -153,9 +152,7 @@ def and_yield(*args, &block)
end
if block
- @eval_context = Object.new
- @eval_context.extend RSpec::Mocks::InstanceExec
- yield @eval_context
+ yield @eval_context = Object.new.extend(RSpec::Mocks::InstanceExec)
end
@args_to_yield << args
@@ -164,7 +161,7 @@ def and_yield(*args, &block)
# @private
def matches?(message, *args)
- @message == message and @argument_expectation.args_match?(*args)
+ @message == message && @argument_expectation.args_match?(*args)
end
# @private
@@ -216,8 +213,7 @@ def raise_exception
# @private
def called_max_times?
- @expected_received_count != :any && @expected_received_count > 0 &&
- @actual_received_count >= @expected_received_count
+ @expected_received_count != :any && @expected_received_count > 0 && @actual_received_count >= @expected_received_count
end
# @private

0 comments on commit 764680c

Please sign in to comment.