Ecosyste.ms: OpenCollective

An open API service for software projects hosted on Open Collective.

github.com/freerange/mocha

A mocking and stubbing library for Ruby
https://github.com/freerange/mocha

Remove default argument in Expectation#invoke

PR: #420

Closes #414.

Co-authored-by: Nitish Rathi <[email protected]>

65b94a35e6aabd69cc13b8586eb85c9ca4fc0bad authored about 5 years ago by James Mead <[email protected]>
Call Expectation#invoke with invocation from ExpectationTest

This allows us to remove the slightly ugly default argument for
Expectation#invoke.

9ecfb1c1a690c74a46366475adef8e125cb54d6e authored about 5 years ago by Nitish Rathi <[email protected]>
Extract ExpectationTest#invoke

In preparation for passing Invocation instance to Expectation#invoke.

077e8578f7f617ab19fd6d4931118a9381e8f7e0 authored about 5 years ago by Nitish Rathi <[email protected]>
Inline local variables in ExpectationTest

In preparation for extracting an `invoke` helper method.

40e7e351b74d709ed24b033436ee9d57490ea608 authored about 5 years ago by Nitish Rathi <[email protected]>
Use Integer#times in ExpectationTest to make tests clearer

This makes the relationship with Expectation#times clearer.

d7fb22434ac60463ea5327f6f82f82232540963a authored about 5 years ago by Nitish Rathi <[email protected]>
Fix ExpectationTest tests which were only passing accidentally

