rspec-spies 1.2.9 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +7 -0
- data/Gemfile.lock +27 -0
- data/README.rdoc +1 -1
- data/Rakefile +22 -27
- data/VERSION +1 -1
- data/lib/rspec-spies.rb +21 -26
- data/spec/rspec-spies_spec.rb +18 -1
- data/spec/spec_helper.rb +3 -3
- metadata +74 -15
- data/.gitignore +0 -21
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
GEM
|
2
|
+
specs:
|
3
|
+
diff-lcs (1.1.2)
|
4
|
+
git (1.2.5)
|
5
|
+
jeweler (1.6.4)
|
6
|
+
bundler (~> 1.0)
|
7
|
+
git (>= 1.2.5)
|
8
|
+
rake
|
9
|
+
rake (0.9.2)
|
10
|
+
rdoc (3.6.1)
|
11
|
+
rspec (2.6.0)
|
12
|
+
rspec-core (~> 2.6.0)
|
13
|
+
rspec-expectations (~> 2.6.0)
|
14
|
+
rspec-mocks (~> 2.6.0)
|
15
|
+
rspec-core (2.6.4)
|
16
|
+
rspec-expectations (2.6.0)
|
17
|
+
diff-lcs (~> 1.1.2)
|
18
|
+
rspec-mocks (2.6.0)
|
19
|
+
|
20
|
+
PLATFORMS
|
21
|
+
ruby
|
22
|
+
|
23
|
+
DEPENDENCIES
|
24
|
+
jeweler
|
25
|
+
rake
|
26
|
+
rdoc
|
27
|
+
rspec (~> 2.0)
|
data/README.rdoc
CHANGED
@@ -23,7 +23,7 @@ In general, I think it should work by doing your usual stub!, followed running t
|
|
23
23
|
|
24
24
|
To get started, you just need to:
|
25
25
|
|
26
|
-
* Run: gem install rspec-spies
|
26
|
+
* Run: gem install rspec-spies --source http://gemcutter.org
|
27
27
|
* Update spec_helper to include this line: require 'rspec-spies'
|
28
28
|
|
29
29
|
|
data/Rakefile
CHANGED
@@ -1,41 +1,36 @@
|
|
1
1
|
require 'rubygems'
|
2
|
+
require 'bundler'
|
3
|
+
Bundler.setup(:default, :development)
|
4
|
+
|
2
5
|
require 'rake'
|
3
6
|
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
gem.add_development_dependency "rspec", ">= 1.2.9"
|
14
|
-
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
|
15
|
-
end
|
16
|
-
Jeweler::GemcutterTasks.new
|
17
|
-
rescue LoadError
|
18
|
-
puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
|
7
|
+
require 'jeweler'
|
8
|
+
Jeweler::Tasks.new do |gem|
|
9
|
+
gem.name = "rspec-spies"
|
10
|
+
gem.summary = %Q{rspec has gone without tests spies. no more!}
|
11
|
+
gem.description = %Q{test spies, for rspec}
|
12
|
+
gem.email = "josh@technicalpickles.com"
|
13
|
+
gem.homepage = "http://github.com/technicalpickles/rspec-spies"
|
14
|
+
gem.authors = ["Joshua Nichols"]
|
15
|
+
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
|
19
16
|
end
|
17
|
+
Jeweler::GemcutterTasks.new
|
20
18
|
|
21
|
-
require '
|
22
|
-
|
23
|
-
|
24
|
-
spec.spec_files = FileList['spec/**/*_spec.rb']
|
19
|
+
require 'rspec/core/rake_task'
|
20
|
+
RSpec::Core::RakeTask.new do |t|
|
21
|
+
t.pattern = FileList['spec/**/*_spec.rb']
|
25
22
|
end
|
26
23
|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
24
|
+
RSpec::Core::RakeTask.new(:rcov) do |t|
|
25
|
+
t.pattern = FileList['spec/**/*_spec.rb']
|
26
|
+
t.rcov = true
|
27
|
+
t.rcov_opts = ['--exclude', 'spec']
|
31
28
|
end
|
32
29
|
|
33
|
-
task :spec => :check_dependencies
|
34
|
-
|
35
30
|
task :default => :spec
|
36
31
|
|
37
|
-
require '
|
38
|
-
|
32
|
+
require 'rdoc/task'
|
33
|
+
RDoc::Task.new do |rdoc|
|
39
34
|
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
40
35
|
|
41
36
|
rdoc.rdoc_dir = 'rdoc'
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
2.0.0
|
data/lib/rspec-spies.rb
CHANGED
@@ -1,49 +1,44 @@
|
|
1
|
-
require '
|
2
|
-
|
1
|
+
require 'rspec/mocks/method_double'
|
2
|
+
RSpec::Mocks::MethodDouble.class_eval do
|
3
3
|
# override defining stubs to record the message was called.
|
4
4
|
# there's only one line difference from upstream rspec, but can't change it without fully overriding
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
end
|
16
|
-
target_metaclass.class_eval(<<-EOF, __FILE__, __LINE__)
|
17
|
-
def #{sym}(*args, &block)
|
18
|
-
__mock_proxy.record_message_received(:#{sym}, args, block) # this is the only line changed by rspec-spies in this method
|
19
|
-
__mock_proxy.message_received :#{sym}, *args, &block
|
20
|
-
end
|
21
|
-
#{visibility_string}
|
22
|
-
EOF
|
23
|
-
end
|
5
|
+
def define_proxy_method
|
6
|
+
method_name = @method_name
|
7
|
+
visibility_for_method = "#{visibility} :#{method_name}"
|
8
|
+
object_singleton_class.class_eval(<<-EOF, __FILE__, __LINE__)
|
9
|
+
def #{method_name}(*args, &block)
|
10
|
+
__mock_proxy.record_message_received :#{method_name}, *args, &block
|
11
|
+
__mock_proxy.message_received :#{method_name}, *args, &block
|
12
|
+
end
|
13
|
+
#{visibility_for_method}
|
14
|
+
EOF
|
24
15
|
end
|
25
16
|
end
|
26
17
|
|
27
|
-
require '
|
28
|
-
|
18
|
+
require 'rspec/matchers'
|
19
|
+
RSpec::Matchers.module_eval do
|
29
20
|
def have_received(sym, &block)
|
30
|
-
|
21
|
+
RSpec::Matchers::Matcher.new :have_received, sym, @args, block do |sym, args, block|
|
31
22
|
match do |actual|
|
32
23
|
actual.received_message?(sym, *@args, &block)
|
33
24
|
end
|
34
25
|
|
26
|
+
|
35
27
|
failure_message_for_should do |actual|
|
36
|
-
"expected #{actual.inspect} to have received #{sym.inspect} with #{args.inspect}"
|
28
|
+
"expected #{actual.inspect} to have received #{sym.inspect} with #{@args.inspect}"
|
37
29
|
end
|
38
30
|
|
31
|
+
|
39
32
|
failure_message_for_should_not do |actual|
|
40
|
-
"expected #{actual.inspect} to not have received #{sym.inspect} with #{args.inspect}, but did"
|
33
|
+
"expected #{actual.inspect} to not have received #{sym.inspect} with #{@args.inspect}, but did"
|
41
34
|
end
|
42
35
|
|
36
|
+
|
43
37
|
description do
|
44
38
|
"to have received #{sym.inspect} with #{args.inspect}"
|
45
39
|
end
|
46
40
|
|
41
|
+
|
47
42
|
def with(*args)
|
48
43
|
@args = args
|
49
44
|
self
|
data/spec/rspec-spies_spec.rb
CHANGED
@@ -4,7 +4,7 @@ module Spec
|
|
4
4
|
module Matchers
|
5
5
|
describe "[object.should] have_received(method, *args)" do
|
6
6
|
before do
|
7
|
-
@object = String.new
|
7
|
+
@object = String.new("HI!")
|
8
8
|
end
|
9
9
|
|
10
10
|
it "does match if method is called with correct args" do
|
@@ -27,6 +27,23 @@ module Spec
|
|
27
27
|
have_received(:slice).with(5).matches?(@object).should be_false
|
28
28
|
end
|
29
29
|
|
30
|
+
it "correctly lists expects arguments for should" do
|
31
|
+
@object.stub!(:slice)
|
32
|
+
|
33
|
+
matcher = have_received(:slice).with(5, 3)
|
34
|
+
messages = matcher.instance_variable_get("@messages")
|
35
|
+
message = messages[:failure_message_for_should].call(@object)
|
36
|
+
message.should == "expected \"HI!\" to have received :slice with [5, 3]"
|
37
|
+
end
|
38
|
+
|
39
|
+
it "correctly lists expects arguments for should_not" do
|
40
|
+
@object.stub!(:slice)
|
41
|
+
|
42
|
+
matcher = have_received(:slice).with(1, 2)
|
43
|
+
messages = matcher.instance_variable_get("@messages")
|
44
|
+
message = messages[:failure_message_for_should_not].call(@object)
|
45
|
+
message.should == "expected \"HI!\" to not have received :slice with [1, 2], but did"
|
46
|
+
end
|
30
47
|
end
|
31
48
|
|
32
49
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
2
2
|
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
3
|
-
require '
|
4
|
-
require '
|
3
|
+
require 'rspec'
|
4
|
+
require 'rspec/autorun'
|
5
5
|
|
6
6
|
require 'rspec-spies'
|
7
7
|
|
8
|
-
|
8
|
+
RSpec.configure do |config|
|
9
9
|
end
|
metadata
CHANGED
@@ -1,7 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rspec-spies
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
4
|
+
hash: 15
|
5
|
+
prerelease:
|
6
|
+
segments:
|
7
|
+
- 2
|
8
|
+
- 0
|
9
|
+
- 0
|
10
|
+
version: 2.0.0
|
5
11
|
platform: ruby
|
6
12
|
authors:
|
7
13
|
- Joshua Nichols
|
@@ -9,19 +15,66 @@ autorequire:
|
|
9
15
|
bindir: bin
|
10
16
|
cert_chain: []
|
11
17
|
|
12
|
-
date:
|
18
|
+
date: 2011-07-07 00:00:00 -04:00
|
13
19
|
default_executable:
|
14
20
|
dependencies:
|
15
21
|
- !ruby/object:Gem::Dependency
|
22
|
+
type: :runtime
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
24
|
+
none: false
|
25
|
+
requirements:
|
26
|
+
- - ~>
|
27
|
+
- !ruby/object:Gem::Version
|
28
|
+
hash: 3
|
29
|
+
segments:
|
30
|
+
- 2
|
31
|
+
- 0
|
32
|
+
version: "2.0"
|
33
|
+
version_requirements: *id001
|
16
34
|
name: rspec
|
35
|
+
prerelease: false
|
36
|
+
- !ruby/object:Gem::Dependency
|
17
37
|
type: :development
|
18
|
-
|
19
|
-
|
38
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
20
40
|
requirements:
|
21
41
|
- - ">="
|
22
42
|
- !ruby/object:Gem::Version
|
23
|
-
|
24
|
-
|
43
|
+
hash: 3
|
44
|
+
segments:
|
45
|
+
- 0
|
46
|
+
version: "0"
|
47
|
+
version_requirements: *id002
|
48
|
+
name: rake
|
49
|
+
prerelease: false
|
50
|
+
- !ruby/object:Gem::Dependency
|
51
|
+
type: :development
|
52
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
53
|
+
none: false
|
54
|
+
requirements:
|
55
|
+
- - ">="
|
56
|
+
- !ruby/object:Gem::Version
|
57
|
+
hash: 3
|
58
|
+
segments:
|
59
|
+
- 0
|
60
|
+
version: "0"
|
61
|
+
version_requirements: *id003
|
62
|
+
name: jeweler
|
63
|
+
prerelease: false
|
64
|
+
- !ruby/object:Gem::Dependency
|
65
|
+
type: :development
|
66
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
67
|
+
none: false
|
68
|
+
requirements:
|
69
|
+
- - ">="
|
70
|
+
- !ruby/object:Gem::Version
|
71
|
+
hash: 3
|
72
|
+
segments:
|
73
|
+
- 0
|
74
|
+
version: "0"
|
75
|
+
version_requirements: *id004
|
76
|
+
name: rdoc
|
77
|
+
prerelease: false
|
25
78
|
description: test spies, for rspec
|
26
79
|
email: josh@technicalpickles.com
|
27
80
|
executables: []
|
@@ -33,7 +86,8 @@ extra_rdoc_files:
|
|
33
86
|
- README.rdoc
|
34
87
|
files:
|
35
88
|
- .document
|
36
|
-
-
|
89
|
+
- Gemfile
|
90
|
+
- Gemfile.lock
|
37
91
|
- LICENSE
|
38
92
|
- README.rdoc
|
39
93
|
- Rakefile
|
@@ -47,29 +101,34 @@ homepage: http://github.com/technicalpickles/rspec-spies
|
|
47
101
|
licenses: []
|
48
102
|
|
49
103
|
post_install_message:
|
50
|
-
rdoc_options:
|
51
|
-
|
104
|
+
rdoc_options: []
|
105
|
+
|
52
106
|
require_paths:
|
53
107
|
- lib
|
54
108
|
required_ruby_version: !ruby/object:Gem::Requirement
|
109
|
+
none: false
|
55
110
|
requirements:
|
56
111
|
- - ">="
|
57
112
|
- !ruby/object:Gem::Version
|
113
|
+
hash: 3
|
114
|
+
segments:
|
115
|
+
- 0
|
58
116
|
version: "0"
|
59
|
-
version:
|
60
117
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
118
|
+
none: false
|
61
119
|
requirements:
|
62
120
|
- - ">="
|
63
121
|
- !ruby/object:Gem::Version
|
122
|
+
hash: 3
|
123
|
+
segments:
|
124
|
+
- 0
|
64
125
|
version: "0"
|
65
|
-
version:
|
66
126
|
requirements: []
|
67
127
|
|
68
128
|
rubyforge_project:
|
69
|
-
rubygems_version: 1.
|
129
|
+
rubygems_version: 1.6.2
|
70
130
|
signing_key:
|
71
131
|
specification_version: 3
|
72
132
|
summary: rspec has gone without tests spies. no more!
|
73
|
-
test_files:
|
74
|
-
|
75
|
-
- spec/spec_helper.rb
|
133
|
+
test_files: []
|
134
|
+
|