mocha 0.5.3 → 0.5.4
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/RELEASE +4 -0
- data/Rakefile +2 -2
- data/lib/mocha/parameter_matchers/matches.rb +39 -0
- data/test/unit/parameter_matchers/matches_test.rb +25 -0
- metadata +4 -2
data/RELEASE
CHANGED
data/Rakefile
CHANGED
@@ -5,7 +5,7 @@ require 'rake/testtask'
|
|
5
5
|
require 'rake/contrib/sshpublisher'
|
6
6
|
|
7
7
|
module Mocha
|
8
|
-
VERSION = "0.5.
|
8
|
+
VERSION = "0.5.4"
|
9
9
|
end
|
10
10
|
|
11
11
|
desc "Run all tests"
|
@@ -40,7 +40,7 @@ end
|
|
40
40
|
desc 'Generate RDoc'
|
41
41
|
Rake::RDocTask.new do |task|
|
42
42
|
task.main = 'README'
|
43
|
-
task.title =
|
43
|
+
task.title = "Mocha #{Mocha::VERSION}"
|
44
44
|
task.rdoc_dir = 'doc'
|
45
45
|
task.template = File.expand_path(File.join(File.dirname(__FILE__), "templates", "html_with_google_analytics"))
|
46
46
|
task.rdoc_files.include('README', 'RELEASE', 'COPYING', 'MIT-LICENSE', 'agiledox.txt', 'lib/mocha/auto_verify.rb', 'lib/mocha/mock.rb', 'lib/mocha/expectation.rb', 'lib/mocha/object.rb', 'lib/mocha/parameter_matchers.rb', 'lib/mocha/parameter_matchers')
|
@@ -0,0 +1,39 @@
|
|
1
|
+
module Mocha
|
2
|
+
|
3
|
+
module ParameterMatchers
|
4
|
+
|
5
|
+
# :call-seq: matches(regular_expression) -> parameter_matcher
|
6
|
+
#
|
7
|
+
# Matches any object matching +regular_expression+.
|
8
|
+
# object = mock()
|
9
|
+
# object.expects(:method_1).with(matches(/oo/))
|
10
|
+
# object.method_1('foo')
|
11
|
+
# # no error raised
|
12
|
+
#
|
13
|
+
# object = mock()
|
14
|
+
# object.expects(:method_1).with(matches(/oo/))
|
15
|
+
# object.method_1('bar')
|
16
|
+
# # error raised, because method_1 was not called with parameter matching regular expression: /oo/
|
17
|
+
def matches(regular_expression)
|
18
|
+
Matches.new(regular_expression)
|
19
|
+
end
|
20
|
+
|
21
|
+
class Matches # :nodoc:
|
22
|
+
|
23
|
+
def initialize(regular_expression)
|
24
|
+
@regular_expression = regular_expression
|
25
|
+
end
|
26
|
+
|
27
|
+
def ==(parameter)
|
28
|
+
@regular_expression.match(parameter)
|
29
|
+
end
|
30
|
+
|
31
|
+
def mocha_inspect
|
32
|
+
"matches(#{@regular_expression.mocha_inspect})"
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), "..", "..", "test_helper")
|
2
|
+
|
3
|
+
require 'mocha/parameter_matchers/matches'
|
4
|
+
require 'mocha/inspect'
|
5
|
+
|
6
|
+
class MatchesTest < Test::Unit::TestCase
|
7
|
+
|
8
|
+
include Mocha::ParameterMatchers
|
9
|
+
|
10
|
+
def test_should_match_parameter_matching_regular_expression
|
11
|
+
matcher = matches(/oo/)
|
12
|
+
assert matcher == 'foo'
|
13
|
+
end
|
14
|
+
|
15
|
+
def test_should_not_match_parameter_not_matching_regular_expression
|
16
|
+
matcher = matches(/oo/)
|
17
|
+
assert matcher != 'bar'
|
18
|
+
end
|
19
|
+
|
20
|
+
def test_should_describe_matcher
|
21
|
+
matcher = matches(/oo/)
|
22
|
+
assert_equal "matches(/oo/)", matcher.mocha_inspect
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
metadata
CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.9.2
|
|
3
3
|
specification_version: 1
|
4
4
|
name: mocha
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 0.5.
|
7
|
-
date: 2007-
|
6
|
+
version: 0.5.4
|
7
|
+
date: 2007-08-28 00:00:00 +01:00
|
8
8
|
summary: Mocking and stubbing library
|
9
9
|
require_paths:
|
10
10
|
- lib
|
@@ -57,6 +57,7 @@ files:
|
|
57
57
|
- lib/mocha/parameter_matchers/includes.rb
|
58
58
|
- lib/mocha/parameter_matchers/instance_of.rb
|
59
59
|
- lib/mocha/parameter_matchers/kind_of.rb
|
60
|
+
- lib/mocha/parameter_matchers/matches.rb
|
60
61
|
- lib/mocha/parameter_matchers.rb
|
61
62
|
- lib/mocha/pretty_parameters.rb
|
62
63
|
- lib/mocha/return_values.rb
|
@@ -112,6 +113,7 @@ files:
|
|
112
113
|
- test/unit/parameter_matchers/includes_test.rb
|
113
114
|
- test/unit/parameter_matchers/instance_of_test.rb
|
114
115
|
- test/unit/parameter_matchers/kind_of_test.rb
|
116
|
+
- test/unit/parameter_matchers/matches_test.rb
|
115
117
|
- test/unit/parameter_matchers/stub_matcher.rb
|
116
118
|
- test/unit/pretty_parameters_test.rb
|
117
119
|
- test/unit/return_values_test.rb
|