rspec-spies 2.1.0 → 2.1.1

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile CHANGED
@@ -1,9 +1,3 @@
1
1
  source :rubygems
2
2
 
3
- gem 'rspec', '~> 2.0'
4
-
5
- group :development do
6
- gem 'rake'
7
- gem 'jeweler'
8
- gem 'rdoc'
9
- end
3
+ gemspec
data/Gemfile.lock CHANGED
@@ -1,3 +1,10 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ rspec-spies (2.1.1)
5
+ rspec (~> 2.0)
6
+ rspec-spies
7
+
1
8
  GEM
2
9
  remote: http://rubygems.org/
3
10
  specs:
@@ -25,4 +32,4 @@ DEPENDENCIES
25
32
  jeweler
26
33
  rake
27
34
  rdoc
28
- rspec (~> 2.0)
35
+ rspec-spies!
data/README.rdoc CHANGED
@@ -25,6 +25,7 @@ To get started, you just need to:
25
25
 
26
26
  * Run: gem install rspec-spies --source http://gemcutter.org
27
27
  * Update spec_helper to include this line: require 'rspec-spies'
28
+ * Alternatively, you can add `-r rspec-spies` to your project's .rspec file
28
29
 
29
30
 
30
31
  == Before and after test spies
data/Rakefile CHANGED
@@ -12,6 +12,12 @@ Jeweler::Tasks.new do |gem|
12
12
  gem.email = "josh@technicalpickles.com"
13
13
  gem.homepage = "http://github.com/technicalpickles/rspec-spies"
14
14
  gem.authors = ["Joshua Nichols"]
15
+
16
+ gem.add_runtime_dependency 'rspec', '~> 2.0'
17
+
18
+ gem.add_development_dependency 'rake'
19
+ gem.add_development_dependency 'jeweler'
20
+ gem.add_development_dependency 'rdoc'
15
21
  # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
16
22
  end
17
23
  Jeweler::GemcutterTasks.new
data/VERSION CHANGED
@@ -1 +1 @@
1
- 2.1.0
1
+ 2.1.1
data/lib/rspec-spies.rb CHANGED
@@ -15,30 +15,36 @@ RSpec::Mocks::MethodDouble.class_eval do
15
15
  end
16
16
  end
17
17
 
18
+ require 'rspec/expectations'
18
19
  require 'rspec/matchers'
19
- RSpec::Matchers.define :have_received do |sym, args, block|
20
+ RSpec::Matchers.define :have_received do |method_name, args, block|
20
21
  match do |actual|
21
- actual.received_message?(sym, *@args, &block)
22
+ messages_received = actual.send(:__mock_proxy).instance_variable_get("@messages_received")
23
+ messages_received.any? do |message|
24
+ received_method_name, received_args, received_block = *message
25
+ result = (received_method_name == method_name)
26
+ result &&= RSpec::Mocks::ArgumentExpectation.new(@args || any_args).args_match?(received_args)
27
+ result &&= (received_block == block)
28
+ end
22
29
  end
23
30
 
31
+ chain :with do |*args|
32
+ @args = args
33
+ end
24
34
 
25
35
  failure_message_for_should do |actual|
26
- "expected #{actual.inspect} to have received #{sym.inspect} with #{@args.inspect}"
36
+ "expected #{actual.inspect} to have received #{method_name.inspect}#{args_message}"
27
37
  end
28
38
 
29
-
30
39
  failure_message_for_should_not do |actual|
31
- "expected #{actual.inspect} to not have received #{sym.inspect} with #{@args.inspect}, but did"
40
+ "expected #{actual.inspect} to not have received #{method_name.inspect}#{args_message}, but did"
32
41
  end
33
42
 
34
-
35
43
  description do
36
- "to have received #{sym.inspect} with #{@args.inspect}"
44
+ "to have received #{method_name.inspect}#{args_message}"
37
45
  end
38
46
 
