github.com/freerange/mocha
A mocking and stubbing library for Ruby
https://github.com/freerange/mocha
Since a method exists (or not) on a class, and an object responds (or not) to a
message, Mockery...
848bea9719982a20162d32fbb4584531d89eef8e authored almost 6 years ago
Makes ObjectMethods#method_exists? more similar to ClassMethods#method_exists?
55b3395c9df679dfcc00a7e06e660fbabb5d56dd authored almost 6 years agod2ed1a84e090f46b21435d87ad1359de117ddf8b authored almost 6 years ago
948b8b81e5c9aeefe028890624adff795d04fd13 authored almost 6 years ago
Makes AnyInstance#method_exists? more similar to ObjectMethods#method_exists?
5de8e6bbd49ecd803002890ec41bce9e3f2d4451 authored almost 6 years agoBoolean expressions are declarative while conditional returns are imperative
06f79d3c34193fee32887121d3bc203cfe3321db authored almost 6 years ago
respond_to? was called only in the if include_public_methods conditional, and
this is the only...
48070db7f49231efe41d4c5359def8c9f9100027 authored almost 6 years ago
Since a method exists (or not) on a class, and an object responds (or not) to a
message, Mockery...
c8b4441acdb1cc918c550991514ff040299af0e2 authored almost 6 years ago
d041cdc25c068115166069b4bfbaf0975ea8debb authored almost 6 years ago
Makes AnyInstance#method_exists? more similar to ClassMethod#method_visibility
3c9f60f3df4c5a714377ed54d86aae0504731b62 authored almost 6 years ago6e50d3818607066d2158a8a6d8313d49dd875f97 authored almost 6 years ago
Boolean expressions are declarative, while conditional returns are imperative.
This makes method...
Make the chainability to #mock and #stub clearer
54dd07521110caa4647b7bb11efc7e49c670f23a authored almost 6 years agoc16848348213a911d923892a2831d5bef7594955 authored almost 6 years ago
Simplify {AnyInstance,Class,Instance,Module}Methods Hierarchy
706effdd7a45b6684f4d7a87e81b7313a13f46bc authored almost 6 years ago
Parameterizing (& generalizing) the methods allows us to reduce the implicit
dependency/contract...
ec8ab787cd42217047be43e117d704435814a1f3 authored almost 6 years ago
This reduces duplication in InstanceMethod & AnyInstanceMethod (assignment to
ivar), and shrinks...
Since original_method_owner returns stubbee anyway. This makes it similar in
InstanceMethod and ...
Since there're only two subclasses of StubbedMethod, I didn't see a reason to
privilege methods ...
ClassMethod is/was being used solely as a superclass of InstanceMethod and
AnyInstanceMethod, an...
ObjectMethods#stubba_method is identical, and is already included in Object.
Since a Class is an...
ObjectMethods provides everything that ModuleMethods did, and is already
included in Object. Sin...
Since the two aren't different from each other or from ModuleMethod
6d9417e3fcfbed848b29a7fdd2a6af638983d19c authored almost 6 years agoSince the two aren't any different from each other or from ClassMethod
87ee1777dc174c7b1b548eebe58d30e62c81c3f4 authored almost 6 years agoReduce duplication in AnyInstanceMethod class
6f36b5b04c3101c77c84bcfc4bde9becff10a1c0 authored almost 6 years agoThe following methods are overridden in AnyInstanceMethod:
* mock_owner
* original_method_body
...
Now there's only a single implementation and it's only a few lines long,
it makes more sense to ...
The implementation is now identical to that in ClassMethod and so we can
safely remove this and ...
It's simplier to obtain the mock underlying the stubbed method from the
instance of ClassMethod ...
The implementations of AnyInstanceMethod#mock & #reset_mocha are now identical
to those of Class...
Reduce duplication by extracting ClassMethod#mock_owner and
AnyInstanceMethod#mock_owner.
Co-au...
033ee48faf8721228a7eabcf2d4b041fed8b0aaa authored almost 6 years agoCo-authored-by: James Mead <[email protected]>
6a16ccf02f0b538a461b44c61c1d6f89c7d471e7 authored almost 6 years ago
Using define_method is safer than class_eval and it has the side effect
of making it easier to s...
This is now identical to ClassMethod#restore_original_method and so in
AnyInstanceMethod we can ...
This means that ClassMethod#restore_original_method and
AnyInstanceMethod#restore_original_metho...
Co-authored-by: James Mead <[email protected]>
220c5d61ec3a59865fe66ccbf373b0311579e0bc authored almost 6 years ago
This fixes a bug in AnyInstanceMethod where it would fail to restore the
visibility of a stubbed...
This also has the benefit of making
AnyInstanceMethod#restore_original_method more similar to
Cl...
This also has the benefit of making ClassMethod#restore_original_method
more similar to AnyInsta...
Accept symbol as mock/stub name
b97766000a176bd5c98f91ea1e709b49cab579ee authored almost 6 years ago4e2f77598c37e2e439962d51954c7f703324a130 authored almost 6 years ago
7ed2e4e76f364be13f8d8b7fe618e569b3e98562 authored almost 6 years ago
There's no need to run rubocop in so many of the CI matrix builds.
Running rubocop on Truffle Ru...
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
This is because minitest > v5.11.3 uses look-behind assertions in regular
expressions which are ...
PR: #365
c34f9af57cf7955c40d7f1662b9cc37c14544f86 authored about 6 years ago
The singleton_class method has been available since Ruby v1.9.2 and so
it seems better to avoid ...
It's vaguely conceivable that tests in the wild are stubbing this method
and so it seems safer t...
As per 9c78af7529d34d8cf5bd4a26999124a8d684b2ed.
793c96813336df9d18dc09d3f4abe7071cac4617 authored about 6 years agoAs per 5aac8b9e4dc8335e30de426ca103678fddcd90dc.
9c78af7529d34d8cf5bd4a26999124a8d684b2ed authored about 6 years agoThese changes should've been made in this commit [1].
[1]: https://github.com/freerange/mocha/c...
6fabe2b66a5c001c0b73923eb8a141962b63cb07 authored about 6 years ago10222e8c1aa82f5fe1ba4172acfd0494c1c0d197 authored about 6 years ago
These changes should've been made in this commit [1].
[1]: https://github.com/freerange/mocha/c...
9ff1e8f1692e0e7842b5dea800384566a14087a8 authored about 6 years ago0b81b2c7d288390841d5aada35d7e2a806f30f86 authored about 6 years ago
I've made this a minor version bump, because there's a chance the
refactoring in #358 may have l...
As per this commit [1].
[1]: 3352e9c5acc11d56198b5cf4b489156ff7ad5c34
8247a8940b14e929f0ecb4e50af7982f7ee58399 authored about 6 years agoThis problem was introduced in this commit [1].
[1]: 330e3f5798a428f0c100b4d7d4cec2b1545b17ea
11abe231409a33986ea6d81d4e8007b1a7986959 authored about 6 years ago
In this commit [1], I added a before_install entry to the Travis CI
configuration to install the...
PR: #358
Co-authored-by: Chris Roos <[email protected]>
c8562ef42db22e80d256869405eeba258cc1b9aa authored about 6 years ago
Note the use of `original_method_in_scope` in
`ClassMethod#restore_original_method`. I can't use...
And the overridden implementation in
`AnyInstanceMethod#restore_original_method`. By reusing
`#o...
To try to better describe its purpose.
4b8075c479dc67f1697d807ad6d2a86df4f0111b authored about 6 years ago
Now that the implementation is the same as its parent's in
`ClassMethod#method_visibility`.
Now that the implementation is the same as its parent's (`ClassMethod`).
0ff0fe849bb54f0b0d456b5b5b0ac10df5b79435 authored about 6 years ago
The `xxx_method_defined?` methods accept either a symbol or string so
we don't need to manually ...
This makes the implementation of `AnyInstanceMethod#method_visibility`
the same as `ClassMethod#...
And the equivalent method in
`AnyInstanceMethod#default_stub_method_owner`.
I think this name m...
a3216ae5a96e363349dadaa0ccb85a00cc9ca47a authored about 6 years ago
In the hope that it makes the code easier to understand. I found it confusing
that we were using...
And the equivalent method in `AnyInstanceMethod#method_visibility`.
The instances of `ClassMeth...
9341dc27d164e1f56c67687ce21a039cffee4567 authored about 6 years agof22fd8cea34225c0d4a4cedaff11a75ba1f64547 authored about 6 years ago
Now that the implementation is the same as its parent's (`ClassMethod`).
08dc507cee41c7e9e5a44e91ada5bf6f048efcdf authored about 6 years ago
The old name was slightly confusing because we're actually interested in
whether the original me...
Having temporarily removed the `rescue` statement, I can see that we're
trying to catch `NameErr...
098a3292151ec4f75024ed60c4e8bafefb54fd51 authored about 6 years ago
And the equivalent method in `AnyInstanceMethod#original_method`.
The instances of `ClassMethod...
0e58584a9b7b05f14a7a2e7c6928e893c0171968 authored about 6 years ago
To explain why we're interested in Ruby version 2 and above. I think
this makes the code easier ...
Given that it's identical to the same method in its parent
(`ClassMethod`).
And override the implementation in `AnyInstanceMethod#prepend_module`.
I want to make the imple...
3623ab1f52191d360ac0ed4ee5698af1353c66f0 authored about 6 years agoAnd override the implementation in `AnyInstanceMethod#original_method`.
I want to make the impl...
86e203c8cb4573a76c384e88898d5e70daeac6d7 authored about 6 years ago
And override the implementation in
`AnyInstanceMethod#original_method_defined_on_stubbee?`.
I w...
bf23d4443dc2aaf65c6e56b5bedc2effdde951a6 authored about 6 years ago
We use `class_eval` in both `ClassMethod#define_new_method` and
`AnyInstanceMethod#define_new_me...
Now that it's identical to the same method in its parent
(`ClassMethod`).
I think the new name better describes its purpose.
7f9d8f8ddfd092778997fae989ad358cbabd6f8e authored about 6 years ago
Now that it's identical to the same method in its parent
(`ClassMethod`).
e5521209a5abb308d025b740c5e9d2d5e0a9ccff authored about 6 years ago
And override the implementation in
`AnyInstanceMethod#default_definition_target`.
I want to mak...
6a29f9e83b0b621a7997562dbb06f5f24015a193 authored about 6 years agoAs well as method parameters named `method`.
To make it clearer that it's a string/symbol and n...
065134915f7544aef49a954efaf3b077ba8e5a8f authored about 6 years ago
Now that it's identical to the same method in its parent
(`ClassMethod`).
And override the implementation in
`AnyInstanceMethod#stub_method_definition`.
I want to make t...
721a910b8cb0879265aff5f930a171d0189a22db authored about 6 years agoI think the new name better describes its purpose.
ff1560b28f63f3e2120fe2ab493acc19b02928ab authored about 6 years agoNow that the implementation is the same as its parent's.
ebb046182ee1547b1ac731afc1f363c594e48934 authored about 6 years ago
And override the implementation in
`AnyInstanceMethod#remove_original_method_from_stubbee`.
I w...
c40d96e45f3c0cbad8a2408469857290ed85b0ac authored about 6 years agoExpand explanation of thread-safety concerns
172380e373de0d759be2058f0b4322d78857c2d3 authored about 6 years agoad4cbd27e2881712a808cec963e8f3262c3a3a6e authored about 6 years ago
Travis CI started switching the default OS to Linux Xenial 16.04 on 23
Apr 2019 [1]. It looks as...
Run tests in TruffleRuby in Travis CI
d986fd2de2f2b896d876e1a4108694d628aa6895 authored over 6 years ago