Skip to content

Commit

Permalink
Merge branch 'master' into change-method-dispatch-behavior-to-that-of…
Browse files Browse the repository at this point in the history
…-jmock2
  • Loading branch information
nitishr authored Nov 25, 2019
2 parents 109aa20 + 6a81f1d commit a56c015
Show file tree
Hide file tree
Showing 187 changed files with 3,529 additions and 2,320 deletions.
3 changes: 3 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ AllCops:
Style/Alias:
EnforcedStyle: prefer_alias_method

Style/Documentation:
Enabled: false

# Enumerable#each_with_object only available since Ruby v1.9
Style/EachWithObject:
Enabled: false
Expand Down
37 changes: 7 additions & 30 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
@@ -1,49 +1,26 @@
# This configuration was generated by
# `rubocop --auto-gen-config`
# on 2018-07-26 12:42:35 +0100 using RuboCop version 0.58.2.
# on 2019-11-16 18:15:36 +0000 using RuboCop version 0.58.2.
# The point is for the user to remove these configuration records
# one by one as the offenses are removed from the code base.
# Note that changes in the inspected code, or installation of new
# versions of RuboCop, may require this file to be generated again.

# Offense count: 53
# Offense count: 57
Metrics/AbcSize:
Max: 39
Max: 26

# Offense count: 2
# Configuration parameters: CountComments, ExcludedMethods.
# ExcludedMethods: refine
Metrics/BlockLength:
Max: 48

# Offense count: 22
# Offense count: 23
# Configuration parameters: CountComments.
Metrics/ClassLength:
Max: 368

# Offense count: 4
Metrics/CyclomaticComplexity:
Max: 9
Max: 366

# Offense count: 173
# Offense count: 172
# Configuration parameters: CountComments.
Metrics/MethodLength:
Max: 31

# Offense count: 1
# Configuration parameters: CountComments.
Metrics/ModuleLength:
Max: 158

# Offense count: 5
Metrics/PerceivedComplexity:
Max: 11

# Offense count: 105
Style/Documentation:
Enabled: false

# Offense count: 501
# Offense count: 545
# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
# URISchemes: http, https
Metrics/LineLength:
Expand Down
31 changes: 19 additions & 12 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,12 @@ rvm:
- 2.0.0
- 2.1.10
- 2.2.10
- 2.3.7
- 2.4.4
- 2.5.1
- 2.3.8
- 2.4.9
- 2.5.7
- 2.6.5
- ruby-head
- jruby-9.2.8.0
- jruby-9.2.9.0
- jruby-head
- truffleruby
gemfile:
Expand All @@ -27,19 +28,22 @@ matrix:
- rvm: jruby-head
gemfile: gemfiles/Gemfile.minitest.latest
env: MOCHA_OPTIONS=debug MOCHA_RUN_INTEGRATION_TESTS=minitest
- rvm: jruby-9.2.8.0
- rvm: jruby-9.2.9.0
gemfile: gemfiles/Gemfile.minitest.latest
env: MOCHA_OPTIONS=debug MOCHA_RUN_INTEGRATION_TESTS=minitest
- rvm: ruby-head
gemfile: gemfiles/Gemfile.minitest.latest
env: MOCHA_OPTIONS=debug MOCHA_RUN_INTEGRATION_TESTS=minitest
- rvm: 2.5.1
- rvm: 2.6.5
gemfile: gemfiles/Gemfile.minitest.latest
env: MOCHA_OPTIONS=debug MOCHA_RUN_INTEGRATION_TESTS=minitest
- rvm: 2.4.4
- rvm: 2.5.7
gemfile: gemfiles/Gemfile.minitest.latest
env: MOCHA_OPTIONS=debug MOCHA_RUN_INTEGRATION_TESTS=minitest
- rvm: 2.3.7
- rvm: 2.4.9
gemfile: gemfiles/Gemfile.minitest.latest
env: MOCHA_OPTIONS=debug MOCHA_RUN_INTEGRATION_TESTS=minitest
- rvm: 2.3.8
gemfile: gemfiles/Gemfile.minitest.latest
env: MOCHA_OPTIONS=debug MOCHA_RUN_INTEGRATION_TESTS=minitest
- rvm: 2.2.10
Expand Down Expand Up @@ -102,7 +106,7 @@ matrix:
- rvm: truffleruby
gemfile: gemfiles/Gemfile.test-unit.latest
env: MOCHA_OPTIONS=debug MOCHA_RUN_INTEGRATION_TESTS=test-unit
- rvm: jruby-9.2.8.0
- rvm: jruby-9.2.9.0
gemfile: gemfiles/Gemfile.test-unit.latest
env: MOCHA_OPTIONS=debug MOCHA_RUN_INTEGRATION_TESTS=test-unit
- rvm: jruby-head
Expand All @@ -111,13 +115,16 @@ matrix:
- rvm: ruby-head
gemfile: gemfiles/Gemfile.test-unit.latest
env: MOCHA_OPTIONS=debug MOCHA_RUN_INTEGRATION_TESTS=test-unit
- rvm: 2.5.1
- rvm: 2.6.5
gemfile: gemfiles/Gemfile.test-unit.latest
env: MOCHA_OPTIONS=debug MOCHA_RUN_INTEGRATION_TESTS=test-unit
- rvm: 2.5.7
gemfile: gemfiles/Gemfile.test-unit.latest
env: MOCHA_OPTIONS=debug MOCHA_RUN_INTEGRATION_TESTS=test-unit
- rvm: 2.4.4
- rvm: 2.4.9
gemfile: gemfiles/Gemfile.test-unit.latest
env: MOCHA_OPTIONS=debug MOCHA_RUN_INTEGRATION_TESTS=test-unit
- rvm: 2.3.7
- rvm: 2.3.8
gemfile: gemfiles/Gemfile.test-unit.latest
env: MOCHA_OPTIONS=debug MOCHA_RUN_INTEGRATION_TESTS=test-unit
- rvm: 2.2.10
Expand Down
14 changes: 4 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,14 @@

