minitest-firemock 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/.travis.yml +4 -0
- data/README.md +1 -2
- data/Rakefile +2 -0
- data/lib/minitest/fire_mock.rb +6 -1
- data/minitest-firemock.gemspec +1 -1
- data/test/test_helper.rb +0 -1
- data/test/unit/firemock_test.rb +7 -0
- metadata +4 -3
data/.travis.yml
ADDED
data/README.md
CHANGED
@@ -28,11 +28,10 @@ class MyOtherClassTest < MiniTest::Unit::TestCase
|
|
28
28
|
end
|
29
29
|
```
|
30
30
|
|
31
|
-
The only real difference of using `MiniTest::FireMock` instead of `MiniTest::Mock` is that if `MyClass` is defined, and `my_method` isn't there, it'll raise a `MockExpectationError`.
|
31
|
+
The only real difference of using `MiniTest::FireMock` instead of `MiniTest::Mock` is that if `MyClass` is defined, and `my_method` isn't there, it'll raise a `MockExpectationError`. It checks also for the arity of the method, so it'll raise a `MockExpectationError` if the real method have a different arity than the expectation.
|
32
32
|
|
33
33
|
TODO
|
34
34
|
----
|
35
35
|
|
36
|
-
- Check for the arity of the methods if they are defined.
|
37
36
|
- Mock class/module methods too.
|
38
37
|
- Make it work with method_missing (as of now it doesn't, even if the #responds_to? is correct)
|
data/Rakefile
CHANGED
data/lib/minitest/fire_mock.rb
CHANGED
@@ -9,10 +9,15 @@ class MiniTest::FireMock < MiniTest::Mock
|
|
9
9
|
end
|
10
10
|
|
11
11
|
def expect(name, retval, args = [])
|
12
|
-
|
12
|
+
method = @constant.instance_method(name) rescue nil
|
13
|
+
if @constant and not method
|
13
14
|
raise MockExpectationError, "expected #{@constant_name} to define `#{name}`, but it doesn't"
|
14
15
|
end
|
15
16
|
|
17
|
+
if method and method.arity != args.size
|
18
|
+
raise MockExpectationError, "`#{name}` expects #{method.arity} arguments, given #{args.size}"
|
19
|
+
end
|
20
|
+
|
16
21
|
super(name, retval, args)
|
17
22
|
end
|
18
23
|
|
data/minitest-firemock.gemspec
CHANGED
data/test/test_helper.rb
CHANGED
data/test/unit/firemock_test.rb
CHANGED
@@ -43,4 +43,11 @@ class FireMockTest < MiniTest::Unit::TestCase
|
|
43
43
|
mock.expect(:not_defined_method, 42)
|
44
44
|
end
|
45
45
|
end
|
46
|
+
|
47
|
+
def test_valid_mock_with_different_arity
|
48
|
+
mock = MiniTest::FireMock.new('DefinedConstant')
|
49
|
+
assert_raises MockExpectationError, "`defined_method` expects 0 arguments, given 3" do
|
50
|
+
mock.expect(:defined_method, 42, [1,2,3])
|
51
|
+
end
|
52
|
+
end
|
46
53
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: minitest-firemock
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2011-10-
|
12
|
+
date: 2011-10-10 00:00:00.000000000Z
|
13
13
|
dependencies: []
|
14
14
|
description: Makes your MiniTest mocks more resilient.
|
15
15
|
email:
|
@@ -18,6 +18,7 @@ executables: []
|
|
18
18
|
extensions: []
|
19
19
|
extra_rdoc_files: []
|
20
20
|
files:
|
21
|
+
- .travis.yml
|
21
22
|
- README.md
|
22
23
|
- Rakefile
|
23
24
|
- lib/minitest/fire_mock.rb
|
@@ -44,7 +45,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
44
45
|
version: '0'
|
45
46
|
requirements: []
|
46
47
|
rubyforge_project:
|
47
|
-
rubygems_version: 1.8.
|
48
|
+
rubygems_version: 1.8.7
|
48
49
|
signing_key:
|
49
50
|
specification_version: 3
|
50
51
|
summary: Makes your MiniTest mocks more resilient.
|