Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

update mocha dependency #13

Merged
merged 1 commit into from

2 participants

@grosser

0.12.3 no changes in mock test, only 1 in method_missing -> build still green :)

@jferris jferris merged commit 54aa1b7 into thoughtbot:master
@jferris
Owner

Thanks. I pushed this as 1.2.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Oct 10, 2012
  1. @grosser

    update mocha dependency

    grosser authored
This page is out of date. Refresh to see the latest.
Showing with 20 additions and 13 deletions.
  1. +1 −1  bourne.gemspec
  2. +6 −3 lib/bourne/mock.rb
  3. +13 −9 test/unit/mock_test.rb
View
2  bourne.gemspec
@@ -20,7 +20,7 @@ Gem::Specification.new do |s|
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
s.require_paths = ["lib"]
- s.add_dependency('mocha', '0.11.4') # when updating this, make sure to update mock.rb and it's tests by copying changes from mocha
+ s.add_dependency('mocha', '0.12.3') # follow instructions in mock.rb to update
s.add_development_dependency('rake')
end
View
9 lib/bourne/mock.rb
@@ -1,10 +1,13 @@
require 'mocha/mock'
require 'bourne/expectation'
+require 'mocha/expectation_error_factory'
module Mocha # :nodoc:
# Overwrites #method_missing on Mocha::Mock
- # - pass arguments to invoke to create Invocation
- # - keep lower else branch
+ # - pass arguments to .invoke() calls to create Invocation
+ # - keep lowest else branch (bourne code)
+ # - update from https://github.com/freerange/mocha/blob/master/lib/mocha/mock.rb#L195
+ # - update test/unit/mock_test.rb
class Mock # :nodoc:
def method_missing(symbol, *arguments, &block)
if @responder and not @responder.respond_to?(symbol)
@@ -17,7 +20,7 @@ def method_missing(symbol, *arguments, &block)
matching_expectation.invoke(arguments, &block) if matching_expectation
message = UnexpectedInvocation.new(self, symbol, *arguments).to_s
message << @mockery.mocha_inspect
- raise ExpectationError.new(message, caller)
+ raise ExpectationErrorFactory.build(message, caller)
else
target = if self.respond_to? :mocha
self.mocha
View
22 test/unit/mock_test.rb
@@ -1,3 +1,7 @@
+# to update:
+# - copy new code from https://raw.github.com/freerange/mocha/master/test/unit/mock_test.rb
+# - keep: require 'bourne/mock'
+# - keep: FakeExpectation test
require File.expand_path('../../test_helper', __FILE__)
require 'bourne/mock'
require 'mocha/expectation_error'
@@ -9,18 +13,18 @@ class MockTest < Test::Unit::TestCase
include Mocha
def test_should_set_single_expectation
- mock = build_mock
- mock.expects(:method1).returns(1)
- assert_nothing_raised(ExpectationError) do
- assert_equal 1, mock.method1
- end
+ mock = build_mock
+ mock.expects(:method1).returns(1)
+ assert_nothing_raised(ExpectationError) do
+ assert_equal 1, mock.method1
+ end
end
def test_should_build_and_store_expectations
- mock = build_mock
- expectation = mock.expects(:method1)
- assert_not_nil expectation
- assert_equal [expectation], mock.__expectations__.to_a
+ mock = build_mock
+ expectation = mock.expects(:method1)
+ assert_not_nil expectation
+ assert_equal [expectation], mock.__expectations__.to_a
end
def test_should_not_stub_everything_by_default
Something went wrong with that request. Please try again.