39
-
40
- def with(*args)
41
- @args = args
42
- self
47
+ def args_message
48
+ @args ? " with #{@args.inspect}" : ""
43
49
  end
44
50
  end
data/rspec-spies.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "rspec-spies"
8
- s.version = "2.1.0"
8
+ s.version = "2.1.1"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Joshua Nichols"]
12
- s.date = "2012-01-31"
12
+ s.date = "2012-09-05"
13
13
  s.description = "test spies, for rspec"
14
14
  s.email = "josh@technicalpickles.com"
15
15
  s.extra_rdoc_files = [
@@ -32,24 +32,36 @@ Gem::Specification.new do |s|
32
32
  ]
33
33
  s.homepage = "http://github.com/technicalpickles/rspec-spies"
34
34
  s.require_paths = ["lib"]
35
- s.rubygems_version = "1.8.10"
35
+ s.rubygems_version = "1.8.24"
36
36
  s.summary = "rspec has gone without tests spies. no more!"
37
37
 
38
38
  if s.respond_to? :specification_version then
39
39
  s.specification_version = 3
40
40
 
41
41
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
42
+ s.add_runtime_dependency(%q<rspec-spies>, [">= 0"])
43
+ s.add_development_dependency(%q<rake>, [">= 0"])
44
+ s.add_development_dependency(%q<jeweler>, [">= 0"])
45
+ s.add_development_dependency(%q<rdoc>, [">= 0"])
42
46
  s.add_runtime_dependency(%q<rspec>, ["~> 2.0"])
43
47
  s.add_development_dependency(%q<rake>, [">= 0"])
44
48
  s.add_development_dependency(%q<jeweler>, [">= 0"])
45
49
  s.add_development_dependency(%q<rdoc>, [">= 0"])
46
50
  else
51
+ s.add_dependency(%q<rspec-spies>, [">= 0"])
52
+ s.add_dependency(%q<rake>, [">= 0"])
53
+ s.add_dependency(%q<jeweler>, [">= 0"])
54
+ s.add_dependency(%q<rdoc>, [">= 0"])
47
55
  s.add_dependency(%q<rspec>, ["~> 2.0"])
48
56
  s.add_dependency(%q<rake>, [">= 0"])
49
57
  s.add_dependency(%q<jeweler>, [">= 0"])
50
58
  s.add_dependency(%q<rdoc>, [">= 0"])
51
59
  end
52
60
  else
61
+ s.add_dependency(%q<rspec-spies>, [">= 0"])
62
+ s.add_dependency(%q<rake>, [">= 0"])
63
+ s.add_dependency(%q<jeweler>, [">= 0"])
64
+ s.add_dependency(%q<rdoc>, [">= 0"])
53
65
  s.add_dependency(%q<rspec>, ["~> 2.0"])
54
66
  s.add_dependency(%q<rake>, [">= 0"])
55
67
  s.add_dependency(%q<jeweler>, [">= 0"])
@@ -7,13 +7,36 @@ module Spec
7
7
  @object = String.new("HI!")
8
8
  end
9
9
 
10
- it "does match if method is called with correct args" do
10
+ it "matches if method is called with correct args" do
11
11
  @object.stub!(:slice)
12
12
  @object.slice(5)
13
13
 
14
14
  have_received(:slice).with(5).matches?(@object).should be_true
15
15
  end
16
16
 
17
+ it "matches if doesn't specify args, even if method is called with args" do
18
+ @object.stub!(:slice)
19
+ @object.slice(5)
20
+
21
+ have_received(:slice).matches?(@object).should be_true
22
+ end
23
+
24
+ it "matches if specifies nil arg, if method is called with a nil arg" do
25
+ @object.stub!(:slice)
26
+ @object.slice(nil)
27
+
28
+ have_received(:slice).with(nil).matches?(@object).should be_true
29
+ have_received(:slice).matches?(@object).should be_true
30
+ end
31
+
32
+ it "matches if specifies hash_including, if method is called with has including arguments" do
33
+ @object.stub!(:slice)
34
+ @object.slice({ :foo => :bar, :baz => :quux })
35
+
36
+ have_received(:slice).with(hash_including({ :foo => :bar })).matches?(@object).should be_true
37
+ have_received(:slice).with(hash_including({ :foo => :baz })).matches?(@object).should be_false
38
+ end
39
+
17
40
  it "does not match if method is called with incorrect args" do