The names of these tests imply that the intention is that the method
name should match (i.e. sho...

41cc6bf5f2018b79ce0e16b2b440f6880d14043f authored about 5 years ago by Nitish Rathi <[email protected]>
Fix MacOS version extraction

RUBY_PLATFORM doesn't necessarily end with $, as it may include a minor
version number (e.g. x86...

8a0f253504daac0a7ff5db0e58631f380620ed54 authored about 5 years ago by Nitish Rathi <[email protected]>
Merge pull request #417 from freerange/fix-test-failures-on-mac-osx-catalina

Fix test failures on Mac OSX Catalina

a0c8bc7b7c78938b331dceb5c8cb8466c27a7dd9 authored about 5 years ago by James Mead <[email protected]>
Exclude syscall from Object methods tested on MacOS Mojave & above

This might be overly conservative, because I know the tests worked
without this exclusion on Mac...

c74df55cab397c41717750ae4c025732707b38bc authored about 5 years ago by James Mead <[email protected]>
Make MockTest::OBJECT_METHODS definition clearer

95504cc74b7697378704c2857e0ceb4bf4111985 authored about 5 years ago by James Mead <[email protected]>
Extract constants in MockTest for clarity

9add8ea93edd14741970b5867a4d4148bc0f70b4 authored about 5 years ago by James Mead <[email protected]>
Use default Max for Metrics/PerceivedComplexity cop

By explicitly disabling 4 violations.

e95716ae629255816fe80b3ca79416d859aeeb3b authored about 5 years ago by James Mead <[email protected]>
Use default Max for Metrics/CyclomaticComplexity cop

By explicitly disabling the cop for 4 violations.

d19f85335488e3c36d43e58c923518d622593825 authored about 5 years ago by James Mead <[email protected]>
Use inline version of rubocop disable in a couple of places

a3bdc518f74e11b48ca78e5c832c9651987e8cef authored about 5 years ago by James Mead <[email protected]>
Use default Max for Metrics/BlockLength cop

By explicitly disabling 2 violations.

d6ddf3658e6717540821ff8b511da8814f652c2d authored about 5 years ago by James Mead <[email protected]>
Reduce Max for Metrics/AbcSize cop

By explicitly disabling cop for one violation.

09a6847ac2dba2545bcb545add0ceae931713b23 authored about 5 years ago by James Mead <[email protected]>
Split Cardinality test method up

2a1240e6ad7bfacd36060c2043f0c2e3f49d2e68 authored about 5 years ago by James Mead <[email protected]>
Fix inconsistency in CardinalityTest

aa10e0a8ec9e4b2a98cbd8e3c0883d8972756255 authored about 5 years ago by James Mead <[email protected]>
Use default Max for Metrics/ModuleLength cop

Explicitly disable cop for the one violation. This should avoid any
other long modules appearing.

6f4db70bcb36e29b51554355c27c8f21c01d96dc authored about 5 years ago by James Mead <[email protected]>
Disable Style/Documentation cop in main rubcop config

I'm happy not having class/module level documentation comments.

d4edb1ced3c5baf2cf28f641440c0de1c4d5c51f authored about 5 years ago by James Mead <[email protected]>
Update rubocop to-do list

I generated this using the following command:

$ rubocop --auto-gen-config

aa16ea67b702b69c2af4cb200f9cda01789709fa authored about 5 years ago by James Mead <[email protected]>
Update JRuby version in Travis CI config

JRuby v9.2.9.0 was released at the end of Oct 2019 [1].

[1]: https://www.jruby.org/2019/10/30/j...

eb061c53faa31926a19cab9eb82e091798b9964e authored about 5 years ago by James Mead <[email protected]>
Update Ruby versions in Travis CI config

These are the latest point releases of Ruby.

18cb1a93a56cffc632a3211e752ed0c9ec4f82da authored about 5 years ago by James Mead <[email protected]>
Consistently use assert_raises

PR: #412

Closes #405.

a66b7bede17cd7e4f7dc185b9e9b1bac86b3eabb authored about 5 years ago by Nitish Rathi <[email protected]>
Pass invocation to expectation list methods

PR: #411

Closes #408 and #409.

Co-authored-by: Nitish Rathi <[email protected]>

c3d8b999350db9a35bc71c86b57e7019f0a4e81f authored about 5 years ago by James Mead <[email protected]>
Extract Expectation#verbose? method

a6850d999e0623334242fba9098058d59a815647 authored about 5 years ago by Nitish Rathi <[email protected]>
Extract Invocation#result_description method

a92cdc2ff0553d273547d1f30d5d9f4b9db1d6ae authored about 5 years ago by Nitish Rathi <[email protected]>
Reuse Invocation#call_description method in #full_description

To reduce duplication.

811dd80a965ee84527a79661ee6e923b0f893aa5 authored about 5 years ago by Nitish Rathi <[email protected]>
Improve naming of Invocation description methods

ed506a9c45376635e3c5022a48b33a71edc1ac23 authored about 5 years ago by Nitish Rathi <[email protected]>
Make Invocation description methods symmetric

b32007aa22939227efa5daf555ae8cb186756f3b authored about 5 years ago by Nitish Rathi <[email protected]>
Inline local vars in Invocation#full_description to reveal duplication

713facd39c268c508925049838fcedb9d8d75ae6 authored about 5 years ago by Nitish Rathi <[email protected]>
Move description methods from UnexpectedInvocation -> Invocation

And remove the now redundant UnexpectedInvocation class.

5fdc3da07daf272b3edb98f23864ff91e1fd4aad authored about 5 years ago by Nitish Rathi <[email protected]>
Reveal duplication in UnexpectedInvocation description methods

Note that eventually the plan is to remove the UnexpectedInvocation
class entirely and so that's...

3bf68b9367adfd9d7f29b42961432917fbc03239 authored about 5 years ago by Nitish Rathi <[email protected]>
Pass invocation into Expectation#invoke

71fa281f2d452cc9e465e41432471c2e767aeb16 authored about 5 years ago by Nitish Rathi <[email protected]>
Pass mock & method name into Invocation constructor

This is in preparation for passing Invocation to Expectation#invoke.

72f6401bbd719d86ef38728196790816e363faa0 authored about 5 years ago by Nitish Rathi <[email protected]>
Inline Expectation#method_name

This is a small step towards pushing more logic into the Invocation
class.

2f9ec4d867e1f3b9b96db75d533c1f40334edc79 authored about 5 years ago by James Mead <[email protected]>
Extract invocation into local variable in Mock#method_missing

44c78cefcf59edd538231121442f91d4ead84aae authored about 5 years ago by Nitish Rathi <[email protected]>
Pass invocation to ExpectationList#match

0deb490623be430ffc3a9b3c80b5536236850e17 authored about 5 years ago by Nitish Rathi <[email protected]>
Pass invocation to ExpectationList#match_allowing_invocation

9f654abe692dd5118fbcab91117769ab592282e1 authored about 5 years ago by Nitish Rathi <[email protected]>
Pass invocation to ExpectationList#matching_expectations

c1b12d8b29f073c852791d47ea890a8c1d2806e0 authored about 5 years ago by Nitish Rathi <[email protected]>
Temporarily make Invocation#arguments externally immutable

This is a step towards encapsulating the arguments entirely within the
Invocation class.

3f1b7699d6bb4a5c0641d2aadbd7fbeab21ec568 authored about 5 years ago by Nitish Rathi <[email protected]>
Pass Invocation to Expecation#match?

4c24a3c1f3f0a5b5c4418865c6e6b0fe94611687 authored about 5 years ago by Nitish Rathi <[email protected]>
Only need to use ParametersMatcher in Invocation#mocha_inspect

So move the instantiation of ParametersMatcher into that method.

ffb16e922272b23dcf2a940a3703b3bb63848bc5 authored about 5 years ago by James Mead <[email protected]>
Switch args for Invocation constructor & #call

This is in preparation for passing Invocation to ExpectationList
methods.

This also simplifies ...

a8f7d0ac1dc4fb1a7f5b4dcdbb2a9bce7bbaf5da authored about 5 years ago by Nitish Rathi <[email protected]>
Rename block argument in Invocation#call

feb9c070f18406878df2b4dd2ce87070603ec189 authored about 5 years ago by James Mead <[email protected]>
Encapsulate invocations inside cardinality

Also handles Expectaction#throws scenario.

PR: #410

Second bunch of commits from #394.

Co-aut...

44708253962238e7ecfb14701c908f7a4a8ad6be authored about 5 years ago by James Mead <[email protected]>
Record result of invocation before 'returning' it

This helps us avoid rescuing an exception raised by code elsewhere in
the Mocha code. Also, enab...

9e449b0c79d41d7045c49a1af648dfe89edcf31e authored about 5 years ago by Nitish Rathi <[email protected]>
Reduce test's knowledge of irrelevant details

ad0fa3c12769a2c16bf6d4619308a1619c85524d authored about 5 years ago by Nitish Rathi <[email protected]>
Cardinality#times is never invoked with 0

09742f1829f4db7c1b27e7c7e202cf5b8c66e2f3 authored about 5 years ago by Nitish Rathi <[email protected]>
Use same times logic for non-zero configured & invoked

4a311184f94ace902490d3f588631327dbe55f1b authored about 5 years ago by Nitish Rathi <[email protected]>
Encapsulate invocations inside Cardinality

e58de2b8bb0141d514deee322482bf09de590b92 authored about 5 years ago by Nitish Rathi <[email protected]>
Rename methods on Cardinality to better describe intention

expected hadn't quite sounded right because it also included allowed.

aa27319f18a95d6b40bd95644380caf0336b7b4c authored about 5 years ago by Nitish Rathi <[email protected]>
Simplify Cardinality#invoked_times

Using more expressive & concise conditionals & booleans.

54f38b079e726ff44f9d4dcde9ebe7c81a1f2c13 authored about 5 years ago by Nitish Rathi <[email protected]>
Interpolate vs append simple expressions in Expectation#mocha_inspect

b6d10dc543fb7732f8ca819da31546c4f9bca4cd authored about 5 years ago by Nitish Rathi <[email protected]>
Rename methods on Cardinality to better describe intention

e20cb8a5f13926f43521f521a55e25586a4f5e15 authored about 5 years ago by Nitish Rathi <[email protected]>
Rename methods on Cardinality to better describe intention

f87bf6c42f9646a9b20b0a5b50bbb170138dfc02 authored about 5 years ago by Nitish Rathi <[email protected]>
Use consistent phrasing for configured & invoked times

290f390ebdd5398c6188671d213317d96fe2316a authored about 5 years ago by Nitish Rathi <[email protected]>
Infer invocation count from invocations size

The target is to encapsulate it inside Cardinality in a tell-don't-ask
style.

836f85b8514c841781767c1d31e923af5074d4ae authored about 5 years ago by Nitish Rathi <[email protected]>
Move invocations list to Cardinality

The target is to encapsulate it inside Cardinality in a tell-don't-ask
style.

59454a83648f76e46918779f7dd39a34927cff2c authored about 5 years ago by Nitish Rathi <[email protected]>
Move invocation size based logic to Cardinality

Cardinality and invocations go hand-in-hand. So, the target is to move
invocations to Cardinality.

0f1478e2f284c7b867bf4154adeabffbd367e3c0 authored about 5 years ago by Nitish Rathi <[email protected]>
Prepare to move invocation size based logic to Cardinality

Cardinality and invocations go hand-in-hand. So, the target is to move
invocations to Cardinality.

862b08e307ead49ccf2291d1f18066b6c7728a6b authored about 5 years ago by Nitish Rathi <[email protected]>
Display matching invocations alongside expectations

First bunch of commits from #394.

Co-authored-by: Nitish Rathi <[email protected]>

00f05402960995d3f8c3ac91023ed45a3e1600c6 authored about 5 years ago by James Mead <[email protected]>
DRY up acceptance test for display matching invocations

Extract the assert_invocations method. Checking that invocations follow
'satisfied expectations:...

6ef520222d06f5988a415bc3bc9b9c214524e622 authored about 5 years ago by Nitish Rathi <[email protected]>
Replace invocation_count with invocations.size

Less state to maintain. Array#size is O(1), so should be fine
performance-wise.

c11c367df2c66e814addf0f849c5fc3a9a35a622 authored about 5 years ago by Nitish Rathi <[email protected]>
Reduce granularity and redundancy of tests

The tests were helpful for test-driving, but not all are needed due to
overlap.

e916363a11772a8c89cd70cdc2b6acd10eb7c3e4 authored about 5 years ago by Nitish Rathi <[email protected]>
Display arguments of matching invocations

Previously the expected arguments were being displayed here (using
Expectation#method_signature)...

64724c72a3876aac055ca5d2811a46d918229a0e authored about 5 years ago by Nitish Rathi <[email protected]>
Rename block arguments when calling invocation from Expectation#invoke

7a5fef9008dccadf7614326f04a1365483e8a513 authored about 5 years ago by James Mead <[email protected]>
Display yields of matching invocations

976705cb41d7201e07bc1c3ce01036fea405a1bb authored about 5 years ago by Nitish Rathi <[email protected]>
Move yielding to invocation

This will allow the yields to be captured and remembered by the invocation

2a79b6cd74193b031c36cf55da223f09ccdc41cc authored about 5 years ago by Nitish Rathi <[email protected]>
Prepare to display yields of invocations

Since an expectation can have multiple matching invocations, and an invocation
can yield multipl...

d50891344bdfd09da2f7617dbc7a2cb0b0df0469 authored about 5 years ago by Nitish Rathi <[email protected]>
Display exceptions raised from invocations

a9f16a80ab6a1ed1f4453dceb005f121a053344b authored about 5 years ago by Nitish Rathi <[email protected]>
Display return values of invocations

7f944998bb998a9ffd21e4f155451d169fe4134a authored about 5 years ago by Nitish Rathi <[email protected]>
Merge pull request #404 from freerange/distinguish-object-methods-modules

Distinguish different ObjectMethods modules

8536868997be05477a0f2696ddc02370d114fd5f authored about 5 years ago by James Mead <[email protected]>
Distinguish module defining mocha_inspect methods

Previously this Mocha::ObjectMethods module was re-opening the module
defined in `lib/mocha/obje...

537a74229e6dd238728454c9df9b1fa81892209c authored about 5 years ago by James Mead <[email protected]>
Distinguish module defining to_matcher method

Previously this Mocha::ObjectMethods module was re-opening the module
defined in `lib/mocha/obje...

ab619c863cc3928d5a79fd7bae333ab78752605a authored about 5 years ago by James Mead <[email protected]>
Merge pull request #402 from freerange/do-not-include-method-definer-into-all-objects

Do not include method definer into all objects

cc85f7c0eb652929adbf1d506f7315ccccea7b4e authored about 5 years ago by James Mead <[email protected]>
Avoid including MethodDefiner into the Object class

Instead we pass the object into the three MethodDefiner methods.

0da9fd49688d6699abc40e1bcff53dd62d589d6d authored about 5 years ago by James Mead <[email protected]>
Move MethodDefiner module out of Mocha namespace

Since this module is not used within the library itself, there's no need
to include it within th...

2aa0beef2447e14a7574c10647185ff209700a46 authored about 5 years ago by James Mead <[email protected]>
Rename module in test/method_definer.rb to MethodDefiner

This should help avoid confusion with the Mocha::ObjectMethods module
defined within the library...

9ada1983e5638ee81d0ed2edac222627351df8a0 authored about 5 years ago by James Mead <[email protected]>
Remove unnecessary require statements for test/method_definer.rb

4498dc9e1cca225518e0e19695713f48f4efaa14 authored about 5 years ago by James Mead <[email protected]>
Deprecate requiring 'mocha/setup'

By forcing people to require the explicit integrations for Test::Unit or
Minitest, we will be ab...

36adf880a0b9302fb5e770161c2e962e7e20fe71 authored about 5 years ago by James Mead <[email protected]>
Make signatures of {Mock,ObjectMethods}#unstub consistent

f04d4377bfd7398a3f238fda9fabd1b70e547100 authored about 5 years ago by Nitish Rathi <[email protected]>
Fix deprecation warnings added in #389

These were not namespaced and it turns out they aren't actually tested
in the build.

2406544dc206bfad7fc9526d771f682e86f2e4d9 authored about 5 years ago by James Mead <[email protected]>
require at least one specified sequence for in_sequence

9020248aae00303885dc6804be832714b7ddab47 authored about 5 years ago by Nitish Rathi <[email protected]>
Warn if integration using mocha/{test_unit,minitest} fails

This is a deprecation warning for the moment, but it would be good to
fail fast by raising an ex...

c6032d0bbfe6bb64295f9d98e94ff9814085154e authored about 5 years ago by Nitish Rathi <[email protected]>
Add documentation to explain how Mocha is intended to be used

It's useful for the Mocha documentation to point out the different types of Test
Double and that...

10b8d9b27b3d320238bf74778e431100dbff2331 authored about 5 years ago by Nitish Rathi <[email protected]>
Don't over-write definition of singleton_class

Introduce stubba_class method as part of the contract between Mockery and the
object being stubbed.

e49d214a8f0f6d2bd5777e63e386f0bcd4179286 authored about 5 years ago by Nitish Rathi <[email protected]>
Document MOCHA_OPTIONS in README

3bac52c52f8deb3b248a8d6aebf1b821a7ffbe30 authored about 5 years ago by Nitish Rathi <[email protected]>
Make yields fail when the caller does not provide a block

PR: #382 by @nitishr

e9e117e6daf5bbf3e08ed7511ede4df2c6d612bf authored about 5 years ago by James Mead <[email protected]>
Refactor: inline simple expressions to prep to add new test

Adding a new test triggers Metrics/ClassLength: Class has too many lines. So,
inlining the expec...

a7db797cf0cb249749f577f12162961052cc14ff authored about 5 years ago by Nitish Rathi <[email protected]>
fail yields when the caller does not provide a block

This is more reasonable and realistic than yielding only if a block is given.
A stub that's set ...

455e0bbabf06d23132c0d4f96f5794b75f2a2c05 authored about 5 years ago by Nitish Rathi <[email protected]>
Simplify/consistent-ify ClassMethods#method_exists? & ObjectMethods#method_exists?

PR: #370 by @nitishr

Closes #270
Closes #362

068d6f743d0010b153c10d92ae5b644fc27677fe authored about 5 years ago by James Mead <[email protected]>
Refactor: delegate method_visibility to original_method_owner

Since original_method_owner is a class, it can already provide method_visibility
(through ClassM...

5bf8be914ab15a51815c4e0a722e05984df7760d authored about 5 years ago by Nitish Rathi <[email protected]>
Refactor: inline method_visibility to prep for rename to method_exists?

3c4e94f74a29a74e9319dd8b430b7e45712d4e81 authored about 5 years ago by Nitish Rathi <[email protected]>
Refactor: Further DRY up checks for actions (allow/prevent/warn)

on_stubbing_method_unnecessarily differs only in how the method_signature and
backtrace are comp...

cd47bbf8c17b1b945d10b3899fb0a2bce801154c authored about 5 years ago by Nitish Rathi <[email protected]>
Refactor: inline method_exists_or_responds_to?

It was originally extracted to please rubocop, as it complained about cyclomatic
complexity bein...

eccb8a26bcc0ad20770d4c475f24986b75123ebf authored about 5 years ago by Nitish Rathi <[email protected]>
Refactor: DRY checks for actions (allow/prevent/warn)

e83d0ff56537369178c2d321eed12c44c79f392b authored about 5 years ago by Nitish Rathi <[email protected]>
Refactor: inline method as body is almost as intention-revealing as method

bf79f3b487adc97b4968aa321b4070b249fc5723 authored about 5 years ago by Nitish Rathi <[email protected]>
Refactor: remove alias as it isn't much more intention-revealing than original

ca58f1289e5e8a861ff5b8878c4f48e02e1a1c6e authored about 5 years ago by Nitish Rathi <[email protected]>
Refactor: rename method_visibility to method_exists? to better reveal intent

0d9400dadd8b40fe7b939505d0f091160e8f3281 authored about 5 years ago by Nitish Rathi <[email protected]>