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

Refactor: prepare to call method_exists? directly on object's singleton_class

Since a method exists (or not) on a class, and an object responds (or not) to a
message, Mockery...

f016fcd154388c8c3582e9955a86eef5736e9532 authored almost 6 years ago
Refactor: make {AnyInstance,ObjectMethods}#method_exists? identical

848bea9719982a20162d32fbb4584531d89eef8e authored almost 6 years ago
Refactor: use more direct & intention-revealing methods

Makes ObjectMethods#method_exists? more similar to ClassMethods#method_exists?

55b3395c9df679dfcc00a7e06e660fbabb5d56dd authored almost 6 years ago
Refactor: rename & alias method_exists? to reflect different intended usages

d2ed1a84e090f46b21435d87ad1359de117ddf8b authored almost 6 years ago
Refactor: method_exists? returns visibility to look similar to method_visibility

948b8b81e5c9aeefe028890624adff795d04fd13 authored almost 6 years ago
Refactor: extract method

Makes AnyInstance#method_exists? more similar to ObjectMethods#method_exists?

5de8e6bbd49ecd803002890ec41bce9e3f2d4451 authored almost 6 years ago
Refactor: Replace conditional return with a single boolean expression

Boolean expressions are declarative while conditional returns are imperative

06f79d3c34193fee32887121d3bc203cfe3321db authored almost 6 years ago
Refactor: Move respond_to? check to the only caller site using it in effect

respond_to? was called only in the if include_public_methods conditional, and
this is the only...

690f32ac0c0bc1efc9b00a1685c6b1b88b37d41d authored almost 6 years ago
Refactor: remove redundant override AnyInstance#method_exists?

48070db7f49231efe41d4c5359def8c9f9100027 authored almost 6 years ago
Refactor: call method_exists? directly on object's singleton_class

Since a method exists (or not) on a class, and an object responds (or not) to a
message, Mockery...

89b0d25b8e9ae33f2e373dd38e8da7a35d90c2c8 authored almost 6 years ago
Refactor: Make respond_to? public to prep for calling from outside

c8b4441acdb1cc918c550991514ff040299af0e2 authored almost 6 years ago
Refactor: extract method to prep for adding respond_to? check to Mockery

d041cdc25c068115166069b4bfbaf0975ea8debb authored almost 6 years ago
Refactor: use more direct & intention-revealing methods

Makes AnyInstance#method_exists? more similar to ClassMethod#method_visibility

3c9f60f3df4c5a714377ed54d86aae0504731b62 authored almost 6 years ago
Refactor: delegate to ClassMethods by extracting & moving

6e50d3818607066d2158a8a6d8313d49dd875f97 authored almost 6 years ago
Refactor: replace conditional returns with single boolean expression

Boolean expressions are declarative, while conditional returns are imperative.
This makes method...

4499c036a0f6895aaff7348abf8c5f8c4e6ef3c3 authored almost 6 years ago
Improve documentation for responds_like{,_instance_of}

Make the chainability to #mock and #stub clearer

54dd07521110caa4647b7bb11efc7e49c670f23a authored almost 6 years ago
More realistic examples for yields and multiple_yields

c16848348213a911d923892a2831d5bef7594955 authored almost 6 years ago
Merge pull request #381 from nitishr/class_method

Simplify {AnyInstance,Class,Instance,Module}Methods Hierarchy

706effdd7a45b6684f4d7a87e81b7313a13f46bc authored almost 6 years ago
Refactor: shrink surface between StubbedMethod & subclasses

Parameterizing (& generalizing) the methods allows us to reduce the implicit
dependency/contract...

bdb4169c253466b25d20c9f8cd3de9682de4259a authored almost 6 years ago
Refactor: conditional is simple & short enough to be a one-liner

ec8ab787cd42217047be43e117d704435814a1f3 authored almost 6 years ago
Refactor: pull up store_original_method

This reduces duplication in InstanceMethod & AnyInstanceMethod (assignment to
ivar), and shrinks...

2df0aea6b71c4675365210d685d03844900484f7 authored almost 6 years ago
Refactor: obtain method from stubbee instead of original_method_owner

Since original_method_owner returns stubbee anyway. This makes it similar in
InstanceMethod and ...

