rspec-multi-mock 0.2.1 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/Gemfile.lock +21 -15
- data/README.md +5 -8
- data/lib/adapters/rr.rb +1 -3
- data/lib/adapters/rspec.rb +5 -3
- data/lib/multi_mock.rb +0 -3
- data/lib/version.rb +1 -1
- data/rspec-multi-mock.gemspec +3 -4
- data/spec/adapter_spec.rb +11 -36
- data/spec/spec_helper.rb +1 -3
- metadata +36 -44
- data/lib/adapters/not_a_mock.rb +0 -10
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: c4a50e9b2721e18c3b2c66e788614aa5ab1b29b4
|
4
|
+
data.tar.gz: 27183a02824920a11867cb7c16ef9dd2e88e599c
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: dfa373e09e3ee47b17272e0f65be6cf94b52464a0144bd0f7da39f87b1a8be4d2b60d91dde818f276384cfa6678c14d29e0a75aff1f409ee756a0c5eabe3b23b
|
7
|
+
data.tar.gz: c53903e158130db5bcf6e363ed7701fd7ec9de6c5328e37e0b71c13df33d57851ee5d0abc360b9dffb53d1adba4f76a946a30659f6a7467f40a9631c304c8221
|
data/Gemfile.lock
CHANGED
@@ -1,32 +1,38 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
rspec-multi-mock (0.
|
5
|
-
rspec (>=
|
4
|
+
rspec-multi-mock (0.3.0)
|
5
|
+
rspec (>= 3.7.0)
|
6
6
|
|
7
7
|
GEM
|
8
8
|
remote: http://rubygems.org/
|
9
9
|
specs:
|
10
|
-
diff-lcs (1.
|
10
|
+
diff-lcs (1.3)
|
11
11
|
mocha (0.9.12)
|
12
|
-
not_a_mock (1.0.1)
|
13
12
|
rake (0.9.2.2)
|
14
|
-
rr (1.
|
15
|
-
rspec (
|
16
|
-
rspec-core (~>
|
17
|
-
rspec-expectations (~>
|
18
|
-
rspec-mocks (~>
|
19
|
-
rspec-core (
|
20
|
-
|
21
|
-
|
22
|
-
|
13
|
+
rr (1.1.2)
|
14
|
+
rspec (3.7.0)
|
15
|
+
rspec-core (~> 3.7.0)
|
16
|
+
rspec-expectations (~> 3.7.0)
|
17
|
+
rspec-mocks (~> 3.7.0)
|
18
|
+
rspec-core (3.7.1)
|
19
|
+
rspec-support (~> 3.7.0)
|
20
|
+
rspec-expectations (3.7.0)
|
21
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
22
|
+
rspec-support (~> 3.7.0)
|
23
|
+
rspec-mocks (3.7.0)
|
24
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
25
|
+
rspec-support (~> 3.7.0)
|
26
|
+
rspec-support (3.7.1)
|
23
27
|
|
24
28
|
PLATFORMS
|
25
29
|
ruby
|
26
30
|
|
27
31
|
DEPENDENCIES
|
28
32
|
mocha (~> 0.9.8)
|
29
|
-
not_a_mock (~> 1.0.1)
|
30
33
|
rake
|
31
|
-
rr (~> 1.
|
34
|
+
rr (~> 1.1.2)
|
32
35
|
rspec-multi-mock!
|
36
|
+
|
37
|
+
BUNDLED WITH
|
38
|
+
1.16.1
|
data/README.md
CHANGED
@@ -1,8 +1,9 @@
|
|
1
|
-
## rspec-multi-mock [![Build Status](
|
1
|
+
## rspec-multi-mock [![Build Status](https://travis-ci.org/endeepak/rspec-multi-mock.png)](https://travis-ci.org/endeepak/rspec-multi-mock)
|
2
2
|
|
3
3
|
Allows multiple mock frameworks to be in action in RSpec. This version is for rspec >=2.3.0.
|
4
4
|
|
5
|
-
For rspec 1.3.1 refer to [v0.1.0](https://github.com/endeepak/rspec-multi-mock/tree/v0.1.0)
|
5
|
+
* For rspec 1.3.1 refer to [v0.1.0](https://github.com/endeepak/rspec-multi-mock/tree/v0.1.0)
|
6
|
+
* For rspec 2.x and `not_a_mock` support refer to [v0.2.1](https://github.com/endeepak/rspec-multi-mock/tree/v0.2.1)
|
6
7
|
|
7
8
|
## Installation
|
8
9
|
|
@@ -17,7 +18,7 @@ If you are using bundler add the dependency in Gemfile
|
|
17
18
|
Configure multi-mock for RSpec runner (Usually done in spec_helper.rb)
|
18
19
|
|
19
20
|
RSpec.configure do |config|
|
20
|
-
config.mock_with MultiMock::Adapter.for(:rspec, :mocha, :rr,
|
21
|
+
config.mock_with MultiMock::Adapter.for(:rspec, :mocha, :rr, ::NewMockFramework::RSpecAdapter)
|
21
22
|
end
|
22
23
|
|
23
24
|
As shown above you can use a symbol for frameworks listed above. The usage of adapter module directly may not work completely if the adapter module contains any extensions methods to be used in specs. For instance RR rspec adapter includes both the adapter methods and the extension methods.
|
@@ -47,8 +48,4 @@ Please note that using multiple mocking frameworks can create a lot of confusion
|
|
47
48
|
If you are already using multiple mock frameworks with just one mock framework configured in spec runner, the mocks may not be working completely as you expected.
|
48
49
|
|
49
50
|
* The expectations set using the un-configured mocking framework will not be verified.
|
50
|
-
* The methods mocked or stubbed using the un-configured mocking framework will not be cleaned up after the spec run is completed. This becomes a serious issue if it is a class method
|
51
|
-
|
52
|
-
## Limitations
|
53
|
-
|
54
|
-
* RR ad Not-A-Mock can not be used together since both frameworks have different implementation of 'have_received' matcher. This is true for any two frameworks with similar interface and different implementations.
|
51
|
+
* The methods mocked or stubbed using the un-configured mocking framework will not be cleaned up after the spec run is completed. This becomes a serious issue if it is a class method
|
data/lib/adapters/rr.rb
CHANGED
@@ -1,8 +1,6 @@
|
|
1
1
|
require 'rubygems'
|
2
2
|
require 'rr'
|
3
3
|
|
4
|
-
RSpec.configuration.backtrace_clean_patterns.push(RR::Errors::BACKTRACE_IDENTIFIER)
|
5
|
-
|
6
4
|
module MultiMock
|
7
5
|
module Adapters
|
8
6
|
class RR
|
@@ -16,4 +14,4 @@ module MultiMock
|
|
16
14
|
end
|
17
15
|
|
18
16
|
#This will add mock(Entity), stub(Entity) etc rr methods to spec methods
|
19
|
-
MultiMock::Adapter.send(:include, ::RR::Extensions::InstanceMethods)
|
17
|
+
MultiMock::Adapter.send(:include, ::RR::Extensions::InstanceMethods)
|
data/lib/adapters/rspec.rb
CHANGED
@@ -1,9 +1,11 @@
|
|
1
|
-
require 'rspec/core/
|
1
|
+
require 'rspec/core/mocking_adapters/rspec'
|
2
2
|
|
3
3
|
module MultiMock
|
4
4
|
module Adapters
|
5
5
|
class RSpec
|
6
|
-
include ::RSpec::Core::
|
6
|
+
include ::RSpec::Core::MockingAdapters::RSpec
|
7
7
|
end
|
8
8
|
end
|
9
|
-
end
|
9
|
+
end
|
10
|
+
|
11
|
+
MultiMock::Adapter.send(:include, ::RSpec::Mocks::ExampleMethods)
|
data/lib/multi_mock.rb
CHANGED
data/lib/version.rb
CHANGED
data/rspec-multi-mock.gemspec
CHANGED
@@ -16,9 +16,8 @@ Gem::Specification.new do |s|
|
|
16
16
|
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
17
17
|
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
18
18
|
s.require_paths = ["lib"]
|
19
|
-
s.add_runtime_dependency("rspec", ">=
|
19
|
+
s.add_runtime_dependency("rspec", ">= 3.7.0")
|
20
20
|
s.add_development_dependency("rake")
|
21
21
|
s.add_development_dependency("mocha", "~> 0.9.8")
|
22
|
-
s.add_development_dependency("
|
23
|
-
|
24
|
-
end
|
22
|
+
s.add_development_dependency("rr", "~> 1.1.2")
|
23
|
+
end
|
data/spec/adapter_spec.rb
CHANGED
@@ -5,7 +5,7 @@ describe MultiMock::Adapter do
|
|
5
5
|
it "should return the stubbed value" do
|
6
6
|
Object.expects(:hello).returns("Hello Mocha")
|
7
7
|
|
8
|
-
Object.hello.
|
8
|
+
expect(Object.hello).to eq "Hello Mocha"
|
9
9
|
end
|
10
10
|
|
11
11
|
it "should verify the proxied expectation" do
|
@@ -24,32 +24,7 @@ describe MultiMock::Adapter do
|
|
24
24
|
end
|
25
25
|
|
26
26
|
it "should clear the stubs created in previous specs" do
|
27
|
-
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
context "with ::NotAMock::RspecMockFrameworkAdapter" do
|
32
|
-
it "should return the stubbed value" do
|
33
|
-
Object.stub_method(:hello => "Hello Not A Mock")
|
34
|
-
|
35
|
-
Object.hello.should == "Hello Not A Mock"
|
36
|
-
end
|
37
|
-
|
38
|
-
it "should verify the proxied expectation" do
|
39
|
-
Object.stub_method(:hello) {}
|
40
|
-
|
41
|
-
Object.hello
|
42
|
-
|
43
|
-
Object.should have_received(:hello)
|
44
|
-
end
|
45
|
-
|
46
|
-
it "is setting up data for next spec" do
|
47
|
-
Object.stub_method(:stubbed_method) {}
|
48
|
-
Object.stubbed_method
|
49
|
-
end
|
50
|
-
|
51
|
-
it "should clear the stubs created in previous specs" do
|
52
|
-
lambda { Object.stubbed_method }.should raise_error(NoMethodError)
|
27
|
+
expect { Object.stubbed_method }.to raise_error(NoMethodError)
|
53
28
|
end
|
54
29
|
end
|
55
30
|
|
@@ -57,13 +32,13 @@ describe MultiMock::Adapter do
|
|
57
32
|
it "should return the stubbed value" do
|
58
33
|
stub(Object).hello { "Hello RR" }
|
59
34
|
|
60
|
-
Object.hello.
|
35
|
+
expect(Object.hello).to eq "Hello RR"
|
61
36
|
end
|
62
37
|
|
63
38
|
it "should verify the proxied expectation" do
|
64
39
|
dont_allow(Object).hello
|
65
40
|
|
66
|
-
|
41
|
+
expect { Object.hello }.to raise_error(RR::Errors::TimesCalledError)
|
67
42
|
end
|
68
43
|
|
69
44
|
it "is setting up data for next spec" do
|
@@ -72,30 +47,30 @@ describe MultiMock::Adapter do
|
|
72
47
|
end
|
73
48
|
|
74
49
|
it "should clear the stubs created in previous specs" do
|
75
|
-
|
50
|
+
expect { Object.stubbed_method }.to raise_error(NoMethodError)
|
76
51
|
end
|
77
52
|
end
|
78
53
|
|
79
54
|
context "with rspec mock" do
|
80
55
|
it "should return the stubbed value" do
|
81
|
-
Object.
|
56
|
+
allow(Object).to receive(:hello).and_return("Hello RSpec mock")
|
82
57
|
|
83
|
-
Object.hello.
|
58
|
+
expect(Object.hello).to eq "Hello RSpec mock"
|
84
59
|
end
|
85
60
|
|
86
61
|
it "should verify the proxied expectation" do
|
87
|
-
Object.
|
62
|
+
expect(Object).to receive(:hello)
|
88
63
|
|
89
|
-
|
64
|
+
expect { Object.hello }.not_to raise_error
|
90
65
|
end
|
91
66
|
|
92
67
|
it "is setting up data for next spec" do
|
93
|
-
Object.
|
68
|
+
allow(Object).to receive(:stubbed_method).and_return("Hello RSpec mock")
|
94
69
|
Object.stubbed_method
|
95
70
|
end
|
96
71
|
|
97
72
|
it "should clear the stubs created in previous specs" do
|
98
|
-
|
73
|
+
expect { Object.stubbed_method }.to raise_error(NoMethodError)
|
99
74
|
end
|
100
75
|
end
|
101
76
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,12 +1,10 @@
|
|
1
1
|
require 'rubygems'
|
2
2
|
require 'rspec'
|
3
3
|
require 'rspec-multi-mock'
|
4
|
-
require 'not_a_mock'
|
5
4
|
|
6
5
|
RSpec.configure do |config|
|
7
|
-
config.mock_with MultiMock::Adapter.for(:rspec, :mocha, :rr
|
6
|
+
config.mock_with MultiMock::Adapter.for(:rspec, :mocha, :rr)
|
8
7
|
# config.mock_with :mocha
|
9
8
|
# config.mock_with :rspec
|
10
|
-
# config.mock_with ::NotAMock::RspecMockFrameworkAdapter
|
11
9
|
# config.mock_with :rr
|
12
10
|
end
|
metadata
CHANGED
@@ -1,71 +1,71 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rspec-multi-mock
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
5
|
-
prerelease:
|
4
|
+
version: 0.3.0
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Deepak N
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date:
|
11
|
+
date: 2018-03-04 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: rspec
|
16
|
-
requirement:
|
17
|
-
none: false
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
18
16
|
requirements:
|
19
|
-
- -
|
17
|
+
- - ">="
|
20
18
|
- !ruby/object:Gem::Version
|
21
|
-
version:
|
19
|
+
version: 3.7.0
|
22
20
|
type: :runtime
|
23
21
|
prerelease: false
|
24
|
-
version_requirements:
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 3.7.0
|
25
27
|
- !ruby/object:Gem::Dependency
|
26
28
|
name: rake
|
27
|
-
requirement:
|
28
|
-
none: false
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
29
30
|
requirements:
|
30
|
-
- -
|
31
|
+
- - ">="
|
31
32
|
- !ruby/object:Gem::Version
|
32
33
|
version: '0'
|
33
34
|
type: :development
|
34
35
|
prerelease: false
|
35
|
-
version_requirements:
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
36
41
|
- !ruby/object:Gem::Dependency
|
37
42
|
name: mocha
|
38
|
-
requirement:
|
39
|
-
none: false
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
40
44
|
requirements:
|
41
|
-
- - ~>
|
45
|
+
- - "~>"
|
42
46
|
- !ruby/object:Gem::Version
|
43
47
|
version: 0.9.8
|
44
48
|
type: :development
|
45
49
|
prerelease: false
|
46
|
-
version_requirements:
|
47
|
-
- !ruby/object:Gem::Dependency
|
48
|
-
name: not_a_mock
|
49
|
-
requirement: &2165675560 !ruby/object:Gem::Requirement
|
50
|
-
none: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- - ~>
|
52
|
+
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version:
|
55
|
-
type: :development
|
56
|
-
prerelease: false
|
57
|
-
version_requirements: *2165675560
|
54
|
+
version: 0.9.8
|
58
55
|
- !ruby/object:Gem::Dependency
|
59
56
|
name: rr
|
60
|
-
requirement:
|
61
|
-
none: false
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
62
58
|
requirements:
|
63
|
-
- - ~>
|
59
|
+
- - "~>"
|
64
60
|
- !ruby/object:Gem::Version
|
65
|
-
version: 1.
|
61
|
+
version: 1.1.2
|
66
62
|
type: :development
|
67
63
|
prerelease: false
|
68
|
-
version_requirements:
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 1.1.2
|
69
69
|
description: Allows multiple mock frameworks to be in action in RSpec.
|
70
70
|
email:
|
71
71
|
- endeep123@gmail.com
|
@@ -73,7 +73,7 @@ executables: []
|
|
73
73
|
extensions: []
|
74
74
|
extra_rdoc_files: []
|
75
75
|
files:
|
76
|
-
- .gitignore
|
76
|
+
- ".gitignore"
|
77
77
|
- Gemfile
|
78
78
|
- Gemfile.lock
|
79
79
|
- LICENSE
|
@@ -81,7 +81,6 @@ files:
|
|
81
81
|
- Rakefile
|
82
82
|
- lib/adapter.rb
|
83
83
|
- lib/adapters/mocha.rb
|
84
|
-
- lib/adapters/not_a_mock.rb
|
85
84
|
- lib/adapters/rr.rb
|
86
85
|
- lib/adapters/rspec.rb
|
87
86
|
- lib/adapters/unknown.rb
|
@@ -93,33 +92,26 @@ files:
|
|
93
92
|
- spec/spec_helper.rb
|
94
93
|
homepage: https://github.com/endeepak/rspec-multi-mock
|
95
94
|
licenses: []
|
95
|
+
metadata: {}
|
96
96
|
post_install_message:
|
97
97
|
rdoc_options: []
|
98
98
|
require_paths:
|
99
99
|
- lib
|
100
100
|
required_ruby_version: !ruby/object:Gem::Requirement
|
101
|
-
none: false
|
102
101
|
requirements:
|
103
|
-
- -
|
102
|
+
- - ">="
|
104
103
|
- !ruby/object:Gem::Version
|
105
104
|
version: '0'
|
106
|
-
segments:
|
107
|
-
- 0
|
108
|
-
hash: -3547394442165570990
|
109
105
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
110
|
-
none: false
|
111
106
|
requirements:
|
112
|
-
- -
|
107
|
+
- - ">="
|
113
108
|
- !ruby/object:Gem::Version
|
114
109
|
version: '0'
|
115
|
-
segments:
|
116
|
-
- 0
|
117
|
-
hash: -3547394442165570990
|
118
110
|
requirements: []
|
119
111
|
rubyforge_project:
|
120
|
-
rubygems_version:
|
112
|
+
rubygems_version: 2.6.13
|
121
113
|
signing_key:
|
122
|
-
specification_version:
|
114
|
+
specification_version: 4
|
123
115
|
summary: Multiple mock frameworks support for RSpec
|
124
116
|
test_files:
|
125
117
|
- spec/adapter_spec.rb
|