rspec-fire 0.2 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- data/HISTORY +3 -0
- data/README.md +2 -6
- data/lib/rspec/fire.rb +28 -33
- data/rspec-fire.gemspec +1 -1
- metadata +7 -7
data/HISTORY
CHANGED
data/README.md
CHANGED
@@ -107,8 +107,6 @@ check for *any* set of methods.
|
|
107
107
|
|
108
108
|
* Only mock methods on collaborators, _not_ the class under test.
|
109
109
|
* Only mock public methods.
|
110
|
-
* Extract common mock setup to keep your specs
|
111
|
-
[DRY](http://en.wikipedia.org/wiki/DRY).
|
112
110
|
|
113
111
|
If you can't meet these criteria, your object is probably violating
|
114
112
|
[SOLID](http://en.wikipedia.org/wiki/SOLID) principles and you should either
|
@@ -117,11 +115,9 @@ refactor or use a non-isolated test.
|
|
117
115
|
Compatibility
|
118
116
|
-------------
|
119
117
|
|
120
|
-
Only RSpec 2 is supported. Tested on all the rubies
|
118
|
+
Only RSpec 2 is supported. Tested on all the rubies thanks to [Travis
|
119
|
+
CI][build-link].
|
121
120
|
|
122
|
-
[![Build Status][build-image]][build-link]
|
123
|
-
|
124
|
-
[build-image]: https://secure.travis-ci.org/xaviershay/rspec-fire.png
|
125
121
|
[build-link]: http://travis-ci.org/xaviershay/rspec-fire
|
126
122
|
|
127
123
|
Developing
|
data/lib/rspec/fire.rb
CHANGED
@@ -18,6 +18,7 @@ module RSpec
|
|
18
18
|
end
|
19
19
|
|
20
20
|
class ShouldProxy < SimpleDelegator
|
21
|
+
extend RSpec::Matchers::DSL
|
21
22
|
include RecursiveConstMethods
|
22
23
|
|
23
24
|
AM = RSpec::Mocks::ArgumentMatchers
|
@@ -55,21 +56,20 @@ module RSpec
|
|
55
56
|
end
|
56
57
|
end
|
57
58
|
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
end
|
59
|
+
define :have_arity do |actual|
|
60
|
+
match do |method|
|
61
|
+
method.arity >= 0 && method.arity == actual
|
62
|
+
end
|
63
63
|
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
end
|
64
|
+
failure_message_for_should do |method|
|
65
|
+
"Wrong number of arguments for #{method.name}. " +
|
66
|
+
"Expected #{method.arity}, got #{actual}."
|
68
67
|
end
|
69
68
|
end
|
70
69
|
end
|
71
70
|
|
72
71
|
class FireDouble < RSpec::Mocks::Mock
|
72
|
+
extend RSpec::Matchers::DSL
|
73
73
|
include RecursiveConstMethods
|
74
74
|
|
75
75
|
def initialize(doubled_class, *args)
|
@@ -106,31 +106,26 @@ module RSpec
|
|
106
106
|
end
|
107
107
|
end
|
108
108
|
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
implemented_methods = doubled_class.send(checked_methods)
|
116
|
-
# to_sym for non-1.9 compat
|
117
|
-
expected_methods - implemented_methods.map(&:to_sym)
|
118
|
-
}
|
119
|
-
|
120
|
-
match do |doubled_class|
|
121
|
-
unimplemented_methods[ doubled_class ].empty?
|
122
|
-
end
|
109
|
+
define :implement do |expected_methods, checked_methods|
|
110
|
+
unimplemented_methods = lambda {|doubled_class|
|
111
|
+
implemented_methods = doubled_class.send(checked_methods)
|
112
|
+
# to_sym for non-1.9 compat
|
113
|
+
expected_methods - implemented_methods.map(&:to_sym)
|
114
|
+
}
|
123
115
|
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
116
|
+
match do |doubled_class|
|
117
|
+
unimplemented_methods[ doubled_class ].empty?
|
118
|
+
end
|
119
|
+
|
120
|
+
failure_message_for_should do |doubled_class|
|
121
|
+
implemented_methods =
|
122
|
+
Object.public_methods - doubled_class.send(checked_methods)
|
123
|
+
"%s does not implement:\n%s" % [
|
124
|
+
doubled_class,
|
125
|
+
unimplemented_methods[ doubled_class ].sort.map {|x|
|
126
|
+
" #{x}"
|
127
|
+
}.join("\n")
|
128
|
+
]
|
134
129
|
end
|
135
130
|
end
|
136
131
|
end
|
data/rspec-fire.gemspec
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rspec-fire
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 0.2.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2012-01-14 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rake
|
16
|
-
requirement: &
|
16
|
+
requirement: &2152370600 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :development
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *2152370600
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: rspec
|
27
|
-
requirement: &
|
27
|
+
requirement: &2152370060 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ~>
|
@@ -32,7 +32,7 @@ dependencies:
|
|
32
32
|
version: '2.5'
|
33
33
|
type: :development
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *2152370060
|
36
36
|
description:
|
37
37
|
email:
|
38
38
|
- hello@xaviershay.com
|
@@ -68,7 +68,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
68
68
|
version: '0'
|
69
69
|
requirements: []
|
70
70
|
rubyforge_project:
|
71
|
-
rubygems_version: 1.8.
|
71
|
+
rubygems_version: 1.8.6
|
72
72
|
signing_key:
|
73
73
|
specification_version: 3
|
74
74
|
summary: More resilient test doubles for RSpec.
|