a43a554d1613e7697f7230fa0ae7598ad593552a authored almost 6 years ago
Refactor: push down subclass-specific methods to subclass

Since there're only two subclasses of StubbedMethod, I didn't see a reason to
privilege methods ...

ad4304ffe17ecd267c2fc598cfdd2889a7972dbd authored almost 6 years ago
Refactor: rename ClassMethod to StubbedMethod

ClassMethod is/was being used solely as a superclass of InstanceMethod and
AnyInstanceMethod, an...

a64200747d35156eb157c35d835493c5814596cd authored almost 6 years ago
Refactor: delete ClassMethods#stubba_method

ObjectMethods#stubba_method is identical, and is already included in Object.
Since a Class is an...

abc29ec2cfe8a3fe70feb7aa91fee19b93f43ca1 authored almost 6 years ago
Refactor: delete ModuleMethods, relying on ObjectMethods

ObjectMethods provides everything that ModuleMethods did, and is already
included in Object. Sin...

6d99a2413e4ecce60a40029e8b139fcfc50ae839 authored almost 6 years ago
Refactor: Use InstanceMethod instead of ClassMethod

Since the two aren't different from each other or from ModuleMethod

6d9417e3fcfbed848b29a7fdd2a6af638983d19c authored almost 6 years ago
Refactor: Use InstanceMethod instead of ModuleMethod

Since the two aren't any different from each other or from ClassMethod

87ee1777dc174c7b1b548eebe58d30e62c81c3f4 authored almost 6 years ago
Merge pull request #378 from nitishr/reduce-duplication-in-any-instance-method-class

Reduce duplication in AnyInstanceMethod class

6f36b5b04c3101c77c84bcfc4bde9becff10a1c0 authored almost 6 years ago
Refactor: Keep overridden methods together in ClassMethod

The following methods are overridden in AnyInstanceMethod:

* mock_owner
* original_method_body
...

9baa0dcded24852726ba88b01b05a990ce735bd9 authored almost 6 years ago
Refactor: Inline ClassMethod#stub_method_body

Now there's only a single implementation and it's only a few lines long,
it makes more sense to ...

828a713a6d71a3e8eb3e25e9f3308d8bd9a1e86c authored almost 6 years ago
Refactor: Remove redundant AnyInstanceMethod#stub_method_body

The implementation is now identical to that in ClassMethod and so we can
safely remove this and ...

84ab371b9d3b0d2d8577b1367095420d2e31b4b8 authored almost 6 years ago
Refactor: Simplify stub_method_body on ClassMethod & AnyInstanceMethod

It's simplier to obtain the mock underlying the stubbed method from the
instance of ClassMethod ...

d8227f57d1ffbdc088ee552de335cef9d8d05f54 authored almost 6 years ago
Refactor: Remove redundant AnyInstance methods

The implementations of AnyInstanceMethod#mock & #reset_mocha are now identical
to those of Class...

c55b733770c69ca7f07790ba4cbb2a5df29ab30f authored almost 6 years ago
Refactor: Extract method in ClassMethod & AnyInstanceMethod

Reduce duplication by extracting ClassMethod#mock_owner and
AnyInstanceMethod#mock_owner.

Co-au...

033ee48faf8721228a7eabcf2d4b041fed8b0aaa authored almost 6 years ago
Refactor: Extract method to retain original visibility

Co-authored-by: James Mead <[email protected]>

6a16ccf02f0b538a461b44c61c1d6f89c7d471e7 authored almost 6 years ago
Refactor: define_method vs class_eval in ClassMethod#define_new_method

Using define_method is safer than class_eval and it has the side effect
of making it easier to s...

8a8e30d60d0b055b801a66c4d79ac233478c26b0 authored almost 6 years ago
Refactor: Remove redundant AnyInstanceMethod#restore_original_method

This is now identical to ClassMethod#restore_original_method and so in
AnyInstanceMethod we can ...

c26fb27ae88994312df14c54b0da00cb8ac68b05 authored almost 6 years ago
Refactor: Extract variation into a private method

This means that ClassMethod#restore_original_method and
AnyInstanceMethod#restore_original_metho...

919b7a29770138afebf7d30b30d2dfc3e6a71682 authored almost 6 years ago
Refactor: Extract variation into a local variable

Co-authored-by: James Mead <[email protected]>

