adequack 0.0.2 → 0.0.3
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/CHANGELOG.md +1 -1
- data/README.md +21 -0
- data/lib/adequack/integration/rspec_setup.rb +26 -0
- data/lib/adequack/proxy.rb +2 -1
- data/lib/adequack/version.rb +1 -1
- data/spec/integration_spec.rb +2 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 19d707b457e7ae1fd0ad7067027fa90a39697869
|
4
|
+
data.tar.gz: 90d10cb4dd9d948e98c4c688ea75e9521c0888ac
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f3e5594e0a8d0b60a1a0dbb4b630bd498f6666d7903c3dd8a8d3a3512696da715858487594a12dbfef3c39fa9ea39c1ce294da7cf2b1554f6de8f997629df66f
|
7
|
+
data.tar.gz: 7476ef90343baf2a48f5ffed1989644cd4ccc472b9197d89bd5d7d6758db1729c34fe5681c9b666382c9cabba2132e9877be00712e20c5554d2b8569d0251077
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -187,6 +187,13 @@ Failures:
|
|
187
187
|
definition of method 'eat_food' differs in parameters accepted.
|
188
188
|
```
|
189
189
|
|
190
|
+
## Requirements
|
191
|
+
|
192
|
+
This gem tested against Ruby 1.9.3, 2.0.0.
|
193
|
+
|
194
|
+
Current version supports RSpec and Rspec Mocks only.
|
195
|
+
If you want minitest or any other mocking library support, please drop a line at [this issue](https://github.com/Somebody32/adequack/issues/2).
|
196
|
+
|
190
197
|
## Installation
|
191
198
|
|
192
199
|
Just install the gem
|
@@ -202,6 +209,20 @@ After that your rspec tests will have `be_adequack_to` matcher and `adequack_dou
|
|
202
209
|
|
203
210
|
TODO: Write full API definition here
|
204
211
|
|
212
|
+
## Alternatives
|
213
|
+
|
214
|
+
There are some alternative solutions:
|
215
|
+
|
216
|
+
* [Quacky](https://github.com/benmoss/quacky)
|
217
|
+
* [Bogus](https://github.com/psyho/bogus)
|
218
|
+
* [Rspec Fire Roles](https://github.com/cvincent/rspec-fire-roles)
|
219
|
+
|
220
|
+
The main goal of Adequack is to provide as transparent solution as possible and be suitable for isolation testing.
|
221
|
+
Developer can pass a core object to the helper and get it back unchanged, just with a small interface checks added.
|
222
|
+
|
223
|
+
This will help minimize any possible integration errors or any unsuspected behaviour.
|
224
|
+
You should just be sure that your mocks are adequate and not get tricked by any internal magick.
|
225
|
+
|
205
226
|
## Contributing
|
206
227
|
|
207
228
|
This library is considered "experimental" quality.
|
@@ -1,14 +1,40 @@
|
|
1
1
|
module Adequack
|
2
2
|
module Integration
|
3
3
|
module RSpecHelpers
|
4
|
+
def behavioral_double(object, interface)
|
5
|
+
Adequack.double object, interface
|
6
|
+
end
|
7
|
+
|
4
8
|
def adequack_double(object, interface)
|
9
|
+
Adequack::Integration::RSpecHelpers.
|
10
|
+
deprecation_warning("adequack_double", "behavioral_double")
|
5
11
|
Adequack.double object, interface
|
6
12
|
end
|
13
|
+
|
14
|
+
class << self
|
15
|
+
def deprecation_warning(old_method, new_method)
|
16
|
+
warning = "DEPRECATION: '#{old_method}' is deprecated."\
|
17
|
+
" Please use `#{new_method}` instead."
|
18
|
+
|
19
|
+
warn warning
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
RSpec::Matchers.define :behave_like do |*expected_duck_types|
|
27
|
+
expected_duck_types.each do |expected_duck_type|
|
28
|
+
match do |actual|
|
29
|
+
Adequack.check_implementation(actual, expected_duck_type)
|
7
30
|
end
|
8
31
|
end
|
9
32
|
end
|
10
33
|
|
11
34
|
RSpec::Matchers.define :be_adequack_to do |*expected_duck_types|
|
35
|
+
Adequack::Integration::RSpecHelpers.
|
36
|
+
deprecation_warning("be_adequack_to", "behave_like")
|
37
|
+
|
12
38
|
expected_duck_types.each do |expected_duck_type|
|
13
39
|
match do |actual|
|
14
40
|
Adequack.check_implementation(actual, expected_duck_type)
|
data/lib/adequack/proxy.rb
CHANGED
@@ -55,7 +55,8 @@ module Adequack
|
|
55
55
|
end
|
56
56
|
|
57
57
|
unless target_method.parameters.any? { |m| m.first == :rest }
|
58
|
-
opt_m =
|
58
|
+
opt_m =
|
59
|
+
target_method.parameters.select { |m| [:opt, :key].include? m.first }
|
59
60
|
|
60
61
|
if args.size > (req_m.size + opt_m.size)
|
61
62
|
raise InterfaceImplementationError,
|
data/lib/adequack/version.rb
CHANGED
data/spec/integration_spec.rb
CHANGED
@@ -29,7 +29,7 @@ end
|
|
29
29
|
|
30
30
|
describe Animal do
|
31
31
|
subject { described_class }
|
32
|
-
it { should
|
32
|
+
it { should behave_like AnimalInterface }
|
33
33
|
end
|
34
34
|
|
35
35
|
class Owner
|
@@ -49,7 +49,7 @@ class Owner
|
|
49
49
|
end
|
50
50
|
|
51
51
|
describe Owner do
|
52
|
-
let(:animal) {
|
52
|
+
let(:animal) { behavioral_double double, AnimalInterface }
|
53
53
|
subject { described_class.new animal }
|
54
54
|
|
55
55
|
it "tricks animal" do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: adequack
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ilya Zayats
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-05-
|
11
|
+
date: 2013-05-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|