fakes 1.1.2 → 1.1.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.
@@ -1,12 +1,12 @@
1
1
  module Fakes
2
2
  class ArgMatchFactory
3
3
  def self.create_arg_matcher_using(args)
4
- matcher = CombinedArgMatcher.new
4
+ combined_matcher = CombinedArgMatcher.new
5
5
  args.each do|arg|
6
- current_matcher = arg.respond_to?(:matches?) ? arg : RegularArgMatcher.new(arg)
7
- matcher.add current_matcher
6
+ matcher = arg.respond_to?(:matches?) ? arg : RegularArgMatcher.new(arg)
7
+ combined_matcher << matcher
8
8
  end
9
- matcher
9
+ combined_matcher
10
10
  end
11
11
  end
12
12
  end
@@ -24,7 +24,7 @@ module Fakes
24
24
  end
25
25
 
26
26
  def regex(pattern)
27
- condition { |string_value| pattern =~ string_value }
27
+ condition { |string_argument| pattern =~ string_argument }
28
28
  end
29
29
 
30
30
  def condition(&conditional_block)
@@ -8,17 +8,20 @@ module Fakes
8
8
 
9
9
  def matches?(args)
10
10
  matches = true
11
- @all_matchers.each_with_index do |matcher, index|
11
+
12
+ all_matchers.each_with_index do |matcher, index|
12
13
  value = args[index]
13
14
  matches &= matcher.matches?(value)
14
15
  return false unless matches
15
16
  end
17
+
16
18
  matches
17
19
  end
18
20
 
19
21
  def add(matcher)
20
- @all_matchers << matcher
22
+ all_matchers << matcher
21
23
  end
24
+ alias :<< :add
22
25
 
23
26
  end
24
27
  end
data/lib/fakes/fake.rb CHANGED
@@ -26,8 +26,16 @@ module Fakes
26
26
  return @method_invocations[symbol]
27
27
  end
28
28
 
29
- def never_received?(symbol)
30
- return !@method_invocations.has_key?(symbol)
29
+ def never_received?(symbol, *args)
30
+ return !received?(symbol, *args)
31
+ end
32
+
33
+ def received?(symbol, *args)
34
+ method = received(symbol)
35
+ return false if method.nil?
36
+
37
+ argument_set = method.called_with(*args)
38
+ return !argument_set.nil?
31
39
  end
32
40
  end
33
41
  end
data/lib/fakes/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Fakes
2
- VERSION = "1.1.2"
2
+ VERSION = "1.1.3"
3
3
  end
@@ -60,15 +60,16 @@ module Fakes
60
60
  let(:invocations){Hash.new}
61
61
  let(:sut){Fake.new(invocations)}
62
62
  let(:existing){:hello}
63
- let(:method_invocation){Object.new}
63
+ let(:method_invocation){ Object.new }
64
64
 
65
65
  before (:each) do
66
66
  invocations[existing] = method_invocation
67
+ method_invocation.stub(:called_with).and_return(false)
67
68
  end
68
69
 
69
70
 
70
71
  it "should base its decision on the list of received invocations" do
71
- [:other,existing].each do|item|
72
+ [:other, existing].each do|item|
72
73
  sut.never_received?(item).should_not be_equal(invocations.has_key?(item))
73
74
  end
74
75
  end
@@ -292,6 +293,15 @@ module Fakes
292
293
  fake.received(:hello).called_with(1,[1,2,3,5]).should be_nil
293
294
  end
294
295
 
296
+ it 'should be able to determine if it received a method call' do
297
+ fake = Fake.new
298
+ fake.hello(1,[1,2,3,4])
299
+
300
+ fake.received?(:hello,1,[1,2,3,4]).should be_true
301
+ fake.received?(:hello).should be_true
302
+ end
303
+
304
+
295
305
  end
296
306
  end
297
307
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fakes
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.2
4
+ version: 1.1.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -134,7 +134,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
134
134
  version: '0'
135
135
  segments:
136
136
  - 0
137
- hash: -2245733213966306634
137
+ hash: -4322059409981481306
138
138
  required_rubygems_version: !ruby/object:Gem::Requirement
139
139
  none: false
140
140
  requirements:
@@ -143,7 +143,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
143
143
  version: '0'
144
144
  segments:
145
145
  - 0
146
- hash: -2245733213966306634
146
+ hash: -4322059409981481306
147
147
  requirements: []
148
148
  rubyforge_project: fakes
149
149
  rubygems_version: 1.8.25