minitest-firemock 0.0.1 → 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,4 @@
1
+ rvm:
2
+ - 1.9.2
3
+ - 1.9.3
4
+ - ruby-head
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
@@ -12,3 +12,5 @@ Rake::TestTask.new do |t|
12
12
  t.verbose = true
13
13
  t.warning = true
14
14
  end
15
+
16
+ task default: :test
@@ -9,10 +9,15 @@ class MiniTest::FireMock < MiniTest::Mock
9
9
  end
10
10
 
11
11
  def expect(name, retval, args = [])
12
- if @constant and not @constant.instance_methods.include? name
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
 
@@ -1,6 +1,6 @@
1
1
  # -*- encoding: utf-8 -*-
2
2
  Gem::Specification.new do |gem|
3
- gem.version = '0.0.1'
3
+ gem.version = '0.0.2'
4
4
 
5
5
  gem.authors = ["Cainã Costa"]
6
6
  gem.email = ["cainan.costa@gmail.com"]
@@ -1,5 +1,4 @@
1
1
  require 'minitest/unit'
2
- require 'minitest/fire_mock'
3
2
 
4
3
  MiniTest::Unit.autorun
5
4
 
@@ -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.1
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-08 00:00:00.000000000Z
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.10
48
+ rubygems_version: 1.8.7
48
49
  signing_key:
49
50
  specification_version: 3
50
51
  summary: Makes your MiniTest mocks more resilient.