minitest-rspec_mocks 0.2.0 → 0.3.0
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.
- checksums.yaml +4 -4
- data/lib/minitest/rspec_mocks.rb +16 -2
- data/lib/minitest/rspec_mocks/version.rb +1 -1
- data/test/minitest/rspec_mocks_test.rb +21 -18
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5688818ab7c483bc82c1b576c62c3e430c2a5538
|
4
|
+
data.tar.gz: 5171b53c75b39ef72dabd6f8ad5429cc8f5f28c7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 06f55f50c10465979366edc5715509bf9319912eb4cf23d781e3ebd6b2454ede20c29ce413b05b9803dbd245ff2cf119c4bd7befa6d659a947f075ff8ced11eb
|
7
|
+
data.tar.gz: 09d4333f951a507b1450b0ac98b1501c5dcf5ecb5e0bf3b5616583987c6cd96dabbc838b0fa1e6da11c73c095ec5493c8795ee33a5c3a4212f77f7bcceff4fd2
|
data/lib/minitest/rspec_mocks.rb
CHANGED
@@ -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?(
|
7
|
+
if self.method_defined?(:stub) && !defined?(removed_minitest_stub)
|
8
8
|
remove_method :stub
|
9
|
-
|
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
|
|
@@ -8,24 +8,9 @@ base_class = if MiniTest.const_defined?(:Unit)
|
|
8
8
|
Minitest::Test
|
9
9
|
end
|
10
10
|
|
11
|
-
|
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 <
|
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 <
|
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.
|
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-
|
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.
|
112
|
+
rubygems_version: 2.4.6
|
113
113
|
signing_key:
|
114
114
|
specification_version: 4
|
115
115
|
summary: Use rspec-mocks with minitest
|