bogus 0.1.5 → 0.1.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.rspec +1 -0
- data/.travis.yml +6 -3
- data/Gemfile +0 -2
- data/Guardfile +1 -1
- data/bogus.gemspec +2 -4
- data/features/authors.md +2 -1
- data/features/changelog.md +8 -0
- data/features/contract_tests/contract_tests_mocks.feature +4 -4
- data/features/contract_tests/contract_tests_stubs.feature +4 -4
- data/features/contract_tests/custom_overwritten_class.feature +3 -3
- data/features/fakes/fake_objects.feature +2 -2
- data/lib/bogus/core_ext.rb +5 -1
- data/lib/bogus/fakes/method_stringifier.rb +2 -2
- data/lib/bogus/minitest/syntax.rb +2 -2
- data/lib/bogus/minitest.rb +2 -2
- data/lib/bogus/rspec/syntax.rb +3 -0
- data/lib/bogus/stubbing/verifies_stub_definition.rb +10 -1
- data/lib/bogus/version.rb +1 -1
- data/license.md +1 -0
- data/spec/bogus/bugs/rbx_instance_eval_bug_spec.rb +20 -0
- data/spec/bogus/bugs/rbx_jruby_stub_on_class_spec.rb +45 -0
- data/spec/bogus/contracts/adds_contract_verification_spec.rb +10 -10
- data/spec/bogus/contracts/adds_recording_spec.rb +9 -9
- data/spec/bogus/contracts/interactions_repository_spec.rb +13 -13
- data/spec/bogus/contracts/records_double_interactions_spec.rb +9 -7
- data/spec/bogus/contracts/verifies_contracts_spec.rb +9 -9
- data/spec/bogus/fakes/copies_classes_spec.rb +5 -5
- data/spec/bogus/fakes/creates_fakes_spec.rb +13 -13
- data/spec/bogus/fakes/creates_fakes_with_stubbed_methods_spec.rb +21 -19
- data/spec/bogus/fakes/fake_ar_attributes_spec.rb +3 -1
- data/spec/bogus/fakes/fake_configuration_spec.rb +4 -4
- data/spec/bogus/fakes/fakes_classes_spec.rb +6 -6
- data/spec/bogus/fakes/faking_factories_spec.rb +3 -1
- data/spec/bogus/fakes/frozen_fakes_spec.rb +3 -1
- data/spec/bogus/fakes/registers_created_fakes_spec.rb +8 -8
- data/spec/bogus/fakes/resets_overwritten_classes_spec.rb +8 -8
- data/spec/bogus/fakes/stubbing_new_method_on_fake_class_spec.rb +3 -1
- data/spec/bogus/mocking_dsl_spec.rb +3 -1
- data/spec/bogus/rspec/syntax_spec.rb +16 -0
- data/spec/bogus/ruby_2_1_support_spec.rb +4 -2
- data/spec/bogus/ruby_2_support_spec.rb +4 -2
- data/spec/bogus/stubbing/double_spec.rb +19 -19
- data/spec/bogus/stubbing/have_received_matcher_spec.rb +13 -14
- data/spec/bogus/stubbing/interaction_spec.rb +7 -7
- data/spec/bogus/stubbing/multi_stubber_spec.rb +5 -5
- data/spec/bogus/stubbing/record_interactions_spec.rb +2 -2
- data/spec/bogus/stubbing/resets_stubbed_methods_spec.rb +5 -5
- data/spec/bogus/stubbing/shadow_spec.rb +6 -6
- data/spec/bogus/stubbing/stubbing_existing_methods_on_fakes_spec.rb +1 -1
- data/spec/bogus/stubbing/verifies_stub_definition_spec.rb +14 -1
- data/spec/spec_helper.rb +6 -13
- data/spec/support/ruby_features.rb +19 -0
- metadata +13 -9
- data/license.md +0 -9
@@ -52,7 +52,7 @@ module Bogus
|
|
52
52
|
first = create_interaction(first_interaction)
|
53
53
|
second = create_interaction(second_interaction)
|
54
54
|
|
55
|
-
expect(Interaction.same?(recorded: first, stubbed: second)).to
|
55
|
+
expect(Interaction.same?(recorded: first, stubbed: second)).to be(true)
|
56
56
|
end
|
57
57
|
end
|
58
58
|
|
@@ -61,7 +61,7 @@ module Bogus
|
|
61
61
|
first = create_interaction(first_interaction)
|
62
62
|
second = create_interaction(second_interaction)
|
63
63
|
|
64
|
-
expect(Interaction.same?(recorded: first, stubbed: second)).to
|
64
|
+
expect(Interaction.same?(recorded: first, stubbed: second)).to be(false)
|
65
65
|
end
|
66
66
|
end
|
67
67
|
|
@@ -69,21 +69,21 @@ module Bogus
|
|
69
69
|
first = Interaction.new(:foo, [:bar]) { raise SomeError }
|
70
70
|
second = Interaction.new(:foo, [:bar]) { nil }
|
71
71
|
|
72
|
-
expect(Interaction.same?(recorded: first, stubbed: second)).to
|
72
|
+
expect(Interaction.same?(recorded: first, stubbed: second)).to be(false)
|
73
73
|
end
|
74
74
|
|
75
75
|
it "differs raised exceptions from ones just returned from the block" do
|
76
76
|
first = Interaction.new(:foo, [:bar]) { raise SomeError }
|
77
77
|
second = Interaction.new(:foo, [:bar]) { SomeError }
|
78
78
|
|
79
|
-
expect(Interaction.same?(recorded: first, stubbed: second)).to
|
79
|
+
expect(Interaction.same?(recorded: first, stubbed: second)).to be(false)
|
80
80
|
end
|
81
81
|
|
82
82
|
it "considers exceptions of the same type as equal" do
|
83
83
|
first = Interaction.new(:foo, [:bar]) { raise SomeError }
|
84
84
|
second = Interaction.new(:foo, [:bar]) { raise SomeError }
|
85
85
|
|
86
|
-
expect(Interaction.same?(recorded: first, stubbed: second)).to
|
86
|
+
expect(Interaction.same?(recorded: first, stubbed: second)).to be(true)
|
87
87
|
end
|
88
88
|
|
89
89
|
context 'when comparing arguments with custom #== implementations' do
|
@@ -97,14 +97,14 @@ module Bogus
|
|
97
97
|
first = Interaction.new(:with, [Dev.new(:psyho)])
|
98
98
|
second = Interaction.new(:with, [Dev.new(:psyho)])
|
99
99
|
|
100
|
-
expect(Interaction.same?(recorded: first, stubbed: second)).to
|
100
|
+
expect(Interaction.same?(recorded: first, stubbed: second)).to be(true)
|
101
101
|
end
|
102
102
|
|
103
103
|
it "considers two interactions != when the arguments are !=" do
|
104
104
|
first = Interaction.new(:with, [Dev.new(:wrozka)])
|
105
105
|
second = Interaction.new(:with, [Dev.new(:yundt)])
|
106
106
|
|
107
|
-
expect(Interaction.same?(recorded: first, stubbed: second)).to
|
107
|
+
expect(Interaction.same?(recorded: first, stubbed: second)).to be(false)
|
108
108
|
end
|
109
109
|
end
|
110
110
|
end
|
@@ -1,22 +1,22 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Bogus::MultiStubber do
|
4
|
-
let(:
|
5
|
-
let(:
|
6
|
-
let(:
|
4
|
+
let(:fake_double) { FakeDouble.new }
|
5
|
+
let(:bogus_any_args) { Bogus::AnyArgs }
|
6
|
+
let(:create_double) { proc{ fake_double } }
|
7
7
|
|
8
8
|
let(:multi_stubber) { isolate(Bogus::MultiStubber) }
|
9
9
|
|
10
10
|
it "stubs all the given methods with any args returning the given value" do
|
11
11
|
multi_stubber.stub_all(Object.new, foo: 1, bar: 2)
|
12
12
|
|
13
|
-
expect(
|
13
|
+
expect(fake_double.stubbed).to eq([[:foo, [bogus_any_args], 1], [:bar, [bogus_any_args], 2]])
|
14
14
|
end
|
15
15
|
|
16
16
|
it "uses passed procs as the return value block" do
|
17
17
|
multi_stubber.stub_all(Object.new, foo: proc{ 1 })
|
18
18
|
|
19
|
-
expect(
|
19
|
+
expect(fake_double.stubbed).to eq([[:foo, [bogus_any_args], 1]])
|
20
20
|
end
|
21
21
|
|
22
22
|
class FakeDouble
|
@@ -11,13 +11,13 @@ describe Bogus::RecordInteractions do
|
|
11
11
|
it "allows verifying that interactions happened" do
|
12
12
|
sample.__record__(:foo, 1, 2, 3)
|
13
13
|
|
14
|
-
expect(sample.__shadow__.has_received(:foo, [1,2,3])).to
|
14
|
+
expect(sample.__shadow__.has_received(:foo, [1,2,3])).to be(true)
|
15
15
|
end
|
16
16
|
|
17
17
|
it "allows verifying that interactions didn't happen" do
|
18
18
|
sample.__record__(:bar)
|
19
19
|
|
20
|
-
expect(sample.__shadow__.has_received(:foo, [1,2,3])).to
|
20
|
+
expect(sample.__shadow__.has_received(:foo, [1,2,3])).to be(false)
|
21
21
|
end
|
22
22
|
|
23
23
|
it "returns self from record by default" do
|
@@ -1,15 +1,15 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Bogus::ResetsStubbedMethods do
|
4
|
-
let(:double_tracker) {
|
5
|
-
let(:overwrites_methods) {
|
4
|
+
let(:double_tracker) { double }
|
5
|
+
let(:overwrites_methods) { double }
|
6
6
|
|
7
7
|
let(:resets_stubbed_methods) { isolate(Bogus::ResetsStubbedMethods) }
|
8
8
|
|
9
9
|
it "resets all stubbed objects back to previous implementation" do
|
10
|
-
foo =
|
11
|
-
|
12
|
-
|
10
|
+
foo = double
|
11
|
+
allow(double_tracker).to receive(:doubles) { [foo] }
|
12
|
+
expect(overwrites_methods).to receive(:reset).with(foo)
|
13
13
|
|
14
14
|
resets_stubbed_methods.reset_all_doubles
|
15
15
|
end
|
@@ -11,12 +11,12 @@ describe Bogus::Shadow do
|
|
11
11
|
end
|
12
12
|
|
13
13
|
it "returns the called methods" do
|
14
|
-
expect(shadow.has_received(:foo, ["a", "b"])).to
|
14
|
+
expect(shadow.has_received(:foo, ["a", "b"])).to be(true)
|
15
15
|
end
|
16
16
|
|
17
17
|
it "does not return true for interactions that did not happen" do
|
18
|
-
expect(shadow.has_received(:foo, ["a", "c"])).to
|
19
|
-
expect(shadow.has_received(:bar, ["a", "c"])).to
|
18
|
+
expect(shadow.has_received(:foo, ["a", "c"])).to be(false)
|
19
|
+
expect(shadow.has_received(:bar, ["a", "c"])).to be(false)
|
20
20
|
end
|
21
21
|
end
|
22
22
|
end
|
@@ -81,7 +81,7 @@ describe Bogus::Shadow do
|
|
81
81
|
it "allows spying on calls using any args" do
|
82
82
|
shadow.run(:foo, "a", "c")
|
83
83
|
|
84
|
-
expect(shadow.has_received(:foo, [Bogus::AnyArgs])).to
|
84
|
+
expect(shadow.has_received(:foo, [Bogus::AnyArgs])).to be(true)
|
85
85
|
end
|
86
86
|
end
|
87
87
|
|
@@ -103,7 +103,7 @@ describe Bogus::Shadow do
|
|
103
103
|
it "allows spying on calls using anything in args" do
|
104
104
|
shadow.run(:foo, "a", "b")
|
105
105
|
|
106
|
-
expect(shadow.has_received(:foo, [Bogus::Anything, "b"])).to
|
106
|
+
expect(shadow.has_received(:foo, [Bogus::Anything, "b"])).to be(true)
|
107
107
|
end
|
108
108
|
end
|
109
109
|
|
@@ -177,7 +177,7 @@ describe Bogus::Shadow do
|
|
177
177
|
|
178
178
|
it "contributes towards unsatisfied interactions" do
|
179
179
|
interactions = shadow.unsatisfied_interactions
|
180
|
-
expect(interactions).to
|
180
|
+
expect(interactions.size).to eq(1)
|
181
181
|
expect(interactions.first.method).to eq(:foo)
|
182
182
|
expect(interactions.first.args).to eq(["a", "b"])
|
183
183
|
end
|
@@ -2,6 +2,9 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe Bogus::VerifiesStubDefinition do
|
4
4
|
class ExampleForVerify
|
5
|
+
def initialize(test)
|
6
|
+
end
|
7
|
+
|
5
8
|
def foo(bar)
|
6
9
|
end
|
7
10
|
|
@@ -15,7 +18,7 @@ describe Bogus::VerifiesStubDefinition do
|
|
15
18
|
end
|
16
19
|
end
|
17
20
|
|
18
|
-
let(:object) { ExampleForVerify.new }
|
21
|
+
let(:object) { ExampleForVerify.new(1) }
|
19
22
|
let(:verifies_stub_definition) { Bogus::VerifiesStubDefinition.new(method_stringifier) }
|
20
23
|
let(:method_stringifier) { isolate(Bogus::MethodStringifier) }
|
21
24
|
|
@@ -47,6 +50,16 @@ describe Bogus::VerifiesStubDefinition do
|
|
47
50
|
end
|
48
51
|
end
|
49
52
|
|
53
|
+
context "when checking #new" do
|
54
|
+
let(:object) { ExampleForVerify }
|
55
|
+
it "checks arity" do
|
56
|
+
it_allows(:new, [1])
|
57
|
+
end
|
58
|
+
it "errors with the wrong number of arguments" do
|
59
|
+
it_disallows(:new, [])
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
50
63
|
it "checks for method presence" do
|
51
64
|
it_disallows(:bar, [1], NameError)
|
52
65
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
require 'simplecov'
|
2
2
|
begin
|
3
3
|
require "coveralls"
|
4
|
+
SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter.new([
|
5
|
+
SimpleCov::Formatter::HTMLFormatter,
|
6
|
+
Coveralls::SimpleCov::Formatter])
|
4
7
|
rescue LoadError
|
5
8
|
warn "warning: coveralls gem not found; skipping Coveralls"
|
9
|
+
SimpleCov.formatter = SimpleCov::Formatter::HTMLFormatter
|
6
10
|
end
|
7
11
|
|
8
|
-
SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[
|
9
|
-
SimpleCov::Formatter::HTMLFormatter,
|
10
|
-
Coveralls::SimpleCov::Formatter]
|
11
|
-
|
12
12
|
SimpleCov.start do
|
13
13
|
add_filter "/spec/"
|
14
14
|
end
|
@@ -16,19 +16,12 @@ end
|
|
16
16
|
require 'bogus'
|
17
17
|
require 'dependor/rspec'
|
18
18
|
|
19
|
-
require 'rr'
|
20
|
-
|
21
19
|
require_relative 'support/sample_fake'
|
22
20
|
require_relative 'support/fake_creator_of_fakes'
|
23
21
|
require_relative 'support/matchers'
|
24
22
|
require_relative 'support/shared_examples_for_keyword_arguments'
|
23
|
+
require_relative 'support/ruby_features'
|
25
24
|
|
26
25
|
RSpec.configure do |config|
|
27
|
-
config.
|
28
|
-
config.mock_framework = :rr
|
29
|
-
end
|
30
|
-
|
31
|
-
# this should not be necessary...
|
32
|
-
def have_received(method = nil)
|
33
|
-
RR::Adapters::Rspec::InvocationMatcher.new(method)
|
26
|
+
config.mock_with :rspec
|
34
27
|
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module RubyFeatures
|
2
|
+
module_function
|
3
|
+
|
4
|
+
def keyword_arguments?
|
5
|
+
ruby?('2.0') && !rbx?
|
6
|
+
end
|
7
|
+
|
8
|
+
def required_keyword_arguments?
|
9
|
+
ruby?('2.1') && keyword_arguments?
|
10
|
+
end
|
11
|
+
|
12
|
+
def ruby?(version)
|
13
|
+
RUBY_VERSION >= version
|
14
|
+
end
|
15
|
+
|
16
|
+
def rbx?
|
17
|
+
RUBY_ENGINE == 'rbx'
|
18
|
+
end
|
19
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bogus
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Adam Pohorecki
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-07-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: dependor
|
@@ -165,7 +165,7 @@ dependencies:
|
|
165
165
|
- !ruby/object:Gem::Version
|
166
166
|
version: '0'
|
167
167
|
- !ruby/object:Gem::Dependency
|
168
|
-
name:
|
168
|
+
name: relish
|
169
169
|
requirement: !ruby/object:Gem::Requirement
|
170
170
|
requirements:
|
171
171
|
- - ">="
|
@@ -179,7 +179,7 @@ dependencies:
|
|
179
179
|
- !ruby/object:Gem::Version
|
180
180
|
version: '0'
|
181
181
|
- !ruby/object:Gem::Dependency
|
182
|
-
name:
|
182
|
+
name: coveralls
|
183
183
|
requirement: !ruby/object:Gem::Requirement
|
184
184
|
requirements:
|
185
185
|
- - ">="
|
@@ -193,7 +193,7 @@ dependencies:
|
|
193
193
|
- !ruby/object:Gem::Version
|
194
194
|
version: '0'
|
195
195
|
- !ruby/object:Gem::Dependency
|
196
|
-
name:
|
196
|
+
name: wwtd
|
197
197
|
requirement: !ruby/object:Gem::Requirement
|
198
198
|
requirements:
|
199
199
|
- - ">="
|
@@ -215,7 +215,7 @@ dependencies:
|
|
215
215
|
version: '3'
|
216
216
|
- - "<"
|
217
217
|
- !ruby/object:Gem::Version
|
218
|
-
version: '
|
218
|
+
version: '7'
|
219
219
|
type: :development
|
220
220
|
prerelease: false
|
221
221
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -225,7 +225,7 @@ dependencies:
|
|
225
225
|
version: '3'
|
226
226
|
- - "<"
|
227
227
|
- !ruby/object:Gem::Version
|
228
|
-
version: '
|
228
|
+
version: '7'
|
229
229
|
- !ruby/object:Gem::Dependency
|
230
230
|
name: activerecord-nulldb-adapter
|
231
231
|
requirement: !ruby/object:Gem::Requirement
|
@@ -278,6 +278,7 @@ extra_rdoc_files: []
|
|
278
278
|
files:
|
279
279
|
- ".gitignore"
|
280
280
|
- ".pelusa.yml"
|
281
|
+
- ".rspec"
|
281
282
|
- ".travis.yml"
|
282
283
|
- Gemfile
|
283
284
|
- Guardfile
|
@@ -386,6 +387,8 @@ files:
|
|
386
387
|
- license.md
|
387
388
|
- pelusa.sh
|
388
389
|
- rbs.sh
|
390
|
+
- spec/bogus/bugs/rbx_instance_eval_bug_spec.rb
|
391
|
+
- spec/bogus/bugs/rbx_jruby_stub_on_class_spec.rb
|
389
392
|
- spec/bogus/clean_ruby_spec.rb
|
390
393
|
- spec/bogus/configuration_spec.rb
|
391
394
|
- spec/bogus/contracts/adds_contract_verification_spec.rb
|
@@ -417,6 +420,7 @@ files:
|
|
417
420
|
- spec/bogus/fakes/resets_overwritten_classes_spec.rb
|
418
421
|
- spec/bogus/fakes/stubbing_new_method_on_fake_class_spec.rb
|
419
422
|
- spec/bogus/mocking_dsl_spec.rb
|
423
|
+
- spec/bogus/rspec/syntax_spec.rb
|
420
424
|
- spec/bogus/ruby_2_1_support_spec.rb
|
421
425
|
- spec/bogus/ruby_2_support_spec.rb
|
422
426
|
- spec/bogus/stubbing/anything_spec.rb
|
@@ -436,6 +440,7 @@ files:
|
|
436
440
|
- spec/spec_helper.rb
|
437
441
|
- spec/support/fake_creator_of_fakes.rb
|
438
442
|
- spec/support/matchers.rb
|
443
|
+
- spec/support/ruby_features.rb
|
439
444
|
- spec/support/sample_fake.rb
|
440
445
|
- spec/support/shared_examples_for_keyword_arguments.rb
|
441
446
|
homepage: https://github.com/psyho/bogus
|
@@ -457,8 +462,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
457
462
|
- !ruby/object:Gem::Version
|
458
463
|
version: '0'
|
459
464
|
requirements: []
|
460
|
-
|
461
|
-
rubygems_version: 2.2.2
|
465
|
+
rubygems_version: 3.4.10
|
462
466
|
signing_key:
|
463
467
|
specification_version: 4
|
464
468
|
summary: Create fakes to make your isolated unit tests reliable.
|
data/license.md
DELETED
@@ -1,9 +0,0 @@
|
|
1
|
-
# The MIT License (MIT)
|
2
|
-
|
3
|
-
Copyright (c) 2012-2013 Adam Pohorecki
|
4
|
-
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
6
|
-
|
7
|
-
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
8
|
-
|
9
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|