surrogate 0.5.2 → 0.5.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.
- data/.gitignore +1 -0
- data/.travis.yml +5 -1
- data/Gemfile +2 -1
- data/Readme.md +2 -1
- data/Readme.md.mountain_berry_fields +2 -1
- data/gemfiles/rspec_mocks_2.10 +8 -0
- data/gemfiles/rspec_mocks_2.2 +8 -0
- data/lib/surrogate/rspec/{have_been_initialized_with.rb → initialization_matcher.rb} +2 -2
- data/lib/surrogate/rspec/{have_been_asked_for_its.rb → noun_matcher.rb} +1 -1
- data/lib/surrogate/rspec/{have_been_asked_if.rb → predicate_matcher.rb} +1 -1
- data/lib/surrogate/rspec/{have_been_told_to.rb → verb_matcher.rb} +1 -1
- data/lib/surrogate/rspec/with_filter.rb +24 -2
- data/lib/surrogate/rspec.rb +12 -12
- data/lib/surrogate/version.rb +1 -1
- data/spec/rspec/{matchers_for_initialization_spec.rb → initialization_matcher_spec.rb} +0 -0
- data/spec/rspec/{matchers_for_nouns_spec.rb → noun_matcher_spec.rb} +0 -0
- data/spec/rspec/{matchers_for_predicates_spec.rb → predicate_matcher_spec.rb} +0 -0
- data/spec/rspec/{matchers_for_verbs_spec.rb → verb_matcher_spec.rb} +0 -0
- data/surrogate.gemspec +2 -2
- metadata +35 -33
data/.gitignore
CHANGED
data/.travis.yml
CHANGED
data/Gemfile
CHANGED
data/Readme.md
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
[](http://travis-ci.org/JoshCheek/surrogate)
|
2
|
+
|
1
3
|
|
2
4
|
|
3
5
|
About
|
@@ -446,7 +448,6 @@ TODO
|
|
446
448
|
----
|
447
449
|
|
448
450
|
* Remove dependency on all of RSpec and only depend on rspec-core, then have AC tests for the other shit
|
449
|
-
* Move surrogates to be first class and defined in the classes that use them.
|
450
451
|
* Add proper failure messages for block invocations
|
451
452
|
* Add a better explanation for motivations
|
452
453
|
* Figure out whether I'm supposed to be using clone or dup for the object -.^ (looks like there may also be an `initialize_copy` method I can take advantage of instead of crazy stupid shit I'm doing now)
|
@@ -1,3 +1,5 @@
|
|
1
|
+
[](http://travis-ci.org/JoshCheek/surrogate)
|
2
|
+
|
1
3
|
<% setup do %>
|
2
4
|
$LOAD_PATH.unshift '../lib', __FILE__
|
3
5
|
require 'surrogate'
|
@@ -531,7 +533,6 @@ TODO
|
|
531
533
|
----
|
532
534
|
|
533
535
|
* Remove dependency on all of RSpec and only depend on rspec-core, then have AC tests for the other shit
|
534
|
-
* Move surrogates to be first class and defined in the classes that use them.
|
535
536
|
* Add proper failure messages for block invocations
|
536
537
|
* Add a better explanation for motivations
|
537
538
|
* Figure out whether I'm supposed to be using clone or dup for the object -.^ (looks like there may also be an `initialize_copy` method I can take advantage of instead of crazy stupid shit I'm doing now)
|
@@ -1,8 +1,8 @@
|
|
1
|
-
require 'surrogate/rspec/
|
1
|
+
require 'surrogate/rspec/verb_matcher'
|
2
2
|
|
3
3
|
class Surrogate
|
4
4
|
module RSpec
|
5
|
-
class
|
5
|
+
class InitializationMatcher < VerbMatcher
|
6
6
|
def initialize(*initialization_args, &block)
|
7
7
|
super :initialize
|
8
8
|
with *initialization_args, &block
|
@@ -2,7 +2,7 @@ require 'surrogate/rspec/invocation_matcher'
|
|
2
2
|
|
3
3
|
class Surrogate
|
4
4
|
module RSpec
|
5
|
-
class
|
5
|
+
class PredicateMatcher < InvocationMatcher
|
6
6
|
class FailureMessageShouldDefault < AbstractFailureMessage
|
7
7
|
def get_message
|
8
8
|
"was never asked if #{ method_name }"
|
@@ -2,7 +2,7 @@ require 'surrogate/rspec/invocation_matcher'
|
|
2
2
|
|
3
3
|
class Surrogate
|
4
4
|
module RSpec
|
5
|
-
class
|
5
|
+
class VerbMatcher < InvocationMatcher
|
6
6
|
class FailureMessageShouldDefault < AbstractFailureMessage
|
7
7
|
def get_message
|
8
8
|
"was never told to #{ method_name }"
|
@@ -70,6 +70,29 @@ class Surrogate
|
|
70
70
|
|
71
71
|
|
72
72
|
|
73
|
+
class RSpecMatchAsserter
|
74
|
+
attr_accessor :actual_invocation, :expected_invocation
|
75
|
+
|
76
|
+
def initialize(actual_invocation, expected_invocation)
|
77
|
+
self.actual_invocation, self.expected_invocation = actual_invocation, expected_invocation
|
78
|
+
end
|
79
|
+
|
80
|
+
def match?
|
81
|
+
rspec_arg_expectation = matcher_class.new *expected_invocation.args
|
82
|
+
rspec_arg_expectation.args_match? *actual_invocation.args
|
83
|
+
end
|
84
|
+
|
85
|
+
def matcher_class
|
86
|
+
return ::RSpec::Mocks::ArgumentListMatcher if approximate_2_11?
|
87
|
+
::RSpec::Mocks::ArgumentExpectation
|
88
|
+
end
|
89
|
+
|
90
|
+
def approximate_2_11?
|
91
|
+
Gem::Requirement.create('~> 2.11').satisfied_by? Gem::Version.new(::RSpec::Mocks::Version::STRING)
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
|
73
96
|
|
74
97
|
# rename args to invocation
|
75
98
|
attr_accessor :expected_invocation, :block, :pass, :filter_name
|
@@ -112,8 +135,7 @@ class Surrogate
|
|
112
135
|
|
113
136
|
def args_match?(actual_invocation)
|
114
137
|
if RSpec.rspec_mocks_loaded?
|
115
|
-
|
116
|
-
rspec_arg_expectation.args_match? *actual_invocation.args
|
138
|
+
RSpecMatchAsserter.new(actual_invocation, expected_invocation).match?
|
117
139
|
else
|
118
140
|
expected_arguments == actual_arguments
|
119
141
|
end
|
data/lib/surrogate/rspec.rb
CHANGED
@@ -23,35 +23,35 @@ class Surrogate
|
|
23
23
|
|
24
24
|
module Matchers
|
25
25
|
def have_been_told_to(method_name)
|
26
|
-
|
26
|
+
VerbMatcher.new method_name
|
27
27
|
end
|
28
28
|
|
29
29
|
def told_to(method_name)
|
30
|
-
|
30
|
+
VerbMatcher.new method_name
|
31
31
|
end
|
32
32
|
|
33
33
|
def have_been_asked_if(method_name)
|
34
|
-
|
34
|
+
PredicateMatcher.new method_name
|
35
35
|
end
|
36
36
|
|
37
37
|
def asked_if(method_name)
|
38
|
-
|
38
|
+
PredicateMatcher.new method_name
|
39
39
|
end
|
40
40
|
|
41
41
|
def have_been_asked_for_its(method_name)
|
42
|
-
|
42
|
+
NounMatcher.new method_name
|
43
43
|
end
|
44
44
|
|
45
45
|
def asked_for(method_name)
|
46
|
-
|
46
|
+
NounMatcher.new method_name
|
47
47
|
end
|
48
48
|
|
49
49
|
def have_been_initialized_with(*initialization_args, &block)
|
50
|
-
|
50
|
+
InitializationMatcher.new *initialization_args, &block
|
51
51
|
end
|
52
52
|
|
53
53
|
def initialized_with(*initialization_args, &block)
|
54
|
-
|
54
|
+
InitializationMatcher.new *initialization_args, &block
|
55
55
|
end
|
56
56
|
end
|
57
57
|
end
|
@@ -65,10 +65,10 @@ class Surrogate
|
|
65
65
|
end
|
66
66
|
|
67
67
|
require 'surrogate/rspec/substitute_for'
|
68
|
-
require 'surrogate/rspec/
|
69
|
-
require 'surrogate/rspec/
|
70
|
-
require 'surrogate/rspec/
|
71
|
-
require 'surrogate/rspec/
|
68
|
+
require 'surrogate/rspec/predicate_matcher'
|
69
|
+
require 'surrogate/rspec/noun_matcher'
|
70
|
+
require 'surrogate/rspec/initialization_matcher'
|
71
|
+
require 'surrogate/rspec/verb_matcher'
|
72
72
|
|
73
73
|
|
74
74
|
RSpec.configure do |config|
|
data/lib/surrogate/version.rb
CHANGED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
data/surrogate.gemspec
CHANGED
@@ -20,9 +20,9 @@ Gem::Specification.new do |s|
|
|
20
20
|
|
21
21
|
s.add_runtime_dependency 'bindable_block', '= 0.0.5.1'
|
22
22
|
|
23
|
-
s.add_development_dependency "rspec", '~> 2.2'
|
24
23
|
s.add_development_dependency "rake"
|
25
|
-
s.add_development_dependency "
|
24
|
+
s.add_development_dependency "rspec", "~> 2.2"
|
25
|
+
s.add_development_dependency "mountain_berry_fields", "~> 1.0.3"
|
26
26
|
s.add_development_dependency "mountain_berry_fields-rspec", "~> 1.0.2"
|
27
27
|
s.add_development_dependency "mountain_berry_fields-magic_comments", "~> 1.0.1"
|
28
28
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: surrogate
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-07-
|
12
|
+
date: 2012-07-10 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bindable_block
|
16
|
-
requirement: &
|
16
|
+
requirement: &70195439834980 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - =
|
@@ -21,43 +21,43 @@ dependencies:
|
|
21
21
|
version: 0.0.5.1
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70195439834980
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
|
-
name:
|
27
|
-
requirement: &
|
26
|
+
name: rake
|
27
|
+
requirement: &70195439834560 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
|
-
- -
|
30
|
+
- - ! '>='
|
31
31
|
- !ruby/object:Gem::Version
|
32
|
-
version: '
|
32
|
+
version: '0'
|
33
33
|
type: :development
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70195439834560
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
|
-
name:
|
38
|
-
requirement: &
|
37
|
+
name: rspec
|
38
|
+
requirement: &70195439834020 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
|
-
- -
|
41
|
+
- - ~>
|
42
42
|
- !ruby/object:Gem::Version
|
43
|
-
version: '
|
43
|
+
version: '2.2'
|
44
44
|
type: :development
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *70195439834020
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: mountain_berry_fields
|
49
|
-
requirement: &
|
49
|
+
requirement: &70195439833520 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ~>
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: 1.0.
|
54
|
+
version: 1.0.3
|
55
55
|
type: :development
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *70195439833520
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: mountain_berry_fields-rspec
|
60
|
-
requirement: &
|
60
|
+
requirement: &70195439833060 !ruby/object:Gem::Requirement
|
61
61
|
none: false
|
62
62
|
requirements:
|
63
63
|
- - ~>
|
@@ -65,10 +65,10 @@ dependencies:
|
|
65
65
|
version: 1.0.2
|
66
66
|
type: :development
|
67
67
|
prerelease: false
|
68
|
-
version_requirements: *
|
68
|
+
version_requirements: *70195439833060
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: mountain_berry_fields-magic_comments
|
71
|
-
requirement: &
|
71
|
+
requirement: &70195439832600 !ruby/object:Gem::Requirement
|
72
72
|
none: false
|
73
73
|
requirements:
|
74
74
|
- - ~>
|
@@ -76,7 +76,7 @@ dependencies:
|
|
76
76
|
version: 1.0.1
|
77
77
|
type: :development
|
78
78
|
prerelease: false
|
79
|
-
version_requirements: *
|
79
|
+
version_requirements: *70195439832600
|
80
80
|
description: Framework to aid in handrolling mock/spy objects.
|
81
81
|
email:
|
82
82
|
- josh.cheek@gmail.com
|
@@ -91,6 +91,8 @@ files:
|
|
91
91
|
- Rakefile
|
92
92
|
- Readme.md
|
93
93
|
- Readme.md.mountain_berry_fields
|
94
|
+
- gemfiles/rspec_mocks_2.10
|
95
|
+
- gemfiles/rspec_mocks_2.2
|
94
96
|
- lib/surrogate.rb
|
95
97
|
- lib/surrogate/api_comparer.rb
|
96
98
|
- lib/surrogate/endower.rb
|
@@ -100,26 +102,26 @@ files:
|
|
100
102
|
- lib/surrogate/options.rb
|
101
103
|
- lib/surrogate/rspec.rb
|
102
104
|
- lib/surrogate/rspec/abstract_failure_message.rb
|
103
|
-
- lib/surrogate/rspec/
|
104
|
-
- lib/surrogate/rspec/have_been_asked_if.rb
|
105
|
-
- lib/surrogate/rspec/have_been_initialized_with.rb
|
106
|
-
- lib/surrogate/rspec/have_been_told_to.rb
|
105
|
+
- lib/surrogate/rspec/initialization_matcher.rb
|
107
106
|
- lib/surrogate/rspec/invocation_matcher.rb
|
107
|
+
- lib/surrogate/rspec/noun_matcher.rb
|
108
|
+
- lib/surrogate/rspec/predicate_matcher.rb
|
108
109
|
- lib/surrogate/rspec/substitute_for.rb
|
109
110
|
- lib/surrogate/rspec/times_predicate.rb
|
111
|
+
- lib/surrogate/rspec/verb_matcher.rb
|
110
112
|
- lib/surrogate/rspec/with_filter.rb
|
111
113
|
- lib/surrogate/values.rb
|
112
114
|
- lib/surrogate/version.rb
|
113
115
|
- spec/acceptance_spec.rb
|
114
116
|
- spec/defining_api_methods_spec.rb
|
115
117
|
- spec/rspec/block_support_spec.rb
|
116
|
-
- spec/rspec/
|
117
|
-
- spec/rspec/matchers_for_nouns_spec.rb
|
118
|
-
- spec/rspec/matchers_for_predicates_spec.rb
|
119
|
-
- spec/rspec/matchers_for_verbs_spec.rb
|
118
|
+
- spec/rspec/initialization_matcher_spec.rb
|
120
119
|
- spec/rspec/messages_spec.rb
|
120
|
+
- spec/rspec/noun_matcher_spec.rb
|
121
|
+
- spec/rspec/predicate_matcher_spec.rb
|
121
122
|
- spec/rspec/rspec_mocks_integration_spec.rb
|
122
123
|
- spec/rspec/substitute_for_spec.rb
|
124
|
+
- spec/rspec/verb_matcher_spec.rb
|
123
125
|
- spec/spec_helper.rb
|
124
126
|
- spec/unit/api_comparer_spec.rb
|
125
127
|
- surrogate.gemspec
|
@@ -151,13 +153,13 @@ test_files:
|
|
151
153
|
- spec/acceptance_spec.rb
|
152
154
|
- spec/defining_api_methods_spec.rb
|
153
155
|
- spec/rspec/block_support_spec.rb
|
154
|
-
- spec/rspec/
|
155
|
-
- spec/rspec/matchers_for_nouns_spec.rb
|
156
|
-
- spec/rspec/matchers_for_predicates_spec.rb
|
157
|
-
- spec/rspec/matchers_for_verbs_spec.rb
|
156
|
+
- spec/rspec/initialization_matcher_spec.rb
|
158
157
|
- spec/rspec/messages_spec.rb
|
158
|
+
- spec/rspec/noun_matcher_spec.rb
|
159
|
+
- spec/rspec/predicate_matcher_spec.rb
|
159
160
|
- spec/rspec/rspec_mocks_integration_spec.rb
|
160
161
|
- spec/rspec/substitute_for_spec.rb
|
162
|
+
- spec/rspec/verb_matcher_spec.rb
|
161
163
|
- spec/spec_helper.rb
|
162
164
|
- spec/unit/api_comparer_spec.rb
|
163
165
|
has_rdoc:
|