220c5d61ec3a59865fe66ccbf373b0311579e0bc authored almost 6 years ago
Fix: Bug in AnyInstanceMethod#restore_original_method

This fixes a bug in AnyInstanceMethod where it would fail to restore the
visibility of a stubbed...

0407630b92ca34b27471b3cb0903acca31650006 authored almost 6 years ago
Refactor: Convert guard condition into if statement

This also has the benefit of making
AnyInstanceMethod#restore_original_method more similar to
Cl...

ad835dea712e88796099582f3308866dddb4aaa6 authored almost 6 years ago
Refactor: Call ClassMethod#original_method_owner to reduce duplication

This also has the benefit of making ClassMethod#restore_original_method
more similar to AnyInsta...

90cd9fc8460c411d960a238cee872a892b8945f9 authored almost 6 years ago
Merge pull request #377 from nitishr/mock-symbol-name

Accept symbol as mock/stub name

b97766000a176bd5c98f91ea1e709b49cab579ee authored almost 6 years ago
reuse mock creation, customize behavior by yielding

4e2f77598c37e2e439962d51954c7f703324a130 authored almost 6 years ago
accept symbol as mock/stub name

7ed2e4e76f364be13f8d8b7fe618e569b3e98562 authored almost 6 years ago
Only run rubocop for MRI Ruby versions & non-integration test builds

There's no need to run rubocop in so many of the CI matrix builds.
Running rubocop on Truffle Ru...

8f1c6af59866151be9a4d4cac85dd2315674ba3a authored almost 6 years ago
Upgrade JRuby to v9.2.8.0 in Travis CI builds

Release: https://www.jruby.org/2019/08/12/jruby-9-2-8-0.html

Note that there was a problem with...

aa29b3f169a9591e20aa60a39e8797d35713abb8 authored almost 6 years ago
Pin minitest to v5.11.3 for Ruby v1.8.7 to fix build

This is because minitest > v5.11.3 uses look-behind assertions in regular
expressions which are ...

4a0a580d1640e12a96bfdd893d5d835711e624e8 authored almost 6 years ago
Remove dependency on metaclass gem

PR: #365

c34f9af57cf7955c40d7f1662b9cc37c14544f86 authored about 6 years ago
Remove dependency on metaclass gem

The singleton_class method has been available since Ruby v1.9.2 and so
it seems better to avoid ...

e3db6e608c0b98ddcfc0c1f540d508004cde55bd authored about 6 years ago
Allow stubbing of Object#singleton_class

It's vaguely conceivable that tests in the wild are stubbing this method
and so it seems safer t...

5393163e5a00e4d47c121ae945139175307f2fb4 authored about 6 years ago
Automatically re-add docs CNAME when generating docs

As per 9c78af7529d34d8cf5bd4a26999124a8d684b2ed.

793c96813336df9d18dc09d3f4abe7071cac4617 authored about 6 years ago
Re-add CNAME for documentation

As per 5aac8b9e4dc8335e30de426ca103678fddcd90dc.

9c78af7529d34d8cf5bd4a26999124a8d684b2ed authored about 6 years ago
Update Google Analytics instructions in README

These changes should've been made in this commit [1].

[1]: https://github.com/freerange/mocha/c...

6fabe2b66a5c001c0b73923eb8a141962b63cb07 authored about 6 years ago
Update documentation in preparation for release of v1.9.0

10222e8c1aa82f5fe1ba4172acfd0494c1c0d197 authored about 6 years ago
Update Google Analytics property ID in README

These changes should've been made in this commit [1].

[1]: https://github.com/freerange/mocha/c...

9ff1e8f1692e0e7842b5dea800384566a14087a8 authored about 6 years ago
Remove trailing whitespace from README

0b81b2c7d288390841d5aada35d7e2a806f30f86 authored about 6 years ago
Prepare to release v1.9.0

I've made this a minor version bump, because there's a chance the
refactoring in #358 may have l...

64d246ab6f8343bfa6c833e75ff6f2fe4ea67c4b authored about 6 years ago
No need to install latest bundler in build-matrix script

As per this commit [1].

[1]: 3352e9c5acc11d56198b5cf4b489156ff7ad5c34

8247a8940b14e929f0ecb4e50af7982f7ee58399 authored about 6 years ago
Fix build-matrix script

