adequack 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 70f0291eb7ccd7aa8818463326c4a68c69bfc99b
4
- data.tar.gz: caf67d45f2aa6efea859b1b8a89b5768417b8870
3
+ metadata.gz: 19d707b457e7ae1fd0ad7067027fa90a39697869
4
+ data.tar.gz: 90d10cb4dd9d948e98c4c688ea75e9521c0888ac
5
5
  SHA512:
6
- metadata.gz: 68d9434369d6c2a5866eb0dee4b535917fc12d3914a3bc4e03f88ae419e63f255e0d4add303c56cd30b8342685ffbe94af8eb87ab1176e44992e9c75c8130185
7
- data.tar.gz: b6c93a4e560827abb4124db0065bfafcac9723c24d2d39c862c1026507ecc0b745a867f32ab9af11beade861a6ca5c2f717d4366242fa9a4a6a71a2cedc95b2b
6
+ metadata.gz: f3e5594e0a8d0b60a1a0dbb4b630bd498f6666d7903c3dd8a8d3a3512696da715858487594a12dbfef3c39fa9ea39c1ce294da7cf2b1554f6de8f997629df66f
7
+ data.tar.gz: 7476ef90343baf2a48f5ffed1989644cd4ccc472b9197d89bd5d7d6758db1729c34fe5681c9b666382c9cabba2132e9877be00712e20c5554d2b8569d0251077
data/CHANGELOG.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  * Class methods now counted too when trying to stub them
4
4
 
5
- * Fix undefined method `new` for when checking for stubs
5
+ * Fix undefined method `new` when checking for stubs satisfaction
6
6
 
7
7
  # Version 0.0.1
8
8
 
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)
@@ -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 = target_method.parameters.select { |m| m.first == :opt }
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,
@@ -1,3 +1,3 @@
1
1
  module Adequack
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
@@ -29,7 +29,7 @@ end
29
29
 
30
30
  describe Animal do
31
31
  subject { described_class }
32
- it { should be_adequack_to AnimalInterface }
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) { adequack_double double, AnimalInterface }
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.2
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-06 00:00:00.000000000 Z
11
+ date: 2013-05-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec