summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorLuke Kanies <luke@madstop.com>2008-02-12 22:11:30 -0600
committerLuke Kanies <luke@madstop.com>2008-02-12 22:11:30 -0600
commit1b90f7f8b523b32439e17f27b9f924bea8f1e74b (patch)
treecb4c05581b378b9358191cf7908acf1dc451757a /test
parentbcb9b564281003e22d72752d84fa9dc9c8c7107b (diff)
downloadpuppet-1b90f7f8b523b32439e17f27b9f924bea8f1e74b.tar.gz
puppet-1b90f7f8b523b32439e17f27b9f924bea8f1e74b.tar.xz
puppet-1b90f7f8b523b32439e17f27b9f924bea8f1e74b.zip
Trying to upgrade rspec, but not having much luck.
Diffstat (limited to 'test')
-rw-r--r--test/lib/mocha.rb19
-rw-r--r--test/lib/mocha/any_instance_method.rb35
-rw-r--r--test/lib/mocha/auto_verify.rb113
-rw-r--r--test/lib/mocha/central.rb35
-rw-r--r--test/lib/mocha/class_method.rb62
-rw-r--r--test/lib/mocha/deprecation.rb22
-rw-r--r--test/lib/mocha/exception_raiser.rb17
-rw-r--r--test/lib/mocha/expectation.rb378
-rw-r--r--test/lib/mocha/expectation_error.rb6
-rw-r--r--test/lib/mocha/infinite_range.rb25
-rw-r--r--test/lib/mocha/inspect.rb39
-rw-r--r--test/lib/mocha/instance_method.rb8
-rw-r--r--test/lib/mocha/is_a.rb9
-rw-r--r--test/lib/mocha/metaclass.rb7
-rw-r--r--test/lib/mocha/missing_expectation.rb27
-rw-r--r--test/lib/mocha/mock.rb207
-rw-r--r--test/lib/mocha/multiple_yields.rb20
-rw-r--r--test/lib/mocha/no_yields.rb11
-rw-r--r--test/lib/mocha/object.rb110
-rw-r--r--test/lib/mocha/parameter_matchers.rb9
-rw-r--r--test/lib/mocha/parameter_matchers/all_of.rb39
-rw-r--r--test/lib/mocha/parameter_matchers/any_of.rb44
-rw-r--r--test/lib/mocha/parameter_matchers/anything.rb30
-rw-r--r--test/lib/mocha/parameter_matchers/has_entry.rb39
-rw-r--r--test/lib/mocha/parameter_matchers/has_key.rb39
-rw-r--r--test/lib/mocha/parameter_matchers/has_value.rb39
-rw-r--r--test/lib/mocha/parameter_matchers/includes.rb37
-rw-r--r--test/lib/mocha/pretty_parameters.rb28
-rw-r--r--test/lib/mocha/return_values.rb31
-rw-r--r--test/lib/mocha/setup_and_teardown.rb23
-rw-r--r--test/lib/mocha/single_return_value.rb24
-rw-r--r--test/lib/mocha/single_yield.rb18
-rw-r--r--test/lib/mocha/standalone.rb32
-rw-r--r--test/lib/mocha/stub.rb18
-rw-r--r--test/lib/mocha/test_case_adapter.rb49
-rw-r--r--test/lib/mocha/yield_parameters.rb31
36 files changed, 0 insertions, 1680 deletions
diff --git a/test/lib/mocha.rb b/test/lib/mocha.rb
deleted file mode 100644
index 58571156a..000000000
--- a/test/lib/mocha.rb
+++ /dev/null
@@ -1,19 +0,0 @@
-require 'mocha_standalone'
-require 'mocha/test_case_adapter'
-
-require 'test/unit/testcase'
-
-module Test
-
- module Unit
-
- class TestCase
-
- include Mocha::Standalone
- include Mocha::TestCaseAdapter
-
- end
-
- end
-
-end \ No newline at end of file
diff --git a/test/lib/mocha/any_instance_method.rb b/test/lib/mocha/any_instance_method.rb
deleted file mode 100644
index 4d55293b9..000000000
--- a/test/lib/mocha/any_instance_method.rb
+++ /dev/null
@@ -1,35 +0,0 @@
-require 'mocha/class_method'
-
-module Mocha
-
- class AnyInstanceMethod < ClassMethod
-
- def unstub
- remove_new_method
- restore_original_method
- stubbee.any_instance.reset_mocha
- end
-
- def mock
- stubbee.any_instance.mocha
- end
-
- def hide_original_method
- stubbee.class_eval "alias_method :#{hidden_method}, :#{method}" if stubbee.method_defined?(method)
- end
-
- def define_new_method
- stubbee.class_eval "def #{method}(*args, &block); self.class.any_instance.mocha.method_missing(:#{method}, *args, &block); end"
- end
-
- def remove_new_method
- stubbee.class_eval "remove_method :#{method}"
- end
-
- def restore_original_method
- stubbee.class_eval "alias_method :#{method}, :#{hidden_method}; remove_method :#{hidden_method}" if stubbee.method_defined?(hidden_method)
- end
-
- end
-
-end \ No newline at end of file
diff --git a/test/lib/mocha/auto_verify.rb b/test/lib/mocha/auto_verify.rb
deleted file mode 100644
index dce877bde..000000000
--- a/test/lib/mocha/auto_verify.rb
+++ /dev/null
@@ -1,113 +0,0 @@
-require 'mocha/mock'
-
-module Mocha # :nodoc:
-
- # Methods added to TestCase allowing creation of traditional mock objects.
- #
- # Mocks created this way will have their expectations automatically verified at the end of the test.
- #
- # See Mock for methods on mock objects.
- module AutoVerify
-
- def mocks # :nodoc:
- @mocks ||= []
- end
-
- def reset_mocks # :nodoc:
- @mocks = nil
- end
-
- # :call-seq: mock(name) -> mock object
- # mock(expected_methods = {}) -> mock object
- # mock(name, expected_methods = {}) -> mock object
- #
- # Creates a mock object.
- #
- # +name+ is a +String+ identifier for the mock object.
- #
- # +expected_methods+ is a +Hash+ with expected method name symbols as keys and corresponding return values as values.
- #
- # Note that (contrary to expectations set up by #stub) these expectations <b>must</b> be fulfilled during the test.
- # def test_product
- # product = mock('ipod_product', :manufacturer => 'ipod', :price => 100)
- # assert_equal 'ipod', product.manufacturer
- # assert_equal 100, product.price
- # # an error will be raised unless both Product#manufacturer and Product#price have been called
- # end
- def mock(*args)
- name, expectations = name_and_expectations_from_args(args)
- build_mock_with_expectations(:expects, expectations, name)
- end
-
- # :call-seq: stub(name) -> mock object
- # stub(stubbed_methods = {}) -> mock object
- # stub(name, stubbed_methods = {}) -> mock object
- #
- # Creates a mock object.
- #
- # +name+ is a +String+ identifier for the mock object.
- #
- # +stubbed_methods+ is a +Hash+ with stubbed method name symbols as keys and corresponding return values as values.
- #
- # Note that (contrary to expectations set up by #mock) these expectations <b>need not</b> be fulfilled during the test.
- # def test_product
- # product = stub('ipod_product', :manufacturer => 'ipod', :price => 100)
- # assert_equal 'ipod', product.manufacturer
- # assert_equal 100, product.price
- # # an error will not be raised even if Product#manufacturer and Product#price have not been called
- # end
- def stub(*args)
- name, expectations = name_and_expectations_from_args(args)
- build_mock_with_expectations(:stubs, expectations, name)
- end
-
- # :call-seq: stub_everything(name) -> mock object
- # stub_everything(stubbed_methods = {}) -> mock object
- # stub_everything(name, stubbed_methods = {}) -> mock object
- #
- # Creates a mock object that accepts calls to any method.
- #
- # By default it will return +nil+ for any method call.
- #
- # +name+ and +stubbed_methods+ work in the same way as for #stub.
- # def test_product
- # product = stub_everything('ipod_product', :price => 100)
- # assert_nil product.manufacturer
- # assert_nil product.any_old_method
- # assert_equal 100, product.price
- # end
- def stub_everything(*args)
- name, expectations = name_and_expectations_from_args(args)
- build_mock_with_expectations(:stub_everything, expectations, name)
- end
-
- def verify_mocks # :nodoc:
- mocks.each { |mock| mock.verify { yield if block_given? } }
- end
-
- def teardown_mocks # :nodoc:
- reset_mocks
- end
-
- def build_mock_with_expectations(expectation_type = :expects, expectations = {}, name = nil) # :nodoc:
- stub_everything = (expectation_type == :stub_everything)
- expectation_type = :stubs if expectation_type == :stub_everything
- mock = Mocha::Mock.new(stub_everything, name)
- expectations.each do |method, result|
- mock.__send__(expectation_type, method).returns(result)
- end
- mocks << mock
- mock
- end
-
- private
-
- def name_and_expectations_from_args(args) # :nodoc:
- name = args.first.is_a?(String) ? args.delete_at(0) : nil
- expectations = args.first || {}
- [name, expectations]
- end
-
- end
-
-end \ No newline at end of file
diff --git a/test/lib/mocha/central.rb b/test/lib/mocha/central.rb
deleted file mode 100644
index 3dde7350f..000000000
--- a/test/lib/mocha/central.rb
+++ /dev/null
@@ -1,35 +0,0 @@
-module Mocha
-
- class Central
-
- attr_accessor :stubba_methods
-
- def initialize
- self.stubba_methods = []
- end
-
- def stub(method)
- unless stubba_methods.include?(method)
- method.stub
- stubba_methods.push method
- end
- end
-
- def verify_all(&block)
- unique_mocks.each { |mock| mock.verify(&block) }
- end
-
- def unique_mocks
- stubba_methods.inject({}) { |mocks, method| mocks[method.mock.__id__] = method.mock; mocks }.values
- end
-
- def unstub_all
- while stubba_methods.size > 0
- method = stubba_methods.pop
- method.unstub
- end
- end
-
- end
-
-end \ No newline at end of file
diff --git a/test/lib/mocha/class_method.rb b/test/lib/mocha/class_method.rb
deleted file mode 100644
index 915fe71b5..000000000
--- a/test/lib/mocha/class_method.rb
+++ /dev/null
@@ -1,62 +0,0 @@
-require 'mocha/metaclass'
-
-module Mocha
-
- class ClassMethod
-
- attr_reader :stubbee, :method
-
- def initialize(stubbee, method)
- @stubbee, @method = stubbee, method
- end
-
- def stub
- hide_original_method
- define_new_method
- end
-
- def unstub
- remove_new_method
- restore_original_method
- stubbee.reset_mocha
- end
-
- def mock
- stubbee.mocha
- end
-
- def hide_original_method
- stubbee.__metaclass__.class_eval "alias_method :#{hidden_method}, :#{method}" if stubbee.__metaclass__.method_defined?(method)
- end
-
- def define_new_method
- stubbee.__metaclass__.class_eval "def #{method}(*args, &block); mocha.method_missing(:#{method}, *args, &block); end"
- end
-
- def remove_new_method
- stubbee.__metaclass__.class_eval "remove_method :#{method}"
- end
-
- def restore_original_method
- stubbee.__metaclass__.class_eval "alias_method :#{method}, :#{hidden_method}; remove_method :#{hidden_method}" if stubbee.__metaclass__.method_defined?(hidden_method)
- end
-
- def hidden_method
- method_name = method.to_s.gsub(/\W/) {|s| "_substituted_character_#{s[0]}_" }
- "__stubba__#{method_name}__stubba__"
- end
-
- def eql?(other)
- return false unless (other.class == self.class)
- (stubbee == other.stubbee) and (method == other.method)
- end
-
- alias_method :==, :eql?
-
- def to_s
- "#{stubbee}.#{method}"
- end
-
- end
-
-end \ No newline at end of file
diff --git a/test/lib/mocha/deprecation.rb b/test/lib/mocha/deprecation.rb
deleted file mode 100644
index 7448510ec..000000000
--- a/test/lib/mocha/deprecation.rb
+++ /dev/null
@@ -1,22 +0,0 @@
-module Mocha
-
- class Deprecation
-
- class << self
-
- attr_accessor :mode, :messages
-
- def warning(message)
- @messages << message
- $stderr.puts "Mocha deprecation warning: #{message}" unless mode == :disabled
- $stderr.puts caller.join("\n ") if mode == :debug
- end
-
- end
-
- self.mode = :enabled
- self.messages = []
-
- end
-
-end \ No newline at end of file
diff --git a/test/lib/mocha/exception_raiser.rb b/test/lib/mocha/exception_raiser.rb
deleted file mode 100644
index 266e209a2..000000000
--- a/test/lib/mocha/exception_raiser.rb
+++ /dev/null
@@ -1,17 +0,0 @@
-module Mocha # :nodoc:
-
- class ExceptionRaiser # :nodoc:
-
- def initialize(exception, message)
- @exception, @message = exception, message
- end
-
- def evaluate
- raise @exception, @exception.to_s if @exception == Interrupt
- raise @exception, @message if @message
- raise @exception
- end
-
- end
-
-end
diff --git a/test/lib/mocha/expectation.rb b/test/lib/mocha/expectation.rb
deleted file mode 100644
index 49b39bea9..000000000
--- a/test/lib/mocha/expectation.rb
+++ /dev/null
@@ -1,378 +0,0 @@
-require 'mocha/infinite_range'
-require 'mocha/pretty_parameters'
-require 'mocha/expectation_error'
-require 'mocha/return_values'
-require 'mocha/exception_raiser'
-require 'mocha/yield_parameters'
-require 'mocha/is_a'
-
-module Mocha # :nodoc:
-
- # Methods on expectations returned from Mock#expects, Mock#stubs, Object#expects and Object#stubs.
- class Expectation
-
- # :stopdoc:
-
- class AlwaysEqual
- def ==(other)
- true
- end
- end
-
- attr_reader :method_name, :backtrace
-
- def initialize(mock, method_name, backtrace = nil)
- @mock, @method_name = mock, method_name
- @expected_count = 1
- @parameters, @parameter_block = AlwaysEqual.new, nil
- @invoked_count, @return_values = 0, ReturnValues.new
- @backtrace = backtrace || caller
- @yield_parameters = YieldParameters.new
- end
-
- def match?(method_name, *arguments)
- return false unless @method_name == method_name
- if @parameter_block then
- return false unless @parameter_block.call(*arguments)
- else
- return false unless (@parameters == arguments)
- end
- if @expected_count.is_a?(Range) then
- return false unless @invoked_count < @expected_count.last
- else
- return false unless @invoked_count < @expected_count
- end
- return true
- end
-
- # :startdoc:
-
- # :call-seq: times(range) -> expectation
- #
- # Modifies expectation so that the number of calls to the expected method must be within a specific +range+.
- #
- # +range+ can be specified as an exact integer or as a range of integers
- # object = mock()
- # object.expects(:expected_method).times(3)
- # 3.times { object.expected_method }
- # # => verify succeeds
- #
- # object = mock()
- # object.expects(:expected_method).times(3)
- # 2.times { object.expected_method }
- # # => verify fails
- #
- # object = mock()
- # object.expects(:expected_method).times(2..4)
- # 3.times { object.expected_method }
- # # => verify succeeds
- #
- # object = mock()
- # object.expects(:expected_method).times(2..4)
- # object.expected_method
- # # => verify fails
- def times(range)
- @expected_count = range
- self
- end
-
- # :call-seq: once() -> expectation
- #
- # Modifies expectation so that the expected method must be called exactly once.
- # Note that this is the default behaviour for an expectation, but you may wish to use it for clarity/emphasis.
- # object = mock()
- # object.expects(:expected_method).once
- # object.expected_method
- # # => verify succeeds
- #
- # object = mock()
- # object.expects(:expected_method).once
- # object.expected_method
- # object.expected_method
- # # => verify fails
- #
- # object = mock()
- # object.expects(:expected_method).once
- # # => verify fails
- def once()
- times(1)
- self
- end
-
- # :call-seq: never() -> expectation
- #
- # Modifies expectation so that the expected method must never be called.
- # object = mock()
- # object.expects(:expected_method).never
- # object.expected_method
- # # => verify fails
- #
- # object = mock()
- # object.expects(:expected_method).never
- # object.expected_method
- # # => verify succeeds
- def never
- times(0)
- self
- end
-
- # :call-seq: at_least(minimum_number_of_times) -> expectation
- #
- # Modifies expectation so that the expected method must be called at least a +minimum_number_of_times+.
- # object = mock()
- # object.expects(:expected_method).at_least(2)
- # 3.times { object.expected_method }
- # # => verify succeeds
- #
- # object = mock()
- # object.expects(:expected_method).at_least(2)
- # object.expected_method
- # # => verify fails
- def at_least(minimum_number_of_times)
- times(Range.at_least(minimum_number_of_times))
- self
- end
-
- # :call-seq: at_least_once() -> expectation
- #
- # Modifies expectation so that the expected method must be called at least once.
- # object = mock()
- # object.expects(:expected_method).at_least_once
- # object.expected_method
- # # => verify succeeds
- #
- # object = mock()
- # object.expects(:expected_method).at_least_once
- # # => verify fails
- def at_least_once()
- at_least(1)
- self
- end
-
- # :call-seq: at_most(maximum_number_of_times) -> expectation
- #
- # Modifies expectation so that the expected method must be called at most a +maximum_number_of_times+.
- # object = mock()
- # object.expects(:expected_method).at_most(2)
- # 2.times { object.expected_method }
- # # => verify succeeds
- #
- # object = mock()
- # object.expects(:expected_method).at_most(2)
- # 3.times { object.expected_method }
- # # => verify fails
- def at_most(maximum_number_of_times)
- times(Range.at_most(maximum_number_of_times))
- self
- end
-
- # :call-seq: at_most_once() -> expectation
- #
- # Modifies expectation so that the expected method must be called at most once.
- # object = mock()
- # object.expects(:expected_method).at_most_once
- # object.expected_method
- # # => verify succeeds
- #
- # object = mock()
- # object.expects(:expected_method).at_most_once
- # 2.times { object.expected_method }
- # # => verify fails
- def at_most_once()
- at_most(1)
- self
- end
-
- # :call-seq: with(*arguments, &parameter_block) -> expectation
- #
- # Modifies expectation so that the expected method must be called with specified +arguments+.
- # object = mock()
- # object.expects(:expected_method).with(:param1, :param2)
- # object.expected_method(:param1, :param2)
- # # => verify succeeds
- #
- # object = mock()
- # object.expects(:expected_method).with(:param1, :param2)
- # object.expected_method(:param3)
- # # => verify fails
- # May be used with parameter matchers in Mocha::ParameterMatchers.
- #
- # If a +parameter_block+ is given, the block is called with the parameters passed to the expected method.
- # The expectation is matched if the block evaluates to +true+.
- # object = mock()
- # object.expects(:expected_method).with() { |value| value % 4 == 0 }
- # object.expected_method(16)
- # # => verify succeeds
- #
- # object = mock()
- # object.expects(:expected_method).with() { |value| value % 4 == 0 }
- # object.expected_method(17)
- # # => verify fails
- def with(*arguments, &parameter_block)
- @parameters, @parameter_block = arguments, parameter_block
- class << @parameters; def to_s; join(', '); end; end
- self
- end
-
- # :call-seq: yields(*parameters) -> expectation
- #
- # Modifies expectation so that when the expected method is called, it yields with the specified +parameters+.
- # object = mock()
- # object.expects(:expected_method).yields('result')
- # yielded_value = nil
- # object.expected_method { |value| yielded_value = value }
- # yielded_value # => 'result'
- # May be called multiple times on the same expectation for consecutive invocations. Also see Expectation#then.
- # object = mock()
- # object.stubs(:expected_method).yields(1).then.yields(2)
- # yielded_values_from_first_invocation = []
- # yielded_values_from_second_invocation = []
- # object.expected_method { |value| yielded_values_from_first_invocation << value } # first invocation
- # object.expected_method { |value| yielded_values_from_second_invocation << value } # second invocation
- # yielded_values_from_first_invocation # => [1]
- # yielded_values_from_second_invocation # => [2]
- def yields(*parameters)
- @yield_parameters.add(*parameters)
- self
- end
-
- # :call-seq: multiple_yields(*parameter_groups) -> expectation
- #
- # Modifies expectation so that when the expected method is called, it yields multiple times per invocation with the specified +parameter_groups+.
- # object = mock()
- # object.expects(:expected_method).multiple_yields(['result_1', 'result_2'], ['result_3'])
- # yielded_values = []
- # object.expected_method { |*values| yielded_values << values }
- # yielded_values # => [['result_1', 'result_2'], ['result_3]]
- # May be called multiple times on the same expectation for consecutive invocations. Also see Expectation#then.
- # object = mock()
- # object.stubs(:expected_method).multiple_yields([1, 2], [3]).then.multiple_yields([4], [5, 6])
- # yielded_values_from_first_invocation = []
- # yielded_values_from_second_invocation = []
- # object.expected_method { |*values| yielded_values_from_first_invocation << values } # first invocation
- # object.expected_method { |*values| yielded_values_from_second_invocation << values } # second invocation
- # yielded_values_from_first_invocation # => [[1, 2], [3]]
- # yielded_values_from_second_invocation # => [[4], [5, 6]]
- def multiple_yields(*parameter_groups)
- @yield_parameters.multiple_add(*parameter_groups)
- self
- end
-
- # :call-seq: returns(value) -> expectation
- # :call-seq: returns(*values) -> expectation
- #
- # Modifies expectation so that when the expected method is called, it returns the specified +value+.
- # object = mock()
- # object.stubs(:stubbed_method).returns('result')
- # object.stubbed_method # => 'result'
- # object.stubbed_method # => 'result'
- # If multiple +values+ are given, these are returned in turn on consecutive calls to the method.
- # object = mock()
- # object.stubs(:stubbed_method).returns(1, 2)
- # object.stubbed_method # => 1
- # object.stubbed_method # => 2
- # May be called multiple times on the same expectation. Also see Expectation#then.
- # object = mock()
- # object.stubs(:expected_method).returns(1, 2).then.returns(3)
- # object.expected_method # => 1
- # object.expected_method # => 2
- # object.expected_method # => 3
- # May be called in conjunction with Expectation#raises on the same expectation.
- # object = mock()
- # object.stubs(:expected_method).returns(1, 2).then.raises(Exception)
- # object.expected_method # => 1
- # object.expected_method # => 2
- # object.expected_method # => raises exception of class Exception1
- # If +value+ is a +Proc+, then the expected method will return the result of calling <tt>Proc#call</tt>.
- #
- # This usage is _deprecated_.
- # Use explicit multiple return values and/or multiple expectations instead.
- #
- # A +Proc+ instance will be treated the same as any other value in a future release.
- # object = mock()
- # object.stubs(:stubbed_method).returns(lambda { rand(100) })
- # object.stubbed_method # => 41
- # object.stubbed_method # => 77
- def returns(*values)
- @return_values += ReturnValues.build(*values)
- self
- end
-
- # :call-seq: raises(exception = RuntimeError, message = nil) -> expectation
- #
- # Modifies expectation so that when the expected method is called, it raises the specified +exception+ with the specified +message+.
- # object = mock()
- # object.expects(:expected_method).raises(Exception, 'message')
- # object.expected_method # => raises exception of class Exception and with message 'message'
- # May be called multiple times on the same expectation. Also see Expectation#then.
- # object = mock()
- # object.stubs(:expected_method).raises(Exception1).then.raises(Exception2)
- # object.expected_method # => raises exception of class Exception1
- # object.expected_method # => raises exception of class Exception2
- # May be called in conjunction with Expectation#returns on the same expectation.
- # object = mock()
- # object.stubs(:expected_method).raises(Exception).then.returns(2, 3)
- # object.expected_method # => raises exception of class Exception1
- # object.expected_method # => 2
- # object.expected_method # => 3
- def raises(exception = RuntimeError, message = nil)
- @return_values += ReturnValues.new(ExceptionRaiser.new(exception, message))
- self
- end
-
- # :call-seq: then() -> expectation
- #
- # Syntactic sugar to improve readability. Has no effect on state of the expectation.
- # object = mock()
- # object.stubs(:expected_method).returns(1, 2).then.raises(Exception).then.returns(4)
- # object.expected_method # => 1
- # object.expected_method # => 2
- # object.expected_method # => raises exception of class Exception
- # object.expected_method # => 4
- def then
- self
- end
-
- # :stopdoc:
-
- def invoke
- @invoked_count += 1
- if block_given? then
- @yield_parameters.next_invocation.each do |yield_parameters|
- yield(*yield_parameters)
- end
- end
- @return_values.next
- end
-
- def verify
- yield(self) if block_given?
- unless (@expected_count === @invoked_count) then
- error = ExpectationError.new(error_message(@expected_count, @invoked_count))
- error.set_backtrace(filtered_backtrace)
- raise error
- end
- end
-
- def mocha_lib_directory
- File.expand_path(File.join(File.dirname(__FILE__), "..")) + File::SEPARATOR
- end
-
- def filtered_backtrace
- backtrace.reject { |location| Regexp.new(mocha_lib_directory).match(File.expand_path(location)) }
- end
-
- def method_signature
- return "#{method_name}" if @parameters.__is_a__(AlwaysEqual)
- "#{@method_name}(#{PrettyParameters.new(@parameters).pretty})"
- end
-
- def error_message(expected_count, actual_count)
- "#{@mock.mocha_inspect}.#{method_signature} - expected calls: #{expected_count.mocha_inspect}, actual calls: #{actual_count}"
- end
-
- # :startdoc:
-
- end
-
-end \ No newline at end of file
diff --git a/test/lib/mocha/expectation_error.rb b/test/lib/mocha/expectation_error.rb
deleted file mode 100644
index c01482e63..000000000
--- a/test/lib/mocha/expectation_error.rb
+++ /dev/null
@@ -1,6 +0,0 @@
-module Mocha
-
- class ExpectationError < StandardError
- end
-
-end \ No newline at end of file
diff --git a/test/lib/mocha/infinite_range.rb b/test/lib/mocha/infinite_range.rb
deleted file mode 100644
index 05dfe559e..000000000
--- a/test/lib/mocha/infinite_range.rb
+++ /dev/null
@@ -1,25 +0,0 @@
-class Range
-
- def self.at_least(minimum_value)
- Range.new(minimum_value, infinite)
- end
-
- def self.at_most(maximum_value)
- Range.new(-infinite, maximum_value, false)
- end
-
- def self.infinite
- 1/0.0
- end
-
- def mocha_inspect
- if first.respond_to?(:to_f) and first.to_f.infinite? then
- return "at most #{last}"
- elsif last.respond_to?(:to_f) and last.to_f.infinite? then
- return "at least #{first}"
- else
- to_s
- end
- end
-
-end \ No newline at end of file
diff --git a/test/lib/mocha/inspect.rb b/test/lib/mocha/inspect.rb
deleted file mode 100644
index ad82ef70e..000000000
--- a/test/lib/mocha/inspect.rb
+++ /dev/null
@@ -1,39 +0,0 @@
-require 'date'
-
-class Object
- def mocha_inspect
- address = self.__id__ * 2
- address += 0x100000000 if address < 0
- inspect =~ /#</ ? "#<#{self.class}:0x#{'%x' % address}>" : inspect
- end
-end
-
-class String
- def mocha_inspect
- inspect.gsub(/\"/, "'")
- end
-end
-
-class Array
- def mocha_inspect
- "[#{collect { |member| member.mocha_inspect }.join(', ')}]"
- end
-end
-
-class Hash
- def mocha_inspect
- "{#{collect { |key, value| "#{key.mocha_inspect} => #{value.mocha_inspect}" }.join(', ')}}"
- end
-end
-
-class Time
- def mocha_inspect
- "#{inspect} (#{to_f} secs)"
- end
-end
-
-class Date
- def mocha_inspect
- to_s
- end
-end \ No newline at end of file
diff --git a/test/lib/mocha/instance_method.rb b/test/lib/mocha/instance_method.rb
deleted file mode 100644
index f0d4b04b8..000000000
--- a/test/lib/mocha/instance_method.rb
+++ /dev/null
@@ -1,8 +0,0 @@
-require 'mocha/class_method'
-
-module Mocha
-
- class InstanceMethod < ClassMethod
- end
-
-end \ No newline at end of file
diff --git a/test/lib/mocha/is_a.rb b/test/lib/mocha/is_a.rb
deleted file mode 100644
index ee23c86a9..000000000
--- a/test/lib/mocha/is_a.rb
+++ /dev/null
@@ -1,9 +0,0 @@
-class Object
-
- # :stopdoc:
-
- alias_method :__is_a__, :is_a?
-
- # :startdoc:
-
-end
diff --git a/test/lib/mocha/metaclass.rb b/test/lib/mocha/metaclass.rb
deleted file mode 100644
index f78fb892b..000000000
--- a/test/lib/mocha/metaclass.rb
+++ /dev/null
@@ -1,7 +0,0 @@
-class Object
-
- def __metaclass__
- class << self; self; end
- end
-
-end \ No newline at end of file
diff --git a/test/lib/mocha/missing_expectation.rb b/test/lib/mocha/missing_expectation.rb
deleted file mode 100644
index f84227d1a..000000000
--- a/test/lib/mocha/missing_expectation.rb
+++ /dev/null
@@ -1,27 +0,0 @@
-require 'mocha/expectation'
-
-module Mocha # :nodoc:
-
- class MissingExpectation < Expectation # :nodoc:
-
- def initialize(mock, method_name)
- super
- @invoked_count = true
- end
-
- def verify
- msg = error_message(0, 1)
- similar_expectations_list = similar_expectations.collect { |expectation| expectation.method_signature }.join("\n")
- msg << "\nSimilar expectations:\n#{similar_expectations_list}" unless similar_expectations.empty?
- error = ExpectationError.new(msg)
- error.set_backtrace(filtered_backtrace)
- raise error if @invoked_count
- end
-
- def similar_expectations
- @mock.expectations.select { |expectation| expectation.method_name == self.method_name }
- end
-
- end
-
-end \ No newline at end of file
diff --git a/test/lib/mocha/mock.rb b/test/lib/mocha/mock.rb
deleted file mode 100644
index 18c23fede..000000000
--- a/test/lib/mocha/mock.rb
+++ /dev/null
@@ -1,207 +0,0 @@
-require 'mocha/expectation'
-require 'mocha/stub'
-require 'mocha/missing_expectation'
-require 'mocha/metaclass'
-
-module Mocha # :nodoc:
-
- # Traditional mock object.
- #
- # Methods return an Expectation which can be further modified by methods on Expectation.
- class Mock
-
- # :stopdoc:
-
- def initialize(stub_everything = false, name = nil)
- @stub_everything = stub_everything
- @mock_name = name
- @expectations = []
- @responder = nil
- end
-
- attr_reader :stub_everything, :expectations
-
- # :startdoc:
-
- # :call-seq: expects(method_name) -> expectation
- # expects(method_names) -> last expectation
- #
- # Adds an expectation that a method identified by +method_name+ symbol must be called exactly once with any parameters.
- # Returns the new expectation which can be further modified by methods on Expectation.
- # object = mock()
- # object.expects(:method1)
- # object.method1
- # # no error raised
- #
- # object = mock()
- # object.expects(:method1)
- # # error raised, because method1 not called exactly once
- # If +method_names+ is a +Hash+, an expectation will be set up for each entry using the key as +method_name+ and value as +return_value+.
- # object = mock()
- # object.expects(:method1 => :result1, :method2 => :result2)
- #
- # # exactly equivalent to
- #
- # object = mock()
- # object.expects(:method1).returns(:result1)
- # object.expects(:method2).returns(:result2)
- #
- # Aliased by <tt>\_\_expects\_\_</tt>
- def expects(method_name_or_hash, backtrace = nil)
- if method_name_or_hash.is_a?(Hash) then
- method_name_or_hash.each do |method_name, return_value|
- add_expectation(Expectation.new(self, method_name, backtrace).returns(return_value))
- end
- else
- add_expectation(Expectation.new(self, method_name_or_hash, backtrace))
- end
- end
-
- # :call-seq: stubs(method_name) -> expectation
- # stubs(method_names) -> last expectation
- #
- # Adds an expectation that a method identified by +method_name+ symbol may be called any number of times with any parameters.
- # Returns the new expectation which can be further modified by methods on Expectation.
- # object = mock()
- # object.stubs(:method1)
- # object.method1
- # object.method1
- # # no error raised
- # If +method_names+ is a +Hash+, an expectation will be set up for each entry using the key as +method_name+ and value as +return_value+.
- # object = mock()
- # object.stubs(:method1 => :result1, :method2 => :result2)
- #
- # # exactly equivalent to
- #
- # object = mock()
- # object.stubs(:method1).returns(:result1)
- # object.stubs(:method2).returns(:result2)
- #
- # Aliased by <tt>\_\_stubs\_\_</tt>
- def stubs(method_name_or_hash, backtrace = nil)
- if method_name_or_hash.is_a?(Hash) then
- method_name_or_hash.each do |method_name, return_value|
- add_expectation(Stub.new(self, method_name, backtrace).returns(return_value))
- end
- else
- add_expectation(Stub.new(self, method_name_or_hash, backtrace))
- end
- end
-
- # :call-seq: responds_like(responder) -> mock
- #
- # Constrains the +mock+ so that it can only expect or stub methods to which +responder+ responds. The constraint is only applied at method invocation time.
- #
- # A +NoMethodError+ will be raised if the +responder+ does not <tt>respond_to?</tt> a method invocation (even if the method has been expected or stubbed).
- #
- # The +mock+ will delegate its <tt>respond_to?</tt> method to the +responder+.
- # class Sheep
- # def chew(grass); end
- # def self.number_of_legs; end
- # end
- #
- # sheep = mock('sheep')
- # sheep.expects(:chew)
- # sheep.expects(:foo)
- # sheep.respond_to?(:chew) # => true
- # sheep.respond_to?(:foo) # => true
- # sheep.chew
- # sheep.foo
- # # no error raised
- #
- # sheep = mock('sheep')
- # sheep.responds_like(Sheep.new)
- # sheep.expects(:chew)
- # sheep.expects(:foo)
- # sheep.respond_to?(:chew) # => true
- # sheep.respond_to?(:foo) # => false
- # sheep.chew
- # sheep.foo # => raises NoMethodError exception
- #
- # sheep_class = mock('sheep_class')
- # sheep_class.responds_like(Sheep)
- # sheep_class.stubs(:number_of_legs).returns(4)
- # sheep_class.expects(:foo)
- # sheep_class.respond_to?(:number_of_legs) # => true
- # sheep_class.respond_to?(:foo) # => false
- # assert_equal 4, sheep_class.number_of_legs
- # sheep_class.foo # => raises NoMethodError exception
- #
- # Aliased by +quacks_like+
- def responds_like(object)
- @responder = object
- self
- end
-
- # :stopdoc:
-
- alias_method :__expects__, :expects
-
- alias_method :__stubs__, :stubs
-
- alias_method :quacks_like, :responds_like
-
- def add_expectation(expectation)
- @expectations << expectation
- method_name = expectation.method_name
- self.__metaclass__.send(:undef_method, method_name) if self.__metaclass__.method_defined?(method_name)
- expectation
- end
-
- def method_missing(symbol, *arguments, &block)
- if @responder and not @responder.respond_to?(symbol)
- raise NoMethodError, "undefined method `#{symbol}' for #{self.mocha_inspect} which responds like #{@responder.mocha_inspect}"
- end
- matching_expectation = matching_expectation(symbol, *arguments)
- if matching_expectation then
- matching_expectation.invoke(&block)
- elsif stub_everything then
- return
- else
- begin
- super_method_missing(symbol, *arguments, &block)
- rescue NoMethodError
- unexpected_method_called(symbol, *arguments)
- end
- end
- end
-
- def respond_to?(symbol)
- if @responder then
- @responder.respond_to?(symbol)
- else
- @expectations.any? { |expectation| expectation.method_name == symbol }
- end
- end
-
- def super_method_missing(symbol, *arguments, &block)
- raise NoMethodError
- end
-
- def unexpected_method_called(symbol, *arguments)
- MissingExpectation.new(self, symbol).with(*arguments).verify
- end
-
- def matching_expectation(symbol, *arguments)
- @expectations.reverse.detect { |expectation| expectation.match?(symbol, *arguments) }
- end
-
- def verify(&block)
- @expectations.each { |expectation| expectation.verify(&block) }
- end
-
- def mocha_inspect
- address = self.__id__ * 2
- address += 0x100000000 if address < 0
- @mock_name ? "#<Mock:#{@mock_name}>" : "#<Mock:0x#{'%x' % address}>"
- end
-
- def inspect
- mocha_inspect
- end
-
- # :startdoc:
-
- end
-
-end \ No newline at end of file
diff --git a/test/lib/mocha/multiple_yields.rb b/test/lib/mocha/multiple_yields.rb
deleted file mode 100644
index 8186c3076..000000000
--- a/test/lib/mocha/multiple_yields.rb
+++ /dev/null
@@ -1,20 +0,0 @@
-module Mocha # :nodoc:
-
- class MultipleYields # :nodoc:
-
- attr_reader :parameter_groups
-
- def initialize(*parameter_groups)
- @parameter_groups = parameter_groups
- end
-
- def each
- @parameter_groups.each do |parameter_group|
- yield(parameter_group)
- end
- end
-
- end
-
-end
-
diff --git a/test/lib/mocha/no_yields.rb b/test/lib/mocha/no_yields.rb
deleted file mode 100644
index b0fba415d..000000000
--- a/test/lib/mocha/no_yields.rb
+++ /dev/null
@@ -1,11 +0,0 @@
-module Mocha # :nodoc:
-
- class NoYields # :nodoc:
-
- def each
- end
-
- end
-
-end
-
diff --git a/test/lib/mocha/object.rb b/test/lib/mocha/object.rb
deleted file mode 100644
index 7ccdbad0d..000000000
--- a/test/lib/mocha/object.rb
+++ /dev/null
@@ -1,110 +0,0 @@
-require 'mocha/mock'
-require 'mocha/instance_method'
-require 'mocha/class_method'
-require 'mocha/any_instance_method'
-
-# Methods added all objects to allow mocking and stubbing on real objects.
-#
-# Methods return a Mocha::Expectation which can be further modified by methods on Mocha::Expectation.
-class Object
-
- def mocha # :nodoc:
- @mocha ||= Mocha::Mock.new
- end
-
- def reset_mocha # :nodoc:
- @mocha = nil
- end
-
- def stubba_method # :nodoc:
- Mocha::InstanceMethod
- end
-
- def stubba_object # :nodoc:
- self
- end
-
- # :call-seq: expects(symbol) -> expectation
- #
- # Adds an expectation that a method identified by +symbol+ must be called exactly once with any parameters.
- # Returns the new expectation which can be further modified by methods on Mocha::Expectation.
- # product = Product.new
- # product.expects(:save).returns(true)
- # assert_equal false, product.save
- #
- # The original implementation of <tt>Product#save</tt> is replaced temporarily.
- #
- # The original implementation of <tt>Product#save</tt> is restored at the end of the test.
- def expects(symbol)
- method = stubba_method.new(stubba_object, symbol)
- $stubba.stub(method)
- mocha.expects(symbol, caller)
- end
-
- # :call-seq: stubs(symbol) -> expectation
- #
- # Adds an expectation that a method identified by +symbol+ may be called any number of times with any parameters.
- # Returns the new expectation which can be further modified by methods on Mocha::Expectation.
- # product = Product.new
- # product.stubs(:save).returns(true)
- # assert_equal false, product.save
- #
- # The original implementation of <tt>Product#save</tt> is replaced temporarily.
- #
- # The original implementation of <tt>Product#save</tt> is restored at the end of the test.
- def stubs(symbol)
- method = stubba_method.new(stubba_object, symbol)
- $stubba.stub(method)
- mocha.stubs(symbol, caller)
- end
-
- def verify # :nodoc:
- mocha.verify
- end
-
-end
-
-class Module # :nodoc:
-
- def stubba_method
- Mocha::ClassMethod
- end
-
-end
-
-class Class
-
- def stubba_method # :nodoc:
- Mocha::ClassMethod
- end
-
- class AnyInstance # :nodoc:
-
- def initialize(klass)
- @stubba_object = klass
- end
-
- def stubba_method
- Mocha::AnyInstanceMethod
- end
-
- def stubba_object
- @stubba_object
- end
-
- end
-
- # :call-seq: any_instance -> mock object
- #
- # Returns a mock object which will detect calls to any instance of this class.
- # Product.any_instance.stubs(:save).returns(false)
- # product_1 = Product.new
- # assert_equal false, product_1.save
- # product_2 = Product.new
- # assert_equal false, product_2.save
- def any_instance
- @any_instance ||= AnyInstance.new(self)
- end
-
-end
-
diff --git a/test/lib/mocha/parameter_matchers.rb b/test/lib/mocha/parameter_matchers.rb
deleted file mode 100644
index 193f77d93..000000000
--- a/test/lib/mocha/parameter_matchers.rb
+++ /dev/null
@@ -1,9 +0,0 @@
-module Mocha
-
- # Used as parameters for Expectation#with to restrict the parameter values which will match the expectation.
- module ParameterMatchers; end
-
-end
-
-
-Dir[File.expand_path(File.join(File.dirname(__FILE__), 'parameter_matchers', "*.rb"))].each { |lib| require lib }
diff --git a/test/lib/mocha/parameter_matchers/all_of.rb b/test/lib/mocha/parameter_matchers/all_of.rb
deleted file mode 100644
index 343d9eea0..000000000
--- a/test/lib/mocha/parameter_matchers/all_of.rb
+++ /dev/null
@@ -1,39 +0,0 @@
-module Mocha
-
- module ParameterMatchers
-
- # :call-seq: all_of -> parameter_matcher
- #
- # Matches if all +matchers+ match.
- # object = mock()
- # object.expects(:method_1).with(all_of(includes(1), includes(3)))
- # object.method_1([1, 3])
- # # no error raised
- #
- # object = mock()
- # object.expects(:method_1).with(all_of(includes(1), includes(3)))
- # object.method_1([1, 2])
- # # error raised, because method_1 was not called with object including 1 and 3
- def all_of(*matchers)
- AllOf.new(*matchers)
- end
-
- class AllOf # :nodoc:
-
- def initialize(*matchers)
- @matchers = matchers
- end
-
- def ==(parameter)
- @matchers.all? { |matcher| matcher == parameter }
- end
-
- def mocha_inspect
- "all_of(#{@matchers.map { |matcher| matcher.mocha_inspect }.join(", ") })"
- end
-
- end
-
- end
-
-end \ No newline at end of file
diff --git a/test/lib/mocha/parameter_matchers/any_of.rb b/test/lib/mocha/parameter_matchers/any_of.rb
deleted file mode 100644
index a1f88075d..000000000
--- a/test/lib/mocha/parameter_matchers/any_of.rb
+++ /dev/null
@@ -1,44 +0,0 @@
-module Mocha
-
- module ParameterMatchers
-
- # :call-seq: any_of -> parameter_matcher
- #
- # Matches if any +matchers+ match.
- # object = mock()
- # object.expects(:method_1).with(any_of(1, 3))
- # object.method_1(1)
- # # no error raised
- #
- # object = mock()
- # object.expects(:method_1).with(any_of(1, 3))
- # object.method_1(3)
- # # no error raised
- #
- # object = mock()
- # object.expects(:method_1).with(any_of(1, 3))
- # object.method_1(2)
- # # error raised, because method_1 was not called with 1 or 3
- def any_of(*matchers)
- AnyOf.new(*matchers)
- end
-
- class AnyOf # :nodoc:
-
- def initialize(*matchers)
- @matchers = matchers
- end
-
- def ==(parameter)
- @matchers.any? { |matcher| matcher == parameter }
- end
-
- def mocha_inspect
- "any_of(#{@matchers.map { |matcher| matcher.mocha_inspect }.join(", ") })"
- end
-
- end
-
- end
-
-end \ No newline at end of file
diff --git a/test/lib/mocha/parameter_matchers/anything.rb b/test/lib/mocha/parameter_matchers/anything.rb
deleted file mode 100644
index 57d0eeab4..000000000
--- a/test/lib/mocha/parameter_matchers/anything.rb
+++ /dev/null
@@ -1,30 +0,0 @@
-module Mocha
-
- module ParameterMatchers
-
- # :call-seq: anything -> parameter_matcher
- #
- # Matches any object.
- # object = mock()
- # object.expects(:method_1).with(anything)
- # object.method_1('foo')
- # # no error raised
- def anything
- Anything.new
- end
-
- class Anything # :nodoc:
-
- def ==(parameter)
- return true
- end
-
- def mocha_inspect
- "anything"
- end
-
- end
-
- end
-
-end \ No newline at end of file
diff --git a/test/lib/mocha/parameter_matchers/has_entry.rb b/test/lib/mocha/parameter_matchers/has_entry.rb
deleted file mode 100644
index 3d7cac4e6..000000000
--- a/test/lib/mocha/parameter_matchers/has_entry.rb
+++ /dev/null
@@ -1,39 +0,0 @@
-module Mocha
-
- module ParameterMatchers
-
- # :call-seq: has_entry(key, value) -> parameter_matcher
- #
- # Matches +Hash+ containing entry with +key+ and +value+.
- # object = mock()
- # object.expects(:method_1).with(has_entry('key_1', 1))
- # object.method_1('key_1' => 1, 'key_2' => 2)
- # # no error raised
- #
- # object = mock()
- # object.expects(:method_1).with(has_entry('key_1', 1))
- # object.method_1('key_1' => 2, 'key_2' => 1)
- # # error raised, because method_1 was not called with Hash containing entry: 'key_1' => 1
- def has_entry(key, value)
- HasEntry.new(key, value)
- end
-
- class HasEntry # :nodoc:
-
- def initialize(key, value)
- @key, @value = key, value
- end
-
- def ==(parameter)
- parameter[@key] == @value
- end
-
- def mocha_inspect
- "has_entry(#{@key.mocha_inspect}, #{@value.mocha_inspect})"
- end
-
- end
-
- end
-
-end \ No newline at end of file
diff --git a/test/lib/mocha/parameter_matchers/has_key.rb b/test/lib/mocha/parameter_matchers/has_key.rb
deleted file mode 100644
index 5a1fcd2e8..000000000
--- a/test/lib/mocha/parameter_matchers/has_key.rb
+++ /dev/null
@@ -1,39 +0,0 @@
-module Mocha
-
- module ParameterMatchers
-
- # :call-seq: has_key(key) -> parameter_matcher
- #
- # Matches +Hash+ containing +key+.
- # object = mock()
- # object.expects(:method_1).with(has_key('key_1'))
- # object.method_1('key_1' => 1, 'key_2' => 2)
- # # no error raised
- #
- # object = mock()
- # object.expects(:method_1).with(has_key('key_1'))
- # object.method_1('key_2' => 2)
- # # error raised, because method_1 was not called with Hash containing key: 'key_1'
- def has_key(key)
- HasKey.new(key)
- end
-
- class HasKey # :nodoc:
-
- def initialize(key)
- @key = key
- end
-
- def ==(parameter)
- parameter.keys.include?(@key)
- end
-
- def mocha_inspect
- "has_key(#{@key.mocha_inspect})"
- end
-
- end
-
- end
-
-end \ No newline at end of file
diff --git a/test/lib/mocha/parameter_matchers/has_value.rb b/test/lib/mocha/parameter_matchers/has_value.rb
deleted file mode 100644
index 742f84268..000000000
--- a/test/lib/mocha/parameter_matchers/has_value.rb
+++ /dev/null
@@ -1,39 +0,0 @@
-module Mocha
-
- module ParameterMatchers
-
- # :call-seq: has_value(value) -> parameter_matcher
- #
- # Matches +Hash+ containing +value+.
- # object = mock()
- # object.expects(:method_1).with(has_value(1))
- # object.method_1('key_1' => 1, 'key_2' => 2)
- # # no error raised
- #
- # object = mock()
- # object.expects(:method_1).with(has_value(1))
- # object.method_1('key_2' => 2)
- # # error raised, because method_1 was not called with Hash containing value: 1
- def has_value(value)
- HasValue.new(value)
- end
-
- class HasValue # :nodoc:
-
- def initialize(value)
- @value = value
- end
-
- def ==(parameter)
- parameter.values.include?(@value)
- end
-
- def mocha_inspect
- "has_value(#{@value.mocha_inspect})"
- end
-
- end
-
- end
-
-end \ No newline at end of file
diff --git a/test/lib/mocha/parameter_matchers/includes.rb b/test/lib/mocha/parameter_matchers/includes.rb
deleted file mode 100644
index 0e4fbe960..000000000
--- a/test/lib/mocha/parameter_matchers/includes.rb
+++ /dev/null
@@ -1,37 +0,0 @@
-module Mocha
-
- module ParameterMatchers
-
- # :call-seq: includes(item) -> parameter_matcher
- #
- # Matches any object that responds true to include?(item)
- # object = mock()
- # object.expects(:method_1).with(includes('foo'))
- # object.method_1(['foo', 'bar'])
- # # no error raised
- #
- # object.method_1(['baz'])
- # # error raised, because ['baz'] does not include 'foo'.
- def includes(item)
- Includes.new(item)
- end
-
- class Includes # :nodoc:
-
- def initialize(item)
- @item = item
- end
-
- def ==(parameter)
- return parameter.include?(@item)
- end
-
- def mocha_inspect
- "includes(#{@item.mocha_inspect})"
- end
-
- end
-
- end
-
-end
diff --git a/test/lib/mocha/pretty_parameters.rb b/test/lib/mocha/pretty_parameters.rb
deleted file mode 100644
index 6d3c165f8..000000000
--- a/test/lib/mocha/pretty_parameters.rb
+++ /dev/null
@@ -1,28 +0,0 @@
-require 'mocha/inspect'
-
-module Mocha
-
- class PrettyParameters
-
- def initialize(params)
- @params = params
- @params_string = params.mocha_inspect
- end
-
- def pretty
- remove_outer_array_braces!
- remove_outer_hash_braces!
- @params_string
- end
-
- def remove_outer_array_braces!
- @params_string = @params_string.gsub(/^\[|\]$/, '')
- end
-
- def remove_outer_hash_braces!
- @params_string = @params_string.gsub(/^\{|\}$/, '') if @params.size == 1
- end
-
- end
-
-end \ No newline at end of file
diff --git a/test/lib/mocha/return_values.rb b/test/lib/mocha/return_values.rb
deleted file mode 100644
index ea0fbbd40..000000000
--- a/test/lib/mocha/return_values.rb
+++ /dev/null
@@ -1,31 +0,0 @@
-require 'mocha/single_return_value'
-
-module Mocha # :nodoc:
-
- class ReturnValues # :nodoc:
-
- def self.build(*values)
- new(*values.map { |value| SingleReturnValue.new(value) })
- end
-
- attr_accessor :values
-
- def initialize(*values)
- @values = values
- end
-
- def next
- case @values.size
- when 0: nil
- when 1: @values.first.evaluate
- else @values.shift.evaluate
- end
- end
-
- def +(other)
- self.class.new(*(@values + other.values))
- end
-
- end
-
-end \ No newline at end of file
diff --git a/test/lib/mocha/setup_and_teardown.rb b/test/lib/mocha/setup_and_teardown.rb
deleted file mode 100644
index 034ce1d6b..000000000
--- a/test/lib/mocha/setup_and_teardown.rb
+++ /dev/null
@@ -1,23 +0,0 @@
-require 'mocha/central'
-
-module Mocha
-
- module SetupAndTeardown
-
- def setup_stubs
- $stubba = Mocha::Central.new
- end
-
- def verify_stubs
- $stubba.verify_all { yield if block_given? } if $stubba
- end
-
- def teardown_stubs
- if $stubba then
- $stubba.unstub_all
- $stubba = nil
- end
- end
-
- end
-end \ No newline at end of file
diff --git a/test/lib/mocha/single_return_value.rb b/test/lib/mocha/single_return_value.rb
deleted file mode 100644
index f420b8b8c..000000000
--- a/test/lib/mocha/single_return_value.rb
+++ /dev/null
@@ -1,24 +0,0 @@
-require 'mocha/is_a'
-require 'mocha/deprecation'
-
-module Mocha # :nodoc:
-
- class SingleReturnValue # :nodoc:
-
- def initialize(value)
- @value = value
- end
-
- def evaluate
- if @value.__is_a__(Proc) then
- message = 'use of Expectation#returns with instance of Proc - see Expectation#returns RDoc for alternatives'
- Deprecation.warning(message)
- @value.call
- else
- @value
- end
- end
-
- end
-
-end \ No newline at end of file
diff --git a/test/lib/mocha/single_yield.rb b/test/lib/mocha/single_yield.rb
deleted file mode 100644
index 5af571621..000000000
--- a/test/lib/mocha/single_yield.rb
+++ /dev/null
@@ -1,18 +0,0 @@
-module Mocha # :nodoc:
-
- class SingleYield # :nodoc:
-
- attr_reader :parameters
-
- def initialize(*parameters)
- @parameters = parameters
- end
-
- def each
- yield(@parameters)
- end
-
- end
-
-end
-
diff --git a/test/lib/mocha/standalone.rb b/test/lib/mocha/standalone.rb
deleted file mode 100644
index 8e3a7cefc..000000000
--- a/test/lib/mocha/standalone.rb
+++ /dev/null
@@ -1,32 +0,0 @@
-require 'mocha/auto_verify'
-require 'mocha/parameter_matchers'
-require 'mocha/setup_and_teardown'
-
-module Mocha
-
- module Standalone
-
- include AutoVerify
- include ParameterMatchers
- include SetupAndTeardown
-
- def mocha_setup
- setup_stubs
- end
-
- def mocha_verify(&block)
- verify_mocks(&block)
- verify_stubs(&block)
- end
-
- def mocha_teardown
- begin
- teardown_mocks
- ensure
- teardown_stubs
- end
- end
-
- end
-
-end \ No newline at end of file
diff --git a/test/lib/mocha/stub.rb b/test/lib/mocha/stub.rb
deleted file mode 100644
index 1b3cccb8a..000000000
--- a/test/lib/mocha/stub.rb
+++ /dev/null
@@ -1,18 +0,0 @@
-require 'mocha/expectation'
-
-module Mocha # :nodoc:
-
- class Stub < Expectation # :nodoc:
-
- def initialize(mock, method_name, backtrace = nil)
- super
- @expected_count = Range.at_least(0)
- end
-
- def verify
- true
- end
-
- end
-
-end \ No newline at end of file
diff --git a/test/lib/mocha/test_case_adapter.rb b/test/lib/mocha/test_case_adapter.rb
deleted file mode 100644
index dc7e33b68..000000000
--- a/test/lib/mocha/test_case_adapter.rb
+++ /dev/null
@@ -1,49 +0,0 @@
-require 'mocha/expectation_error'
-
-module Mocha
-
- module TestCaseAdapter
-
- def self.included(base)
- base.class_eval do
-
- alias_method :run_before_mocha_test_case_adapter, :run
-
- def run(result)
- yield(Test::Unit::TestCase::STARTED, name)
- @_result = result
- begin
- mocha_setup
- begin
- setup
- __send__(@method_name)
- mocha_verify { add_assertion }
- rescue Mocha::ExpectationError => e
- add_failure(e.message, e.backtrace)
- rescue Test::Unit::AssertionFailedError => e
- add_failure(e.message, e.backtrace)
- rescue StandardError, ScriptError
- add_error($!)
- ensure
- begin
- teardown
- rescue Test::Unit::AssertionFailedError => e
- add_failure(e.message, e.backtrace)
- rescue StandardError, ScriptError
- add_error($!)
- end
- end
- ensure
- mocha_teardown
- end
- result.add_run
- yield(Test::Unit::TestCase::FINISHED, name)
- end
-
- end
-
- end
-
- end
-
-end \ No newline at end of file
diff --git a/test/lib/mocha/yield_parameters.rb b/test/lib/mocha/yield_parameters.rb
deleted file mode 100644
index b1623bf71..000000000
--- a/test/lib/mocha/yield_parameters.rb
+++ /dev/null
@@ -1,31 +0,0 @@
-require 'mocha/no_yields'
-require 'mocha/single_yield'
-require 'mocha/multiple_yields'
-
-module Mocha # :nodoc:
-
- class YieldParameters # :nodoc:
-
- def initialize
- @parameter_groups = []
- end
-
- def next_invocation
- case @parameter_groups.size
- when 0: NoYields.new
- when 1: @parameter_groups.first
- else @parameter_groups.shift
- end
- end
-
- def add(*parameters)
- @parameter_groups << SingleYield.new(*parameters)
- end
-
- def multiple_add(*parameter_groups)
- @parameter_groups << MultipleYields.new(*parameter_groups)
- end
-
- end
-
-end \ No newline at end of file