rr-matchy 0.1.0
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.
- data/.document +5 -0
- data/.gitignore +21 -0
- data/LICENSE +20 -0
- data/README.md +36 -0
- data/Rakefile +55 -0
- data/VERSION +1 -0
- data/lib/rr-matchy.rb +28 -0
- data/rr-matchy.gemspec +57 -0
- data/test/rr-matchy_test.rb +7 -0
- data/test/test_helper.rb +7 -0
- metadata +85 -0
data/.document
ADDED
data/.gitignore
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2010 Elliot Winkler
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
# rr-matchy
|
2
|
+
|
3
|
+
## Summary
|
4
|
+
|
5
|
+
A matcher for use with Jeremy McAnally's `matchy` that integrates with RR.
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
gem install rr-matchy
|
10
|
+
|
11
|
+
## Usage
|
12
|
+
|
13
|
+
Somewhere in your `test_helper.rb`:
|
14
|
+
|
15
|
+
require 'rr-matchy'
|
16
|
+
|
17
|
+
class Test::Unit::TestCase
|
18
|
+
include RR::Adapters::TestUnit
|
19
|
+
extend RRMatchy
|
20
|
+
end
|
21
|
+
|
22
|
+
Now you can say:
|
23
|
+
|
24
|
+
this.should have_received(:that)
|
25
|
+
|
26
|
+
and
|
27
|
+
|
28
|
+
this.should_not have_received(:that)
|
29
|
+
|
30
|
+
## TODO
|
31
|
+
|
32
|
+
Probably should submit a pull request to btakita eventually, but we'll see how this works first.
|
33
|
+
|
34
|
+
## Author/License
|
35
|
+
|
36
|
+
Copyright (c) 2010 Elliot Winkler. See LICENSE for details.
|
data/Rakefile
ADDED
@@ -0,0 +1,55 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake'
|
3
|
+
|
4
|
+
begin
|
5
|
+
require 'jeweler'
|
6
|
+
Jeweler::Tasks.new do |gem|
|
7
|
+
gem.name = "rr-matchy"
|
8
|
+
gem.summary = %Q{Matchy matcher for RR}
|
9
|
+
gem.description = %Q{Matchy matcher for RR}
|
10
|
+
gem.email = "elliot.winkler@gmail.com"
|
11
|
+
gem.homepage = "http://github.com/mcmire/rr-matchy"
|
12
|
+
gem.authors = ["Elliot Winkler"]
|
13
|
+
gem.add_dependency "rr", ">= 0.10.5"
|
14
|
+
gem.add_dependency "mcmire-matchy"
|
15
|
+
#gem.add_development_dependency "test-spec", ">= 0"
|
16
|
+
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
|
17
|
+
end
|
18
|
+
Jeweler::GemcutterTasks.new
|
19
|
+
rescue LoadError
|
20
|
+
puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
|
21
|
+
end
|
22
|
+
|
23
|
+
require 'rake/testtask'
|
24
|
+
Rake::TestTask.new(:test) do |test|
|
25
|
+
test.libs << 'lib' << 'test'
|
26
|
+
test.pattern = 'test/**/*_test.rb'
|
27
|
+
test.verbose = true
|
28
|
+
end
|
29
|
+
|
30
|
+
begin
|
31
|
+
require 'rcov/rcovtask'
|
32
|
+
Rcov::RcovTask.new do |test|
|
33
|
+
test.libs << 'test'
|
34
|
+
test.pattern = 'test/**/*_test.rb'
|
35
|
+
test.verbose = true
|
36
|
+
end
|
37
|
+
rescue LoadError
|
38
|
+
task :rcov do
|
39
|
+
abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
task :test => :check_dependencies
|
44
|
+
|
45
|
+
task :default => :test
|
46
|
+
|
47
|
+
require 'rake/rdoctask'
|
48
|
+
Rake::RDocTask.new do |rdoc|
|
49
|
+
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
50
|
+
|
51
|
+
rdoc.rdoc_dir = 'rdoc'
|
52
|
+
rdoc.title = "rr-matchy #{version}"
|
53
|
+
rdoc.rdoc_files.include('README*')
|
54
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
55
|
+
end
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.1.0
|
data/lib/rr-matchy.rb
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'rr'
|
2
|
+
require 'matchy'
|
3
|
+
|
4
|
+
module RRMatchy
|
5
|
+
custom_matcher :have_received do |subject, matcher, args|
|
6
|
+
proxy = RR::SpyVerificationProxy.new(subject)
|
7
|
+
verification = nil
|
8
|
+
if args[0]
|
9
|
+
# subject.should have_received(:foo)
|
10
|
+
verification = proxy.method_missing(args[0])
|
11
|
+
else
|
12
|
+
# subject.should have_received.foo(1)
|
13
|
+
first_msg = matcher.chained_messages.shift
|
14
|
+
verification = proxy.method_missing(first_msg.name, *first_msg.args, &first_msg.block)
|
15
|
+
for msg in matcher.chained_messages
|
16
|
+
# subject.should have_received.foo(1).once
|
17
|
+
verification.send(msg.name, *msg.args, &msg.block)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
calls = RR::Space.instance.recorded_calls
|
21
|
+
if error = calls.match_error(verification)
|
22
|
+
matcher.positive_failure_message = error.message
|
23
|
+
false
|
24
|
+
else
|
25
|
+
true
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
data/rr-matchy.gemspec
ADDED
@@ -0,0 +1,57 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = %q{rr-matchy}
|
8
|
+
s.version = "0.1.0"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["Elliot Winkler"]
|
12
|
+
s.date = %q{2010-01-06}
|
13
|
+
s.description = %q{Matchy matcher for RR}
|
14
|
+
s.email = %q{elliot.winkler@gmail.com}
|
15
|
+
s.extra_rdoc_files = [
|
16
|
+
"LICENSE",
|
17
|
+
"README.md"
|
18
|
+
]
|
19
|
+
s.files = [
|
20
|
+
".document",
|
21
|
+
".gitignore",
|
22
|
+
"LICENSE",
|
23
|
+
"README.md",
|
24
|
+
"Rakefile",
|
25
|
+
"VERSION",
|
26
|
+
"lib/rr-matchy.rb",
|
27
|
+
"rr-matchy.gemspec",
|
28
|
+
"test/rr-matchy_test.rb",
|
29
|
+
"test/test_helper.rb"
|
30
|
+
]
|
31
|
+
s.homepage = %q{http://github.com/mcmire/rr-matchy}
|
32
|
+
s.rdoc_options = ["--charset=UTF-8"]
|
33
|
+
s.require_paths = ["lib"]
|
34
|
+
s.rubygems_version = %q{1.3.5}
|
35
|
+
s.summary = %q{Matchy matcher for RR}
|
36
|
+
s.test_files = [
|
37
|
+
"test/rr-matchy_test.rb",
|
38
|
+
"test/test_helper.rb"
|
39
|
+
]
|
40
|
+
|
41
|
+
if s.respond_to? :specification_version then
|
42
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
43
|
+
s.specification_version = 3
|
44
|
+
|
45
|
+
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
46
|
+
s.add_runtime_dependency(%q<rr>, [">= 0.10.5"])
|
47
|
+
s.add_runtime_dependency(%q<mcmire-matchy>, [">= 0"])
|
48
|
+
else
|
49
|
+
s.add_dependency(%q<rr>, [">= 0.10.5"])
|
50
|
+
s.add_dependency(%q<mcmire-matchy>, [">= 0"])
|
51
|
+
end
|
52
|
+
else
|
53
|
+
s.add_dependency(%q<rr>, [">= 0.10.5"])
|
54
|
+
s.add_dependency(%q<mcmire-matchy>, [">= 0"])
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
data/test/test_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,85 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: rr-matchy
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Elliot Winkler
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2010-01-06 00:00:00 -06:00
|
13
|
+
default_executable:
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: rr
|
17
|
+
type: :runtime
|
18
|
+
version_requirement:
|
19
|
+
version_requirements: !ruby/object:Gem::Requirement
|
20
|
+
requirements:
|
21
|
+
- - ">="
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: 0.10.5
|
24
|
+
version:
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: mcmire-matchy
|
27
|
+
type: :runtime
|
28
|
+
version_requirement:
|
29
|
+
version_requirements: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: "0"
|
34
|
+
version:
|
35
|
+
description: Matchy matcher for RR
|
36
|
+
email: elliot.winkler@gmail.com
|
37
|
+
executables: []
|
38
|
+
|
39
|
+
extensions: []
|
40
|
+
|
41
|
+
extra_rdoc_files:
|
42
|
+
- LICENSE
|
43
|
+
- README.md
|
44
|
+
files:
|
45
|
+
- .document
|
46
|
+
- .gitignore
|
47
|
+
- LICENSE
|
48
|
+
- README.md
|
49
|
+
- Rakefile
|
50
|
+
- VERSION
|
51
|
+
- lib/rr-matchy.rb
|
52
|
+
- rr-matchy.gemspec
|
53
|
+
- test/rr-matchy_test.rb
|
54
|
+
- test/test_helper.rb
|
55
|
+
has_rdoc: true
|
56
|
+
homepage: http://github.com/mcmire/rr-matchy
|
57
|
+
licenses: []
|
58
|
+
|
59
|
+
post_install_message:
|
60
|
+
rdoc_options:
|
61
|
+
- --charset=UTF-8
|
62
|
+
require_paths:
|
63
|
+
- lib
|
64
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: "0"
|
69
|
+
version:
|
70
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
71
|
+
requirements:
|
72
|
+
- - ">="
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: "0"
|
75
|
+
version:
|
76
|
+
requirements: []
|
77
|
+
|
78
|
+
rubyforge_project:
|
79
|
+
rubygems_version: 1.3.5
|
80
|
+
signing_key:
|
81
|
+
specification_version: 3
|
82
|
+
summary: Matchy matcher for RR
|
83
|
+
test_files:
|
84
|
+
- test/rr-matchy_test.rb
|
85
|
+
- test/test_helper.rb
|