This problem was introduced in this commit [1].

[1]: 330e3f5798a428f0c100b4d7d4cec2b1545b17ea

11abe231409a33986ea6d81d4e8007b1a7986959 authored about 6 years ago
Rely on default bundler version in Travis CI builds

In this commit [1], I added a before_install entry to the Travis CI
configuration to install the...

3352e9c5acc11d56198b5cf4b489156ff7ad5c34 authored about 6 years ago
Refactor class method and any instance method

PR: #358

Co-authored-by: Chris Roos <[email protected]>

c8562ef42db22e80d256869405eeba258cc1b9aa authored about 6 years ago
Encapsulate access to @original_method

Note the use of `original_method_in_scope` in
`ClassMethod#restore_original_method`. I can't use...

189c6157bed9017071b6ec07faddfb31e700d742 authored about 6 years ago
DRY up ClassMethod#restore_original_method

And the overridden implementation in
`AnyInstanceMethod#restore_original_method`. By reusing
`#o...

5ccdf3b351c225799d61b1970bc234eca1e9050b authored about 6 years ago
Rename ClassMethod#prepend_module

To try to better describe its purpose.

4b8075c479dc67f1697d807ad6d2a86df4f0111b authored about 6 years ago
Remove AnyInstanceMethod#method_visibility

Now that the implementation is the same as its parent's in
`ClassMethod#method_visibility`.

0d070fd80d542f2a2ff81b2b654e0f91758ab770 authored about 6 years ago
Remove AnyInstanceMethod#remove_original_method_from_stubbee

Now that the implementation is the same as its parent's (`ClassMethod`).

0ff0fe849bb54f0b0d456b5b5b0ac10df5b79435 authored about 6 years ago
Avoid unnecessary symbol var in ClassMethod#method_visibility

The `xxx_method_defined?` methods accept either a symbol or string so
we don't need to manually ...

970502896d8e27696bf66886e84d1e5f5c43984e authored about 6 years ago
Unify method_visibility method definitions

This makes the implementation of `AnyInstanceMethod#method_visibility`
the same as `ClassMethod#...

0f07f8cd54117678e0564110afb979d72fe26579 authored about 6 years ago
Rename ClassMethod#default_stub_method_owner

And the equivalent method in
`AnyInstanceMethod#default_stub_method_owner`.

I think this name m...

a3216ae5a96e363349dadaa0ccb85a00cc9ca47a authored about 6 years ago
Introduce method_defined_in_stubbee_or_in_ancestor_chain? alias

In the hope that it makes the code easier to understand. I found it confusing
that we were using...

e92f4317bc40b0664a17c9e19875a39efe00730c authored about 6 years ago
Avoid passing method_name to ClassMethod#method_visibility

And the equivalent method in `AnyInstanceMethod#method_visibility`.

The instances of `ClassMeth...

9341dc27d164e1f56c67687ce21a039cffee4567 authored about 6 years ago
Encapsulate access to @original_visibility

f22fd8cea34225c0d4a4cedaff11a75ba1f64547 authored about 6 years ago
Remove AnyInstanceMethod#original_method_defined_on_stubbee?

Now that the implementation is the same as its parent's (`ClassMethod`).

08dc507cee41c7e9e5a44e91ada5bf6f048efcdf authored about 6 years ago
Rename ClassMethod#original_method_defined_on_stubbee?

The old name was slightly confusing because we're actually interested in
whether the original me...

23bfbe3dfae5f8fd243de32a8ef066e90691c97a authored about 6 years ago
Reduce scope of rescue in ClassMethod#hide_original_method

Having temporarily removed the `rescue` statement, I can see that we're
trying to catch `NameErr...

8530f2961155c8cb53168020208d7e2cc9bd0e16 authored about 6 years ago
Avoid unnecessary metaclass var in ClassMethod#method_visibility

098a3292151ec4f75024ed60c4e8bafefb54fd51 authored about 6 years ago
Avoid passing method_name to ClassMethod#original_method

And the equivalent method in `AnyInstanceMethod#original_method`.