### Description

* A Ruby library for mocking and stubbing.
* A Ruby library for [mocking](http://xunitpatterns.com/Mock%20Object.html) and [stubbing](http://xunitpatterns.com/Test%20Stub.html) - but deliberately not (yet) [faking](http://xunitpatterns.com/Fake%20Object.html) or [spying](http://xunitpatterns.com/Test%20Spy.html).
* A unified, simple and readable syntax for both full & partial mocking.
* Built-in support for MiniTest and Test::Unit.
* Supported by many other test frameworks.

### Intended Usage
Mocha is intended to be used in unit tests for the [Mock Object](http://xunitpatterns.com/Mock%20Object.html) or [Test Stub](http://xunitpatterns.com/Test%20Stub.html) types of [Test Double](http://xunitpatterns.com/Test%20Double.html), not the [Fake Object](http://xunitpatterns.com/Fake%20Object.html) or [Test Spy](http://xunitpatterns.com/Test%20Spy.html) types. Although it would be possible to extend Mocha to allow the implementation of fakes and spies, we have chosen to keep it focused on mocks and stubs.

### Installation

#### Gem
Expand Down Expand Up @@ -92,14 +95,6 @@ end

Note: There is no need to use a require statement to setup Mocha; RSpec does this itself.

#### Rails Plugin

Install the Rails plugin...

$ rails plugin install git://github.com/freerange/mocha.git

Note: As of version 0.9.8, the Mocha plugin is not automatically setup at plugin load time. Instead it must be manually setup e.g. at the bottom of your `test_helper.rb`.

##### MiniTest

```ruby
Expand All @@ -115,7 +110,6 @@ require 'mocha/minitest'
* 0.13.x versions cause a harmless, but annoying, deprecation warning when used with Rails 3.2.0-3.2.12, 3.1.0-3.1.10 & 3.0.0-3.0.19.
* 0.11.x versions don't work with Rails 3.2.13 (`TypeError: superclass mismatch for class ExpectationError`). See #115.
* Versions 0.10.2, 0.10.3 & 0.11.0 of the Mocha gem were broken. Please do not use these versions.
* Versions 0.9.6 & 0.9.7 of the Mocha Rails plugin were broken. Please do not use these versions.

### Usage

Expand Down
48 changes: 48 additions & 0 deletions RELEASE.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,53 @@
# Release Notes

## 1.10.0.alpha

### External changes

* Remove dependency on metaclass gem (#49, #365)
* Accept symbol (as well as a string) as mock/stub name - thanks to @nitishr (#347, #353, #377)
* More realistic examples in documentation for `Expectation#yields` and `#multiple_yields` - thanks to @nitishr (#352, #383)
* Improve documentation for `Mock#responds_like` & `#responds_like_instance_of` - thanks to @nitishr (#337, #384)
* Make `Expectation#yields` & `Expectation#multiple_yields` fail when the caller of the stubbed method does not provide a block. This is a change to an undocumented aspect of the public API's behaviour. If this causes your tests to fail, then fix it by removing the unnecessary call to `Expectation#yields` or `Expectation#multiple_yields` - thanks to @nitishr (#382)
* Document `MOCHA_OPTIONS` in README - thanks to @nitishr (#311, #386)
* Add documentation to explain how Mocha is intended to be used - thanks to @nitishr (#330, #385)
* Deprecation warning if integration using 'mocha/test_unit' or 'mocha/minitest' fails - thanks to @nitishr (#229, #389, c6032d0b)
* Require at least one specified sequence for `Expectation#in_sequence` - thanks to @nitishr (#79, #396, 9020248a)
* Make signatures of `Mock#unstub` & `ObjectMethods#unstub` consistent - thanks to @nitishr (#397, f04d437)
* Deprecate requiring 'mocha/setup' (36adf880)
* Optionally display matching invocations alongside expectations - thanks to @nitishr (#178, #394, 00f0540, #410)
* Put deprecations into effect (#400, #418):
* Remove deprecated 'mocha_standalone.rb' & 'mocha/standalone.rb'
* Fail fast if no test library loaded
* Removed optional block for `Mocha::API#mock`, `#stub` & `#stub_everything`
* Remove deprecated `ParameterMatchers#has_equivalent_query_string` method
* Remove deprecated 'mocha/mini_test.rb'
* Fix typo in docs for `Mocha::Configuration.prevent` (266ce71c)
* New-style configuration (see documentation for `Mocha::Configuration`) (#407, #421)
* Deprecate support for Ruby versions earlier than v1.9 (#325, c5f8496d)
* Deprecate support for versions of test-unit & minitest which need monkey-patching (a34e1a88)
* Deprecate old-style Rails plugin (#403, 2df77134)
* Documentation fixes & improvements which also fix YARD warnings (472d5416, a2c0d64a)

### Internal changes

* Pin minitest to v5.11.3 for Ruby v1.8.7 to fix build; minitest no longer supports Ruby v1.8.7 (4a0a580)
* Upgrade JRuby to v9.2.8.0 in Travis CI builds (aa29b3f)
* Only run rubocop for MRI Ruby versions & non-integration test builds (8f1c6af)
* Reduce duplication in any instance method class - thanks to @nitishr (#378)
* Simplify `AnyInstanceMethod`, `ClassMethod`, `InstanceMethod`, `ModuleMethod` class hierarchy - thanks to @nitishr (#381)
* Simplify `ClassMethods#method_exists?` & `ObjectMethods#method_exists?` making them consistent - thanks to @nitishr (#270, #362, #370)
* Don't override definition of `singleton_class` in `ClassMethods` - thanks to @nitishr (#391, #392)
* Do not include 'method_definer' methods into all objects (#268, #402)
* Distinguish different `ObjectMethods` modules (#268, #404)
* Pass invocation to expectation list methods - thanks to @nitishr (#408, #409, #411)
* Consistently use `assert_raises` - thanks to @nitishr (#405, #412, a66b7bed)
* Update Ruby & JRuby versions in Travis CI config (18cb1a93, eb061c53)
* Rubocop improvements (aa16ea67...6f4db70b, 2a1240e6...e95716ae)
* Fix inconsistency in CardinalityTest (aa10e0a8)
* Fix test failures on Mac OSX Catalina - thanks to @nitishr (#413, #417, #419, 8a0f2535)
* Remove default argument in `Expectation#invoke` - thanks to @nitishr (#414, #420)

## 1.9.0

* Add TruffleRuby to Travis CI build matrix - thanks to @deepj (#354)
Expand Down
4 changes: 3 additions & 1 deletion Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ task 'test' do
end
end

namespace 'test' do
namespace 'test' do # rubocop:disable Metrics/BlockLength
unit_tests = FileList['test/unit/**/*_test.rb']
all_acceptance_tests = FileList['test/acceptance/*_test.rb']
ruby186_incompatible_acceptance_tests = FileList['test/acceptance/stub_class_method_defined_on_*_test.rb'] + FileList['test/acceptance/stub_instance_method_defined_on_*_test.rb']
Expand Down Expand Up @@ -92,6 +92,7 @@ begin
rescue LoadError # rubocop:disable Lint/HandleExceptions
end

# rubocop:disable Metrics/CyclomaticComplexity,Metrics/PerceivedComplexity
def benchmark_test_case(klass, iterations)
require 'benchmark'
require 'mocha/detection/mini_test'
Expand Down Expand Up @@ -119,6 +120,7 @@ def benchmark_test_case(klass, iterations)
Benchmark.realtime { iterations.times { Test::Unit::UI::Console::TestRunner.run(klass, @silent_option) } }
end
end
# rubocop:enable Metrics/CyclomaticComplexity,Metrics/PerceivedComplexity

if ENV['MOCHA_GENERATE_DOCS']
require 'yard'
Expand Down
Loading

0 comments on commit a56c015

Please sign in to comment.