minitest-rspec_mocks 0.2.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ec555958f3d7d82a5d2b7363c3d09737aff2f781
4
- data.tar.gz: 580ed80295ccbf05b31614d650345976f870d654
3
+ metadata.gz: 5688818ab7c483bc82c1b576c62c3e430c2a5538
4
+ data.tar.gz: 5171b53c75b39ef72dabd6f8ad5429cc8f5f28c7
5
5
  SHA512:
6
- metadata.gz: bba4f1199b2bbb5b9c8d0c4002033ba8538df01b7c0cb211a51a9557b9017d8e978f27f0a6ff20280e7714ce8c56746861c815932383390b43ee7256425fb153
7
- data.tar.gz: c213daf0809d295b6c598d34151c49914834f6bba4a53b3d096dc0feba343ffeae6dc5a92007c91c4b57ee1a411b5eab4ea56333fcfbfdbc4e1dbf4dccf3e249
6
+ metadata.gz: 06f55f50c10465979366edc5715509bf9319912eb4cf23d781e3ebd6b2454ede20c29ce413b05b9803dbd245ff2cf119c4bd7befa6d659a947f075ff8ced11eb
7
+ data.tar.gz: 09d4333f951a507b1450b0ac98b1501c5dcf5ecb5e0bf3b5616583987c6cd96dabbc838b0fa1e6da11c73c095ec5493c8795ee33a5c3a4212f77f7bcceff4fd2
@@ -4,9 +4,23 @@ require_relative './rspec_mocks/version'
4
4
 
5
5
  class Object
6
6
  # remove Minitest's stub method so RSpec's version on BasicObject will work
7
- if self.method_defined?(:stub) && !defined?(removed_minitest)
7
+ if self.method_defined?(:stub) && !defined?(removed_minitest_stub)
8
8
  remove_method :stub
9
- removed_minitest = true
9
+ removed_minitest_stub = true
10
+ removed_minitest_stub
11
+ end
12
+ end
13
+
14
+ class Minitest::Spec
15
+ module DSL
16
+ module InstanceMethods
17
+ # remove Minitest's stub method so RSpec's version on BasicObject will work
18
+ if self.method_defined?(:expect) && !defined?(removed_minitest_expect)
19
+ remove_method :expect
20
+ removed_minitest_expect = true
21
+ removed_minitest_expect
22
+ end
23
+ end
10
24
  end
11
25
  end
12
26
 
@@ -1,5 +1,5 @@
1
1
  module MiniTest
2
2
  module RSpecMocks
3
- VERSION = "0.2.0"
3
+ VERSION = "0.3.0"
4
4
  end
5
5
  end
@@ -8,24 +8,9 @@ base_class = if MiniTest.const_defined?(:Unit)
8
8
  Minitest::Test
9
9
  end
10
10
 
11
- class TestBase < base_class
12
- include Minitest::RSpecMocks
13
- end
14
-
15
- # I am not sure how/if this test ever passed. We remove minitest stub
16
- # when we require minitest_spec_mocks, so it doesn't make sense to
17
- # have this test.
18
- #
19
- # class MiniTestWithoutRspecMocksTest < MiniTest::Unit::TestCase
20
- # def test_it_should_use_minitest_stub
21
- # string = "hello"
22
- # string.stub(:to_i, 100) do
23
- # assert string.to_i == 100
24
- # end
25
- # end
26
- # end
11
+ base_class.send :include, Minitest::RSpecMocks
27
12
 
28
- class MiniTestWithRspecMocksShouldStyleTest < TestBase
13
+ class MiniTestWithRspecMocksShouldStyleTest < base_class
29
14
  def test_it_should_use_rspec_stub
30
15
  RSpec::Mocks.configuration.syntax = :should
31
16
  string = "hello"
@@ -35,7 +20,7 @@ class MiniTestWithRspecMocksShouldStyleTest < TestBase
35
20
  end
36
21
  end
37
22
 
38
- class MiniTestWithRspecMocksExpectStyleTest < TestBase
23
+ class MiniTestWithRspecMocksExpectStyleTest < base_class
39
24
  def test_it_should_use_rspec_expect
40
25
  RSpec::Mocks.configuration.syntax = :expect
41
26
  string = "hello"
@@ -44,3 +29,21 @@ class MiniTestWithRspecMocksExpectStyleTest < TestBase
44
29
  assert string.to_i == 100
45
30
  end
46
31
  end
32
+
33
+ describe 'when used with minitest/spec syntax' do
34
+ it 'works with stub syntax' do
35
+ RSpec::Mocks.configuration.syntax = :should
36
+ string = "hello"
37
+ assert string.to_i == 0
38
+ string.stub(to_i: 100)
39
+ assert string.to_i == 100
40
+ end
41
+
42
+ it 'works with expect syntax' do
43
+ RSpec::Mocks.configuration.syntax = :expect
44
+ string = "hello"
45
+ assert string.to_i == 0
46
+ expect(string).to receive(:to_i).and_return 100
47
+ assert string.to_i == 100
48
+ end
49
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: minitest-rspec_mocks
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sammy Larbi
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-02-21 00:00:00.000000000 Z
11
+ date: 2015-05-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -109,7 +109,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
109
109
  version: '0'
110
110
  requirements: []
111
111
  rubyforge_project:
112
- rubygems_version: 2.4.3
112
+ rubygems_version: 2.4.6
113
113
  signing_key:
114
114
  specification_version: 4
115
115
  summary: Use rspec-mocks with minitest