The instances of `ClassMethod...

0e58584a9b7b05f14a7a2e7c6928e893c0171968 authored about 6 years ago
Extract ClassMethod#use_prepended_module_for_stub_method?

To explain why we're interested in Ruby version 2 and above. I think
this makes the code easier ...

5a935ef078e4f25c1f91955d4a996df675f301b0 authored about 6 years ago
Remove AnyInstanceMethod#remove_new_method

Given that it's identical to the same method in its parent
(`ClassMethod`).

c602eeacdc303df764bb350bf945a92c5f431734 authored about 6 years ago
Extract ClassMethod#prepend_module

And override the implementation in `AnyInstanceMethod#prepend_module`.

I want to make the imple...

3623ab1f52191d360ac0ed4ee5698af1353c66f0 authored about 6 years ago
Extract ClassMethod#original_method

And override the implementation in `AnyInstanceMethod#original_method`.

I want to make the impl...

86e203c8cb4573a76c384e88898d5e70daeac6d7 authored about 6 years ago
Extract ClassMethod#original_method_defined_on_stubbee?

And override the implementation in
`AnyInstanceMethod#original_method_defined_on_stubbee?`.

I w...

bf23d4443dc2aaf65c6e56b5bedc2effdde951a6 authored about 6 years ago
Add tests for reporting filename and line number

We use `class_eval` in both `ClassMethod#define_new_method` and
`AnyInstanceMethod#define_new_me...

e6db194a3b3e7f2b4bfffcbaa2c4a8bd3cb88958 authored about 6 years ago
Remove AnyInstanceMethod#hide_original_method

Now that it's identical to the same method in its parent
(`ClassMethod`).

2451506c4142e3f2c2aa50caacec40b6481dae98 authored about 6 years ago
Rename ClassMethod#default_definition_target

I think the new name better describes its purpose.

7f9d8f8ddfd092778997fae989ad358cbabd6f8e authored about 6 years ago
Remove AnyInstanceMethod#definition_target

Now that it's identical to the same method in its parent
(`ClassMethod`).

be0cc3c1cbf9f495c89fda3c29db5917b2134e16 authored about 6 years ago
Use default_definition_target to DRY up code

e5521209a5abb308d025b740c5e9d2d5e0a9ccff authored about 6 years ago
Extract ClassMethod#default_definition_target

And override the implementation in
`AnyInstanceMethod#default_definition_target`.

I want to mak...

6a29f9e83b0b621a7997562dbb06f5f24015a193 authored about 6 years ago
Rename ClassMethod#method to #method_name

As well as method parameters named `method`.

To make it clearer that it's a string/symbol and n...

065134915f7544aef49a954efaf3b077ba8e5a8f authored about 6 years ago
Remove AnyInstanceMethod#define_new_method

Now that it's identical to the same method in its parent
(`ClassMethod`).

56005bf5b4ddc131f0352e78d3e011bf2557e5f2 authored about 6 years ago
Extract ClassMethod#stub_method_definition

And override the implementation in
`AnyInstanceMethod#stub_method_definition`.

I want to make t...

721a910b8cb0879265aff5f930a171d0189a22db authored about 6 years ago
Rename ClassMethod#definition_target

I think the new name better describes its purpose.

ff1560b28f63f3e2120fe2ab493acc19b02928ab authored about 6 years ago
Remove AnyInstanceMethod#prepend_module

Now that the implementation is the same as its parent's.

ebb046182ee1547b1ac731afc1f363c594e48934 authored about 6 years ago
Extract ClassMethod#remove_original_method_from_stubbee

And override the implementation in
`AnyInstanceMethod#remove_original_method_from_stubbee`.

I w...

c40d96e45f3c0cbad8a2408469857290ed85b0ac authored about 6 years ago
Merge pull request #357 from freerange/thread-safety-explanation

Expand explanation of thread-safety concerns

172380e373de0d759be2058f0b4322d78857c2d3 authored about 6 years ago
Expand explanation of thread-safety concerns

ad4cbd27e2881712a808cec963e8f3262c3a3a6e authored about 6 years ago
Explicitly set Travis CI OS to Ubuntu Trusty 14.04

Travis CI started switching the default OS to Linux Xenial 16.04 on 23
Apr 2019 [1]. It looks as...

ded1fa45929ef9761921e778a13b7a69db968a9b authored about 6 years ago
Merge pull request #354 from deepj/truffleruby

Run tests in TruffleRuby in Travis CI

d986fd2de2f2b896d876e1a4108694d628aa6895 authored over 6 years ago