rspec-multi-mock 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +19 -8
- data/lib/adapters/rr.rb +8 -2
- data/lib/adapters/rspec.rb +2 -2
- metadata +12 -19
data/README.rdoc
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
== Description
|
2
2
|
|
3
|
-
Allows multiple mock frameworks to be in action in RSpec.
|
3
|
+
Allows multiple mock frameworks to be in action in RSpec. This version is for rspec ~>2.3.0.
|
4
|
+
|
5
|
+
For rspec 1.3.1 refer to v0.1.0[https://github.com/endeepak/rspec-multi-mock/tree/v0.1.0]
|
4
6
|
|
5
7
|
== Installation
|
6
8
|
|
@@ -8,24 +10,29 @@ Allows multiple mock frameworks to be in action in RSpec. Currently works only f
|
|
8
10
|
|
9
11
|
== Usage
|
10
12
|
|
11
|
-
|
13
|
+
If you are using bundler add the dependency in Gemfile
|
12
14
|
|
13
15
|
gem 'rspec-multi-mock', :group => :test
|
14
16
|
|
15
|
-
Configure multi-mock for
|
17
|
+
Configure multi-mock for RSpec runner (Usually done in spec_helper.rb)
|
16
18
|
|
17
|
-
|
19
|
+
RSpec.configure do |config|
|
18
20
|
config.mock_with MultiMock::Adapter.for(:rspec, :mocha, :rr, :not_a_mock, ::NewMockFramework::RSpecAdapter)
|
19
21
|
end
|
20
22
|
|
21
23
|
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.
|
22
24
|
|
23
|
-
==
|
25
|
+
== When & How is this useful?
|
26
|
+
|
27
|
+
There are cases where you might have to use two different mocking in the same project(for a while). It could be because
|
28
|
+
|
29
|
+
* You are merging two big projects and they use different mocking frameworks for unit testing.
|
30
|
+
* You want to try a new mocking framework with cleaner syntax and some new features.
|
24
31
|
|
25
|
-
|
32
|
+
Since RSpec does not support multiple mocking frameworks, we might hesitate to pick up these tasks because
|
26
33
|
|
27
|
-
* There
|
28
|
-
* The new mocking framework may not provide all the features available in the current mocking framework.
|
34
|
+
* There could be less time and it needs some effort to convert all the specs to use new mocking framework.
|
35
|
+
* The new mocking framework may not yet provide all the features available in the current mocking framework.
|
29
36
|
|
30
37
|
Using this gem you can
|
31
38
|
|
@@ -33,6 +40,10 @@ Using this gem you can
|
|
33
40
|
* Start using new framework for new specs. This will reduce the number of specs need to be converted at the end.
|
34
41
|
* Use both mocking frameworks till the new one provides all the required features.
|
35
42
|
|
43
|
+
Please note that using multiple mocking frameworks can create a lot of confusion in the team. So make sure that the end goal is to use single mocking framework(Your favorite one!). Use this gem only during the transition phase.
|
44
|
+
|
45
|
+
== Note
|
46
|
+
|
36
47
|
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.
|
37
48
|
|
38
49
|
* The expectations set using the un-configured mocking framework will not be verified.
|
data/lib/adapters/rr.rb
CHANGED
@@ -1,13 +1,19 @@
|
|
1
1
|
require 'rubygems'
|
2
2
|
require 'rr'
|
3
3
|
|
4
|
+
RSpec.configuration.backtrace_clean_patterns.push(RR::Errors::BACKTRACE_IDENTIFIER)
|
5
|
+
|
4
6
|
module MultiMock
|
5
7
|
module Adapters
|
6
8
|
class RR
|
7
|
-
include ::RR::
|
9
|
+
include ::RR::Extensions::InstanceMethods
|
10
|
+
|
11
|
+
alias :setup_mocks_for_rspec :reset
|
12
|
+
alias :verify_mocks_for_rspec :verify
|
13
|
+
alias :teardown_mocks_for_rspec :reset
|
8
14
|
end
|
9
15
|
end
|
10
16
|
end
|
11
17
|
|
12
18
|
#This will add mock(Entity), stub(Entity) etc rr methods to spec methods
|
13
|
-
MultiMock::Adapter.send(:include, RR::Extensions::InstanceMethods)
|
19
|
+
MultiMock::Adapter.send(:include, ::RR::Extensions::InstanceMethods)
|
data/lib/adapters/rspec.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,12 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rspec-multi-mock
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
prerelease:
|
4
|
+
prerelease: false
|
6
5
|
segments:
|
7
6
|
- 0
|
8
|
-
-
|
7
|
+
- 2
|
9
8
|
- 0
|
10
|
-
version: 0.
|
9
|
+
version: 0.2.0
|
11
10
|
platform: ruby
|
12
11
|
authors:
|
13
12
|
- Deepak N
|
@@ -15,7 +14,7 @@ autorequire:
|
|
15
14
|
bindir: bin
|
16
15
|
cert_chain: []
|
17
16
|
|
18
|
-
date: 2011-01
|
17
|
+
date: 2011-02-01 00:00:00 +05:30
|
19
18
|
default_executable:
|
20
19
|
dependencies:
|
21
20
|
- !ruby/object:Gem::Dependency
|
@@ -24,14 +23,13 @@ dependencies:
|
|
24
23
|
requirement: &id001 !ruby/object:Gem::Requirement
|
25
24
|
none: false
|
26
25
|
requirements:
|
27
|
-
- -
|
26
|
+
- - ~>
|
28
27
|
- !ruby/object:Gem::Version
|
29
|
-
hash: 25
|
30
28
|
segments:
|
31
|
-
-
|
29
|
+
- 2
|
32
30
|
- 3
|
33
|
-
-
|
34
|
-
version:
|
31
|
+
- 0
|
32
|
+
version: 2.3.0
|
35
33
|
type: :runtime
|
36
34
|
version_requirements: *id001
|
37
35
|
- !ruby/object:Gem::Dependency
|
@@ -40,9 +38,8 @@ dependencies:
|
|
40
38
|
requirement: &id002 !ruby/object:Gem::Requirement
|
41
39
|
none: false
|
42
40
|
requirements:
|
43
|
-
- -
|
41
|
+
- - ~>
|
44
42
|
- !ruby/object:Gem::Version
|
45
|
-
hash: 43
|
46
43
|
segments:
|
47
44
|
- 0
|
48
45
|
- 9
|
@@ -56,9 +53,8 @@ dependencies:
|
|
56
53
|
requirement: &id003 !ruby/object:Gem::Requirement
|
57
54
|
none: false
|
58
55
|
requirements:
|
59
|
-
- -
|
56
|
+
- - ~>
|
60
57
|
- !ruby/object:Gem::Version
|
61
|
-
hash: 21
|
62
58
|
segments:
|
63
59
|
- 1
|
64
60
|
- 0
|
@@ -72,9 +68,8 @@ dependencies:
|
|
72
68
|
requirement: &id004 !ruby/object:Gem::Requirement
|
73
69
|
none: false
|
74
70
|
requirements:
|
75
|
-
- -
|
71
|
+
- - ~>
|
76
72
|
- !ruby/object:Gem::Version
|
77
|
-
hash: 19
|
78
73
|
segments:
|
79
74
|
- 1
|
80
75
|
- 0
|
@@ -117,7 +112,6 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
117
112
|
requirements:
|
118
113
|
- - ">="
|
119
114
|
- !ruby/object:Gem::Version
|
120
|
-
hash: 3
|
121
115
|
segments:
|
122
116
|
- 0
|
123
117
|
version: "0"
|
@@ -126,14 +120,13 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
126
120
|
requirements:
|
127
121
|
- - ">="
|
128
122
|
- !ruby/object:Gem::Version
|
129
|
-
hash: 3
|
130
123
|
segments:
|
131
124
|
- 0
|
132
125
|
version: "0"
|
133
126
|
requirements: []
|
134
127
|
|
135
128
|
rubyforge_project:
|
136
|
-
rubygems_version: 1.
|
129
|
+
rubygems_version: 1.3.7
|
137
130
|
signing_key:
|
138
131
|
specification_version: 3
|
139
132
|
summary: Multiple mock frameworks support for RSpec
|