test/unit/expector_test.rb in hardmock-1.2.0 vs test/unit/expector_test.rb in hardmock-1.2.3
- old
+ new
@@ -1,9 +1,10 @@
require File.expand_path(File.dirname(__FILE__) + "/../test_helper")
-require 'hardmock'
+require 'hardmock/expector'
class ExpectorTest < Test::Unit::TestCase
+ include Hardmock
class MyControl
attr_reader :added
def add_expectation(expectation)
@added ||= []
@@ -17,23 +18,10 @@
@options = options
"dummy expectation"
end
end
- #
- # TESTS
- #
-
- def test_method_missing
- try_it_with 'wonder_bread'
- try_it_with 'whatever'
- end
-
- def test_methods_that_wont_trigger_method_missing
- try_it_with 'instance_eval'
- end
-
def try_it_with(method_name)
mock = Object.new
mock_control = MyControl.new
builder = ExpBuilder.new
@@ -48,7 +36,22 @@
"Wrong expectation added to control"
assert_equal "dummy expectation", output, "Expectation should have been returned"
end
+ #
+ # TESTS
+ #
+ def test_method_missing
+ try_it_with 'wonder_bread'
+ try_it_with 'whatever'
+ end
+ def test_methods_that_wont_trigger_method_missing
+ mock = Object.new
+ mock_control = MyControl.new
+ builder = ExpBuilder.new
+
+ exp = Expector.new(mock, mock_control, builder)
+ assert_equal mock, exp.instance_eval("@mock")
+ end
end