18
41
  @object.stub!(:slice)
19
42
  @object.slice(3)
metadata CHANGED
@@ -1,68 +1,145 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: rspec-spies
3
- version: !ruby/object:Gem::Version
4
- version: 2.1.0
3
+ version: !ruby/object:Gem::Version
4
+ hash: 9
5
5
  prerelease:
6
+ segments:
7
+ - 2
8
+ - 1
9
+ - 1
10
+ version: 2.1.1
6
11
  platform: ruby
7
- authors:
12
+ authors:
8
13
  - Joshua Nichols
9
14
  autorequire:
10
15
  bindir: bin
11
16
  cert_chain: []
12
- date: 2012-01-31 00:00:00.000000000Z
13
- dependencies:
14
- - !ruby/object:Gem::Dependency
17
+
18
+ date: 2012-09-05 00:00:00 Z
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
21
+ name: rspec-spies
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
24
+ none: false
25
+ requirements:
26
+ - - ">="
27
+ - !ruby/object:Gem::Version
28
+ hash: 3
29
+ segments:
30
+ - 0
31
+ version: "0"
32
+ type: :runtime
33
+ version_requirements: *id001
34
+ - !ruby/object:Gem::Dependency
35
+ name: rake
36
+ prerelease: false
37
+ requirement: &id002 !ruby/object:Gem::Requirement
38
+ none: false
39
+ requirements:
40
+ - - ">="
41
+ - !ruby/object:Gem::Version
42
+ hash: 3
43
+ segments:
44
+ - 0
45
+ version: "0"
46
+ type: :development
47
+ version_requirements: *id002
48
+ - !ruby/object:Gem::Dependency
49
+ name: jeweler
50
+ prerelease: false
51
+ requirement: &id003 !ruby/object:Gem::Requirement
52
+ none: false
53
+ requirements:
54
+ - - ">="
55
+ - !ruby/object:Gem::Version
56
+ hash: 3
57
+ segments:
58
+ - 0
59
+ version: "0"
60
+ type: :development
61
+ version_requirements: *id003
62
+ - !ruby/object:Gem::Dependency
63
+ name: rdoc
64
+ prerelease: false
65
+ requirement: &id004 !ruby/object:Gem::Requirement
66
+ none: false
67
+ requirements:
68
+ - - ">="
69
+ - !ruby/object:Gem::Version
70
+ hash: 3
71
+ segments:
72
+ - 0
73
+ version: "0"
74
+ type: :development
75
+ version_requirements: *id004
76
+ - !ruby/object:Gem::Dependency
15
77
  name: rspec
16
- requirement: &70331177385760 !ruby/object:Gem::Requirement
78
+ prerelease: false
79
+ requirement: &id005 !ruby/object:Gem::Requirement
17
80
  none: false
18
- requirements:
81
+ requirements:
19
82
  - - ~>
20
- - !ruby/object:Gem::Version
21
- version: '2.0'
83
+ - !ruby/object:Gem::Version
84
+ hash: 3
85
+ segments:
86
+ - 2
87
+ - 0
88
+ version: "2.0"
22
89
  type: :runtime
23
- prerelease: false
24
- version_requirements: *70331177385760
25
- - !ruby/object:Gem::Dependency
90
+ version_requirements: *id005
91
+ - !ruby/object:Gem::Dependency
26
92
  name: rake
27
- requirement: &70331177385060 !ruby/object:Gem::Requirement
93
+ prerelease: false
94
+ requirement: &id006 !ruby/object:Gem::Requirement
28
95
  none: false
