bogus 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +7 -0
- data/.pelusa.yml +1 -0
- data/.travis.yml +6 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +75 -0
- data/Guardfile +15 -0
- data/README.md +272 -0
- data/Rakefile +1 -0
- data/bogus.gemspec +34 -0
- data/features/configuration_options.feature +43 -0
- data/features/contract_tests_mocks.feature +100 -0
- data/features/contract_tests_spies.feature +72 -0
- data/features/contract_tests_stubs.feature +101 -0
- data/features/fake_objects.feature +94 -0
- data/features/return_value_contracts.feature +90 -0
- data/features/safe_mocking.feature +59 -0
- data/features/safe_stubbing.feature +62 -0
- data/features/spies.feature +78 -0
- data/features/step_definitions/rspec_steps.rb +68 -0
- data/features/support/env.rb +1 -0
- data/lib/bogus.rb +35 -0
- data/lib/bogus/adds_recording.rb +11 -0
- data/lib/bogus/configuration.rb +9 -0
- data/lib/bogus/contract_not_fulfilled.rb +24 -0
- data/lib/bogus/converts_name_to_class.rb +31 -0
- data/lib/bogus/copies_classes.rb +44 -0
- data/lib/bogus/creates_fakes.rb +32 -0
- data/lib/bogus/double.rb +10 -0
- data/lib/bogus/fake.rb +33 -0
- data/lib/bogus/fake_registry.rb +13 -0
- data/lib/bogus/injector.rb +64 -0
- data/lib/bogus/interaction.rb +24 -0
- data/lib/bogus/interaction_presenter.rb +29 -0
- data/lib/bogus/interactions_repository.rb +19 -0
- data/lib/bogus/invocation_matcher.rb +27 -0
- data/lib/bogus/method_stringifier.rb +31 -0
- data/lib/bogus/overwrites_classes.rb +9 -0
- data/lib/bogus/proxy_class.rb +22 -0
- data/lib/bogus/public_methods.rb +46 -0
- data/lib/bogus/record_interactions.rb +17 -0
- data/lib/bogus/recording_proxy.rb +18 -0
- data/lib/bogus/records_double_interactions.rb +11 -0
- data/lib/bogus/registers_created_fakes.rb +11 -0
- data/lib/bogus/rr_proxy.rb +5 -0
- data/lib/bogus/rspec.rb +4 -0
- data/lib/bogus/rspec_extensions.rb +32 -0
- data/lib/bogus/takes.rb +8 -0
- data/lib/bogus/verifies_contracts.rb +12 -0
- data/lib/bogus/verifies_stub_definition.rb +37 -0
- data/lib/bogus/version.rb +3 -0
- data/pelusa.sh +3 -0
- data/rbs.sh +3 -0
- data/spec/bogus/adds_recording_spec.rb +33 -0
- data/spec/bogus/configuration_spec.rb +17 -0
- data/spec/bogus/converts_name_to_class_spec.rb +40 -0
- data/spec/bogus/copies_classes_spec.rb +175 -0
- data/spec/bogus/creates_fakes_spec.rb +59 -0
- data/spec/bogus/double_spec.rb +31 -0
- data/spec/bogus/fake_registry_spec.rb +24 -0
- data/spec/bogus/interaction_spec.rb +68 -0
- data/spec/bogus/interactions_repository_spec.rb +50 -0
- data/spec/bogus/invocation_matcher_spec.rb +26 -0
- data/spec/bogus/mocking_dsl_spec.rb +76 -0
- data/spec/bogus/overwrites_classes_spec.rb +26 -0
- data/spec/bogus/proxy_class_spec.rb +95 -0
- data/spec/bogus/record_interactions_spec.rb +27 -0
- data/spec/bogus/records_double_interactions_spec.rb +25 -0
- data/spec/bogus/registers_created_fakes_spec.rb +25 -0
- data/spec/bogus/verifies_contracts_spec.rb +42 -0
- data/spec/bogus/verifies_stub_definition_spec.rb +71 -0
- data/spec/spec_helper.rb +14 -0
- metadata +299 -0
@@ -0,0 +1,71 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Bogus::VerifiesStubDefinition do
|
4
|
+
class ExampleForVerify
|
5
|
+
def foo(bar)
|
6
|
+
end
|
7
|
+
|
8
|
+
def three_args(x, y, z)
|
9
|
+
end
|
10
|
+
|
11
|
+
def optional_args(x, y = 1, z = 2)
|
12
|
+
end
|
13
|
+
|
14
|
+
def var_args(x, *y)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
let(:object) { ExampleForVerify.new }
|
19
|
+
let(:verifies_stub_definition) { Bogus::VerifiesStubDefinition.new(method_stringifier) }
|
20
|
+
let(:method_stringifier) { stub(arguments_as_string: 'foo, bar') }
|
21
|
+
|
22
|
+
def verify(method_name, args)
|
23
|
+
verifies_stub_definition.verify!(object, method_name, args)
|
24
|
+
end
|
25
|
+
|
26
|
+
def it_allows(method_name, args)
|
27
|
+
expect{ verify(method_name, args) }.not_to raise_error
|
28
|
+
end
|
29
|
+
|
30
|
+
def it_disallows(method_name, args, error = ArgumentError)
|
31
|
+
expect{ verify(method_name, args) }.to raise_error(error)
|
32
|
+
end
|
33
|
+
|
34
|
+
def self.it_allows_argument_numbers(method_name, *arg_counts)
|
35
|
+
arg_counts.each do |arg_count|
|
36
|
+
it "allows #{arg_count} arguments" do
|
37
|
+
it_allows(method_name, [1] * arg_count)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
def self.it_disallows_argument_numbers(method_name, *arg_counts)
|
43
|
+
arg_counts.each do |arg_count|
|
44
|
+
it "disallows #{arg_count} arguments" do
|
45
|
+
it_disallows(method_name, [1] * arg_count)
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
it "checks for method presence" do
|
51
|
+
it_disallows(:bar, [1], NameError)
|
52
|
+
end
|
53
|
+
|
54
|
+
describe "method arity checks" do
|
55
|
+
context "method with positive arity" do
|
56
|
+
it_allows_argument_numbers :three_args, 3
|
57
|
+
it_disallows_argument_numbers :three_args, 2, 4
|
58
|
+
end
|
59
|
+
|
60
|
+
context "method with optional arguments" do
|
61
|
+
it_allows_argument_numbers :optional_args, 1, 2, 3
|
62
|
+
it_disallows_argument_numbers :optional_args, 0, 4
|
63
|
+
end
|
64
|
+
|
65
|
+
context "method with infinite number of arguments" do
|
66
|
+
it_allows_argument_numbers :var_args, 1000
|
67
|
+
it_disallows_argument_numbers :var_args, 0
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
require 'bogus'
|
2
|
+
require 'dependor/rspec'
|
3
|
+
|
4
|
+
require 'rr'
|
5
|
+
|
6
|
+
RSpec.configure do |config|
|
7
|
+
config.color_enabled = true
|
8
|
+
config.mock_framework = :rr
|
9
|
+
end
|
10
|
+
|
11
|
+
# this should not be necessary...
|
12
|
+
def have_received(method = nil)
|
13
|
+
RR::Adapters::Rspec::InvocationMatcher.new(method)
|
14
|
+
end
|
metadata
ADDED
@@ -0,0 +1,299 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: bogus
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Adam Pohorecki
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-07-30 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: dependor
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: 0.0.4
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: 0.0.4
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: rr
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
type: :runtime
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: rake
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ! '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
54
|
+
type: :development
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: rspec
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - ! '>='
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
70
|
+
type: :development
|
71
|
+
prerelease: false
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ! '>='
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
78
|
+
- !ruby/object:Gem::Dependency
|
79
|
+
name: cucumber
|
80
|
+
requirement: !ruby/object:Gem::Requirement
|
81
|
+
none: false
|
82
|
+
requirements:
|
83
|
+
- - ! '>='
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: '0'
|
86
|
+
type: :development
|
87
|
+
prerelease: false
|
88
|
+
version_requirements: !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
90
|
+
requirements:
|
91
|
+
- - ! '>='
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: '0'
|
94
|
+
- !ruby/object:Gem::Dependency
|
95
|
+
name: aruba
|
96
|
+
requirement: !ruby/object:Gem::Requirement
|
97
|
+
none: false
|
98
|
+
requirements:
|
99
|
+
- - ! '>='
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: '0'
|
102
|
+
type: :development
|
103
|
+
prerelease: false
|
104
|
+
version_requirements: !ruby/object:Gem::Requirement
|
105
|
+
none: false
|
106
|
+
requirements:
|
107
|
+
- - ! '>='
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '0'
|
110
|
+
- !ruby/object:Gem::Dependency
|
111
|
+
name: guard
|
112
|
+
requirement: !ruby/object:Gem::Requirement
|
113
|
+
none: false
|
114
|
+
requirements:
|
115
|
+
- - ! '>='
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
none: false
|
122
|
+
requirements:
|
123
|
+
- - ! '>='
|
124
|
+
- !ruby/object:Gem::Version
|
125
|
+
version: '0'
|
126
|
+
- !ruby/object:Gem::Dependency
|
127
|
+
name: guard-rspec
|
128
|
+
requirement: !ruby/object:Gem::Requirement
|
129
|
+
none: false
|
130
|
+
requirements:
|
131
|
+
- - ! '>='
|
132
|
+
- !ruby/object:Gem::Version
|
133
|
+
version: '0'
|
134
|
+
type: :development
|
135
|
+
prerelease: false
|
136
|
+
version_requirements: !ruby/object:Gem::Requirement
|
137
|
+
none: false
|
138
|
+
requirements:
|
139
|
+
- - ! '>='
|
140
|
+
- !ruby/object:Gem::Version
|
141
|
+
version: '0'
|
142
|
+
- !ruby/object:Gem::Dependency
|
143
|
+
name: guard-cucumber
|
144
|
+
requirement: !ruby/object:Gem::Requirement
|
145
|
+
none: false
|
146
|
+
requirements:
|
147
|
+
- - ! '>='
|
148
|
+
- !ruby/object:Gem::Version
|
149
|
+
version: '0'
|
150
|
+
type: :development
|
151
|
+
prerelease: false
|
152
|
+
version_requirements: !ruby/object:Gem::Requirement
|
153
|
+
none: false
|
154
|
+
requirements:
|
155
|
+
- - ! '>='
|
156
|
+
- !ruby/object:Gem::Version
|
157
|
+
version: '0'
|
158
|
+
- !ruby/object:Gem::Dependency
|
159
|
+
name: growl
|
160
|
+
requirement: !ruby/object:Gem::Requirement
|
161
|
+
none: false
|
162
|
+
requirements:
|
163
|
+
- - ! '>='
|
164
|
+
- !ruby/object:Gem::Version
|
165
|
+
version: '0'
|
166
|
+
type: :development
|
167
|
+
prerelease: false
|
168
|
+
version_requirements: !ruby/object:Gem::Requirement
|
169
|
+
none: false
|
170
|
+
requirements:
|
171
|
+
- - ! '>='
|
172
|
+
- !ruby/object:Gem::Version
|
173
|
+
version: '0'
|
174
|
+
- !ruby/object:Gem::Dependency
|
175
|
+
name: libnotify
|
176
|
+
requirement: !ruby/object:Gem::Requirement
|
177
|
+
none: false
|
178
|
+
requirements:
|
179
|
+
- - ! '>='
|
180
|
+
- !ruby/object:Gem::Version
|
181
|
+
version: '0'
|
182
|
+
type: :development
|
183
|
+
prerelease: false
|
184
|
+
version_requirements: !ruby/object:Gem::Requirement
|
185
|
+
none: false
|
186
|
+
requirements:
|
187
|
+
- - ! '>='
|
188
|
+
- !ruby/object:Gem::Version
|
189
|
+
version: '0'
|
190
|
+
description: Decreases the need to write integration tests by ensuring that the things
|
191
|
+
you stub or mock actually exist.
|
192
|
+
email:
|
193
|
+
- adam@pohorecki.pl
|
194
|
+
executables: []
|
195
|
+
extensions: []
|
196
|
+
extra_rdoc_files: []
|
197
|
+
files:
|
198
|
+
- .gitignore
|
199
|
+
- .pelusa.yml
|
200
|
+
- .travis.yml
|
201
|
+
- Gemfile
|
202
|
+
- Gemfile.lock
|
203
|
+
- Guardfile
|
204
|
+
- README.md
|
205
|
+
- Rakefile
|
206
|
+
- bogus.gemspec
|
207
|
+
- features/configuration_options.feature
|
208
|
+
- features/contract_tests_mocks.feature
|
209
|
+
- features/contract_tests_spies.feature
|
210
|
+
- features/contract_tests_stubs.feature
|
211
|
+
- features/fake_objects.feature
|
212
|
+
- features/return_value_contracts.feature
|
213
|
+
- features/safe_mocking.feature
|
214
|
+
- features/safe_stubbing.feature
|
215
|
+
- features/spies.feature
|
216
|
+
- features/step_definitions/rspec_steps.rb
|
217
|
+
- features/support/env.rb
|
218
|
+
- lib/bogus.rb
|
219
|
+
- lib/bogus/adds_recording.rb
|
220
|
+
- lib/bogus/configuration.rb
|
221
|
+
- lib/bogus/contract_not_fulfilled.rb
|
222
|
+
- lib/bogus/converts_name_to_class.rb
|
223
|
+
- lib/bogus/copies_classes.rb
|
224
|
+
- lib/bogus/creates_fakes.rb
|
225
|
+
- lib/bogus/double.rb
|
226
|
+
- lib/bogus/fake.rb
|
227
|
+
- lib/bogus/fake_registry.rb
|
228
|
+
- lib/bogus/injector.rb
|
229
|
+
- lib/bogus/interaction.rb
|
230
|
+
- lib/bogus/interaction_presenter.rb
|
231
|
+
- lib/bogus/interactions_repository.rb
|
232
|
+
- lib/bogus/invocation_matcher.rb
|
233
|
+
- lib/bogus/method_stringifier.rb
|
234
|
+
- lib/bogus/overwrites_classes.rb
|
235
|
+
- lib/bogus/proxy_class.rb
|
236
|
+
- lib/bogus/public_methods.rb
|
237
|
+
- lib/bogus/record_interactions.rb
|
238
|
+
- lib/bogus/recording_proxy.rb
|
239
|
+
- lib/bogus/records_double_interactions.rb
|
240
|
+
- lib/bogus/registers_created_fakes.rb
|
241
|
+
- lib/bogus/rr_proxy.rb
|
242
|
+
- lib/bogus/rspec.rb
|
243
|
+
- lib/bogus/rspec_extensions.rb
|
244
|
+
- lib/bogus/takes.rb
|
245
|
+
- lib/bogus/verifies_contracts.rb
|
246
|
+
- lib/bogus/verifies_stub_definition.rb
|
247
|
+
- lib/bogus/version.rb
|
248
|
+
- pelusa.sh
|
249
|
+
- rbs.sh
|
250
|
+
- spec/bogus/adds_recording_spec.rb
|
251
|
+
- spec/bogus/configuration_spec.rb
|
252
|
+
- spec/bogus/converts_name_to_class_spec.rb
|
253
|
+
- spec/bogus/copies_classes_spec.rb
|
254
|
+
- spec/bogus/creates_fakes_spec.rb
|
255
|
+
- spec/bogus/double_spec.rb
|
256
|
+
- spec/bogus/fake_registry_spec.rb
|
257
|
+
- spec/bogus/interaction_spec.rb
|
258
|
+
- spec/bogus/interactions_repository_spec.rb
|
259
|
+
- spec/bogus/invocation_matcher_spec.rb
|
260
|
+
- spec/bogus/mocking_dsl_spec.rb
|
261
|
+
- spec/bogus/overwrites_classes_spec.rb
|
262
|
+
- spec/bogus/proxy_class_spec.rb
|
263
|
+
- spec/bogus/record_interactions_spec.rb
|
264
|
+
- spec/bogus/records_double_interactions_spec.rb
|
265
|
+
- spec/bogus/registers_created_fakes_spec.rb
|
266
|
+
- spec/bogus/verifies_contracts_spec.rb
|
267
|
+
- spec/bogus/verifies_stub_definition_spec.rb
|
268
|
+
- spec/spec_helper.rb
|
269
|
+
homepage: https://github.com/psyho/bogus
|
270
|
+
licenses: []
|
271
|
+
post_install_message:
|
272
|
+
rdoc_options: []
|
273
|
+
require_paths:
|
274
|
+
- lib
|
275
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
276
|
+
none: false
|
277
|
+
requirements:
|
278
|
+
- - ! '>='
|
279
|
+
- !ruby/object:Gem::Version
|
280
|
+
version: '0'
|
281
|
+
segments:
|
282
|
+
- 0
|
283
|
+
hash: -1064750600305128815
|
284
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
285
|
+
none: false
|
286
|
+
requirements:
|
287
|
+
- - ! '>='
|
288
|
+
- !ruby/object:Gem::Version
|
289
|
+
version: '0'
|
290
|
+
segments:
|
291
|
+
- 0
|
292
|
+
hash: -1064750600305128815
|
293
|
+
requirements: []
|
294
|
+
rubyforge_project: bogus
|
295
|
+
rubygems_version: 1.8.24
|
296
|
+
signing_key:
|
297
|
+
specification_version: 3
|
298
|
+
summary: Create fakes to make your isolated unit tests reliable.
|
299
|
+
test_files: []
|