29
- requirements:
30
- - - ! '>='
31
- - !ruby/object:Gem::Version
32
- version: '0'
96
+ requirements:
97
+ - - ">="
98
+ - !ruby/object:Gem::Version
99
+ hash: 3
100
+ segments:
101
+ - 0
102
+ version: "0"
33
103
  type: :development
34
- prerelease: false
35
- version_requirements: *70331177385060
36
- - !ruby/object:Gem::Dependency
104
+ version_requirements: *id006
105
+ - !ruby/object:Gem::Dependency
37
106
  name: jeweler
38
- requirement: &70331177384440 !ruby/object:Gem::Requirement
107
+ prerelease: false
108
+ requirement: &id007 !ruby/object:Gem::Requirement
39
109
  none: false
40
- requirements:
41
- - - ! '>='
42
- - !ruby/object:Gem::Version
43
- version: '0'
110
+ requirements:
111
+ - - ">="
112
+ - !ruby/object:Gem::Version
113
+ hash: 3
114
+ segments:
115
+ - 0
116
+ version: "0"
44
117
  type: :development
45
- prerelease: false
46
- version_requirements: *70331177384440
47
- - !ruby/object:Gem::Dependency
118
+ version_requirements: *id007
119
+ - !ruby/object:Gem::Dependency
48
120
  name: rdoc
49
- requirement: &70331177383920 !ruby/object:Gem::Requirement
121
+ prerelease: false
122
+ requirement: &id008 !ruby/object:Gem::Requirement
50
123
  none: false
51
- requirements:
52
- - - ! '>='
53
- - !ruby/object:Gem::Version
54
- version: '0'
124
+ requirements:
125
+ - - ">="
126
+ - !ruby/object:Gem::Version
127
+ hash: 3
128
+ segments:
129
+ - 0
130
+ version: "0"
55
131
  type: :development
56
- prerelease: false
57
- version_requirements: *70331177383920
132
+ version_requirements: *id008
58
133
  description: test spies, for rspec
59
134
  email: josh@technicalpickles.com
60
135
  executables: []
136
+
61
137
  extensions: []
62
- extra_rdoc_files:
138
+
139
+ extra_rdoc_files:
63
140
  - LICENSE
64
141
  - README.rdoc
65
- files:
142
+ files:
66
143
  - .document
67
144
  - Gemfile
68
145
  - Gemfile.lock
@@ -77,29 +154,36 @@ files:
77
154
  - spec/spec_helper.rb
78
155
  homepage: http://github.com/technicalpickles/rspec-spies
79
156
  licenses: []
157
+
80
158
  post_install_message:
81
159
  rdoc_options: []
82
- require_paths:
160
+
161
+ require_paths:
83
162
  - lib
84
- required_ruby_version: !ruby/object:Gem::Requirement
163
+ required_ruby_version: !ruby/object:Gem::Requirement
85
164
  none: false
86
- requirements:
87
- - - ! '>='
88
- - !ruby/object:Gem::Version
89
- version: '0'
90
- segments:
165
+ requirements:
166
+ - - ">="
167
+ - !ruby/object:Gem::Version
168
+ hash: 3
169
+ segments:
91
170
  - 0
92
- hash: -2045128620934632625
93
- required_rubygems_version: !ruby/object:Gem::Requirement
171
+ version: "0"
172
+ required_rubygems_version: !ruby/object:Gem::Requirement
94
173
  none: false
95
- requirements:
96
- - - ! '>='
97
- - !ruby/object:Gem::Version
98
- version: '0'
174
+ requirements:
175
+ - - ">="
176
+ - !ruby/object:Gem::Version
177
+ hash: 3
178
+ segments:
179
+ - 0
180
+ version: "0"
99
181
  requirements: []
182
+
100
183
  rubyforge_project:
101
- rubygems_version: 1.8.10
184
+ rubygems_version: 1.8.24
102
185
  signing_key:
103
186
  specification_version: 3
104
187
  summary: rspec has gone without tests spies. no more!
105
188
  test_files: []
189
+