bogus 0.1.5 → 0.1.7

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.
Files changed (55) hide show
  1. checksums.yaml +5 -5
  2. data/.rspec +1 -0
  3. data/.travis.yml +6 -3
  4. data/Gemfile +0 -2
  5. data/Guardfile +1 -1
  6. data/bogus.gemspec +2 -4
  7. data/features/authors.md +2 -1
  8. data/features/changelog.md +8 -0
  9. data/features/contract_tests/contract_tests_mocks.feature +4 -4
  10. data/features/contract_tests/contract_tests_stubs.feature +4 -4
  11. data/features/contract_tests/custom_overwritten_class.feature +3 -3
  12. data/features/fakes/fake_objects.feature +2 -2
  13. data/lib/bogus/core_ext.rb +5 -1
  14. data/lib/bogus/fakes/method_stringifier.rb +2 -2
  15. data/lib/bogus/minitest/syntax.rb +2 -2
  16. data/lib/bogus/minitest.rb +2 -2
  17. data/lib/bogus/rspec/syntax.rb +3 -0
  18. data/lib/bogus/stubbing/verifies_stub_definition.rb +10 -1
  19. data/lib/bogus/version.rb +1 -1
  20. data/license.md +1 -0
  21. data/spec/bogus/bugs/rbx_instance_eval_bug_spec.rb +20 -0
  22. data/spec/bogus/bugs/rbx_jruby_stub_on_class_spec.rb +45 -0
  23. data/spec/bogus/contracts/adds_contract_verification_spec.rb +10 -10
  24. data/spec/bogus/contracts/adds_recording_spec.rb +9 -9
  25. data/spec/bogus/contracts/interactions_repository_spec.rb +13 -13
  26. data/spec/bogus/contracts/records_double_interactions_spec.rb +9 -7
  27. data/spec/bogus/contracts/verifies_contracts_spec.rb +9 -9
  28. data/spec/bogus/fakes/copies_classes_spec.rb +5 -5
  29. data/spec/bogus/fakes/creates_fakes_spec.rb +13 -13
  30. data/spec/bogus/fakes/creates_fakes_with_stubbed_methods_spec.rb +21 -19
  31. data/spec/bogus/fakes/fake_ar_attributes_spec.rb +3 -1
  32. data/spec/bogus/fakes/fake_configuration_spec.rb +4 -4
  33. data/spec/bogus/fakes/fakes_classes_spec.rb +6 -6
  34. data/spec/bogus/fakes/faking_factories_spec.rb +3 -1
  35. data/spec/bogus/fakes/frozen_fakes_spec.rb +3 -1
  36. data/spec/bogus/fakes/registers_created_fakes_spec.rb +8 -8
  37. data/spec/bogus/fakes/resets_overwritten_classes_spec.rb +8 -8
  38. data/spec/bogus/fakes/stubbing_new_method_on_fake_class_spec.rb +3 -1
  39. data/spec/bogus/mocking_dsl_spec.rb +3 -1
  40. data/spec/bogus/rspec/syntax_spec.rb +16 -0
  41. data/spec/bogus/ruby_2_1_support_spec.rb +4 -2
  42. data/spec/bogus/ruby_2_support_spec.rb +4 -2
  43. data/spec/bogus/stubbing/double_spec.rb +19 -19
  44. data/spec/bogus/stubbing/have_received_matcher_spec.rb +13 -14
  45. data/spec/bogus/stubbing/interaction_spec.rb +7 -7
  46. data/spec/bogus/stubbing/multi_stubber_spec.rb +5 -5
  47. data/spec/bogus/stubbing/record_interactions_spec.rb +2 -2
  48. data/spec/bogus/stubbing/resets_stubbed_methods_spec.rb +5 -5
  49. data/spec/bogus/stubbing/shadow_spec.rb +6 -6
  50. data/spec/bogus/stubbing/stubbing_existing_methods_on_fakes_spec.rb +1 -1
  51. data/spec/bogus/stubbing/verifies_stub_definition_spec.rb +14 -1
  52. data/spec/spec_helper.rb +6 -13
  53. data/spec/support/ruby_features.rb +19 -0
  54. metadata +13 -9
  55. data/license.md +0 -9
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 5692979cf19268250f0bd23067c79beca39210f9
4
- data.tar.gz: eace904b3205850ab8a3359453d4fe1236e120fe
2
+ SHA256:
3
+ metadata.gz: f19fb1ce0b29dead39cdc4fefdd2fb496abafbfc2fe1ce958f31a6dcf91cf708
4
+ data.tar.gz: 3694b31fbc3f9211de7e309d72042abd98e35fc5c63cb4fb32dce87484d7fde3
5
5
  SHA512:
6
- metadata.gz: f8be32e8fbc29928cc5f517c10bf6602dee35910e0c2768d83ec0db7c8a62bdd993cc84482aec9d26dd4ecce2f096f80ac0c9bc8ed2c7f6092bf0e570c7fcf54
7
- data.tar.gz: b12ed7d4b58170ff5f7180f559c054817ff7b84476808355d822b7d5270a34083d77f10996036d17d5a45f6da2da80b4e7e4de065e32ab65f244960b1fec43f5
6
+ metadata.gz: e324b7b0f9e4c1a8c5403de4d6ccd3a9a1e694a72d63a88af4c27819c59d3cd0c26e6ca22de87a304853b2c0189902a764efc543d6493c12a60a0ba262e5c737
7
+ data.tar.gz: d7489aa2eb177b1fd20409b808ad16f1b37183bfc226b56ce15ce3126472dc3e47a87a8c7724faf9daf910b789c96184c5925d86274b72314f9791a62d265c84
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --color
data/.travis.yml CHANGED
@@ -1,7 +1,10 @@
1
1
  language: ruby
2
2
  rvm:
3
3
  - 1.9.3
4
- - 2.0
5
- - 2.1.1
6
- - jruby-19mode
4
+ - 2.0.0
5
+ - 2.1
6
+ - 2.2
7
+ - jruby
8
+ - rbx
7
9
  script: bundle exec rspec spec && bundle exec cucumber --tag ~@wip
10
+ sudo: false
data/Gemfile CHANGED
@@ -2,5 +2,3 @@ source "http://rubygems.org"
2
2
 
3
3
  # Specify your gem's dependencies in bogus.gemspec
4
4
  gemspec
5
-
6
- gem 'minitest', require: false
data/Guardfile CHANGED
@@ -1,7 +1,7 @@
1
1
  # A sample Guardfile
2
2
  # More info at https://github.com/guard/guard#readme
3
3
 
4
- guard 'rspec', all_after_pass: true, all_on_start: true do
4
+ guard 'rspec', cmd: 'bundle exec rspec', all_after_pass: true, all_on_start: true do
5
5
  watch(%r{^spec/.+_spec\.rb$})
6
6
  watch(%r{^lib/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
7
7
  watch('spec/spec_helper.rb') { "spec" }
data/bogus.gemspec CHANGED
@@ -12,8 +12,6 @@ Gem::Specification.new do |s|
12
12
  s.summary = %q{Create fakes to make your isolated unit tests reliable.}
13
13
  s.description = %q{Decreases the need to write integration tests by ensuring that the things you stub or mock actually exist.}
14
14
 
15
- s.rubyforge_project = "bogus"
16
-
17
15
  s.files = `git ls-files`.split("\n")
18
16
  s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
19
17
  s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
@@ -32,11 +30,11 @@ Gem::Specification.new do |s|
32
30
  s.add_development_dependency 'guard-ctags-bundler'
33
31
  s.add_development_dependency 'growl'
34
32
  s.add_development_dependency 'libnotify'
35
- s.add_development_dependency 'rr'
36
33
  s.add_development_dependency 'relish'
37
34
  s.add_development_dependency 'coveralls'
35
+ s.add_development_dependency 'wwtd'
38
36
 
39
- s.add_development_dependency 'activerecord', '>= 3', '< 5'
37
+ s.add_development_dependency 'activerecord', '>= 3', '< 7'
40
38
  s.add_development_dependency 'activerecord-nulldb-adapter'
41
39
 
42
40
  s.add_development_dependency 'minitest', '>= 4.7'
data/features/authors.md CHANGED
@@ -29,9 +29,10 @@ The mocking DSL syntax was inspired by the [RR framework][rr].
29
29
 
30
30
  ## Sponsor
31
31
 
32
- The development of Bogus was partially sponsored by [Lunar Logic][llp].
32
+ The development of Bogus was partially sponsored by [GunpowderLabs][gunpowderlabs] and [Lunar Logic][llp].
33
33
 
34
34
  [llp]: http://www.lunarlogicpolska.com
35
+ [gunpowderlabs]: http://www.gunpowderlabs.com
35
36
 
36
37
  [psyho]: https://github.com/psyho
37
38
  [apohorecki]: http://twitter.com/apohorecki
@@ -1,3 +1,11 @@
1
+ ## 0.1.6
2
+
3
+ - Removed dependency on Coveralls::SimpleCov::Formatter (thanks to Ken Dreyer)
4
+ - Made all tests pass on Rubinious
5
+ - Updated tests to use RSpec Mocks instead of RR in unit tests
6
+ - Updated tests to use RSpec 3
7
+ - Fixed described_class in RSpec 3.*
8
+
1
9
  ## 0.1.5
2
10
 
3
11
  - Made it possible to use fake objects in case/when statements (override ===)
@@ -77,7 +77,7 @@ Feature: Contract tests with mocks
77
77
 
78
78
  library.checkout("Moby Dick")
79
79
 
80
- expect(library.has_book?("Moby Dick")).to be_false
80
+ expect(library.has_book?("Moby Dick")).to be(false)
81
81
  end
82
82
  end
83
83
  """
@@ -95,11 +95,11 @@ Feature: Contract tests with mocks
95
95
  it "allows checking out books that are in the inventory" do
96
96
  library.return("Moby Dick")
97
97
 
98
- expect(library.has_book?("Moby Dick")).to be_true
98
+ expect(library.has_book?("Moby Dick")).to be(true)
99
99
  end
100
100
 
101
101
  it "does not allow checking out unavailable books" do
102
- expect(library.has_book?("Moby Dick")).to be_false
102
+ expect(library.has_book?("Moby Dick")).to be(false)
103
103
  end
104
104
 
105
105
  it "marks books as unavailable after they are checked out" do
@@ -107,7 +107,7 @@ Feature: Contract tests with mocks
107
107
 
108
108
  library.checkout("Moby Dick")
109
109
 
110
- expect(library.has_book?("Moby Dick")).to be_false
110
+ expect(library.has_book?("Moby Dick")).to be(false)
111
111
  end
112
112
  end
113
113
  """
@@ -90,7 +90,7 @@ Feature: Contract tests with stubs
90
90
 
91
91
  library.checkout("Moby Dick")
92
92
 
93
- expect(library.has_book?("Moby Dick")).to be_false
93
+ expect(library.has_book?("Moby Dick")).to be(false)
94
94
  end
95
95
  end
96
96
  """
@@ -108,11 +108,11 @@ Feature: Contract tests with stubs
108
108
  it "allows checking out books that are in the inventory" do
109
109
  library.return("Moby Dick")
110
110
 
111
- expect(library.has_book?("Moby Dick")).to be_true
111
+ expect(library.has_book?("Moby Dick")).to be(true)
112
112
  end
113
113
 
114
114
  it "does not allow checking out unavailable books" do
115
- expect(library.has_book?("Moby Dick")).to be_false
115
+ expect(library.has_book?("Moby Dick")).to be(false)
116
116
  end
117
117
 
118
118
  it "marks books as unavailable after they are checked out" do
@@ -120,7 +120,7 @@ Feature: Contract tests with stubs
120
120
 
121
121
  library.checkout("Moby Dick")
122
122
 
123
- expect(library.has_book?("Moby Dick")).to be_false
123
+ expect(library.has_book?("Moby Dick")).to be(false)
124
124
  end
125
125
  end
126
126
  """
@@ -95,11 +95,11 @@ Feature: Customizing the overwritten class
95
95
  it "allows checking out books that are in the inventory" do
96
96
  library.return("Moby Dick")
97
97
 
98
- expect(library.has_book?("Moby Dick")).to be_true
98
+ expect(library.has_book?("Moby Dick")).to be(true)
99
99
  end
100
100
 
101
101
  it "does not allow checking out unavailable books" do
102
- expect(library.has_book?("Moby Dick")).to be_false
102
+ expect(library.has_book?("Moby Dick")).to be(false)
103
103
  end
104
104
 
105
105
  it "marks books as unavailable after they are checked out" do
@@ -107,7 +107,7 @@ Feature: Customizing the overwritten class
107
107
 
108
108
  library.checkout("Moby Dick")
109
109
 
110
- expect(library.has_book?("Moby Dick")).to be_false
110
+ expect(library.has_book?("Moby Dick")).to be(false)
111
111
  end
112
112
  end
113
113
  """
@@ -60,7 +60,7 @@ Feature: Faking existing classes
60
60
  fake(:library)
61
61
 
62
62
  it "does something" do
63
- expect(Student.learn(library)).to be_true
63
+ expect(Student.learn(library)).to be(true)
64
64
  end
65
65
  end
66
66
  """
@@ -140,7 +140,7 @@ Feature: Faking existing classes
140
140
  fake(:library)
141
141
 
142
142
  it "is identified as Library" do
143
- expect(library?(library)).to be_true
143
+ expect(library?(library)).to be(true)
144
144
  end
145
145
  end
146
146
  """
@@ -1,5 +1,5 @@
1
1
  # This monkey patch should not break Ruby compatibility
2
- # but is necessary because MRI, insead of calling object.kind_of?(module),
2
+ # but is necessary because MRI, instead of calling object.kind_of?(module),
3
3
  # calls the C function, which implements kind_of. This makes
4
4
  # using fake objects in switch cases produce unexpected results:
5
5
  #
@@ -15,7 +15,11 @@
15
15
  class Module
16
16
  # don't warn about redefining === method
17
17
  Bogus::Support.supress_warnings do
18
+ alias :__trequals__ :===
19
+
18
20
  def ===(object)
21
+ # BasicObjects do not have kind_of? method
22
+ return __trequals__(object) unless Object.__trequals__(object)
19
23
  object.kind_of?(self)
20
24
  end
21
25
  end
@@ -27,12 +27,12 @@ module Bogus
27
27
 
28
28
  def argument_to_string(name, type, default)
29
29
  case type
30
- when :block then "&#{name}"
30
+ when :block then "&#{name == :& ? 'block' : name}"
31
31
  when :key then default ? "#{name}: #{default}" : "#{name}: #{name}"
32
32
  when :keyreq then default ? "#{name}:" : "#{name}: #{name}"
33
33
  when :opt then default ? "#{name} = #{default}" : name
34
34
  when :req then name
35
- when :rest then "*#{name}"
35
+ when :rest then "*#{name == :* ? 'rest' : name}"
36
36
  when :keyrest then "**#{name}"
37
37
  else raise "unknown argument type: #{type}"
38
38
  end
@@ -17,8 +17,8 @@ module Bogus
17
17
 
18
18
  def after_suite(&block)
19
19
  # minitest 5 vs 4.7
20
- if defined? Minitest.after_run
21
- Minitest.after_run(&block)
20
+ if defined? ::Minitest.after_run
21
+ ::Minitest.after_run(&block)
22
22
  else
23
23
  MiniTest::Unit.after_tests(&block)
24
24
  end
@@ -38,8 +38,8 @@ module Bogus::Minitest
38
38
  end
39
39
 
40
40
  # minitest 5 vs 4.7
41
- if defined? Minitest::Test
42
- class Minitest::Test
41
+ if defined? ::Minitest::Test
42
+ class ::Minitest::Test
43
43
  include Bogus::Minitest
44
44
  end
45
45
  else
@@ -8,6 +8,9 @@ module Bogus
8
8
  def_delegators :context, :before, :after, :described_class
9
9
 
10
10
  def described_class=(value)
11
+ # for new RSpec (> 3.0)
12
+ context.metadata[:described_class] = value
13
+ # for old RSpec (< 3.0)
11
14
  context.example.metadata[:example_group][:described_class] = value
12
15
  end
13
16
 
@@ -8,12 +8,17 @@ module Bogus
8
8
  stubbing_non_existent_method!(object, method_name) unless object.respond_to?(method_name)
9
9
  return unless object.methods.include?(method_name)
10
10
  return if WithArguments.with_matcher?(args)
11
- method = object.method(method_name)
11
+ method = get_method_object(object, method_name)
12
12
  verify_call!(method, args)
13
13
  end
14
14
 
15
15
  private
16
16
 
17
+ def get_method_object(object, method_name)
18
+ return object.instance_method(:initialize) if constructor?(object, method_name)
19
+ object.method(method_name)
20
+ end
21
+
17
22
  def verify_call!(method, args)
18
23
  object = Object.new
19
24
  fake_method = method_stringifier.stringify(method, "")
@@ -31,5 +36,9 @@ module Bogus
31
36
  def stubbing_non_existent_method!(object, method_name)
32
37
  raise NameError, "#{object.inspect} does not respond to #{method_name}"
33
38
  end
39
+
40
+ def constructor?(object, method_name)
41
+ method_name.to_sym == :new && object.kind_of?(Class)
42
+ end
34
43
  end
35
44
  end
data/lib/bogus/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Bogus
2
- VERSION = "0.1.5"
2
+ VERSION = "0.1.7"
3
3
  end
data/license.md ADDED
@@ -0,0 +1 @@
1
+ features/license.md
@@ -0,0 +1,20 @@
1
+ require 'spec_helper'
2
+
3
+ describe Bogus do
4
+ class SampleForRbxInstanceEval < BasicObject
5
+ def x
6
+ 3
7
+ end
8
+ end
9
+
10
+ it "doesn't break #instance_eval on RBX" do
11
+ result = SampleForRbxInstanceEval.new.instance_eval{x}
12
+ expect(result).to eq(3)
13
+ end
14
+
15
+ it "does not break === with the monkey patch" do
16
+ expect(SampleForRbxInstanceEval === SampleForRbxInstanceEval.new).to be(true)
17
+ expect(BasicObject === SampleForRbxInstanceEval.new).to be(true)
18
+ expect(Bogus === SampleForRbxInstanceEval.new).to be(false)
19
+ end
20
+ end
@@ -0,0 +1,45 @@
1
+ require 'spec_helper'
2
+
3
+ class ExampleForRbxJRubyBug
4
+ def self.bar(argument)
5
+ argument
6
+ end
7
+
8
+ def self.foo(argument)
9
+ argument
10
+ end
11
+
12
+ def initialize(*args)
13
+ args
14
+ end
15
+ end
16
+
17
+ describe ExampleForRbxJRubyBug do
18
+ before do
19
+ extend Bogus::MockingDSL
20
+ end
21
+
22
+ context '.bar' do
23
+ specify 'stubbing class twice in example' do
24
+ stub(ExampleForRbxJRubyBug).bar('same_argument')
25
+ stub(ExampleForRbxJRubyBug).bar('same_argument')
26
+ end
27
+ end
28
+
29
+ context '.foo' do
30
+ specify 'stubbing class once in example' do
31
+ stub(ExampleForRbxJRubyBug).foo('same_argument')
32
+ end
33
+
34
+ specify 'stubbing class once in another example' do
35
+ stub(ExampleForRbxJRubyBug).foo('same_argument')
36
+ end
37
+ end
38
+
39
+ context '.new' do
40
+ before { stub(ExampleForRbxJRubyBug).new(any_args) }
41
+
42
+ specify { ExampleForRbxJRubyBug.new(1, 2, 3) }
43
+ specify { ExampleForRbxJRubyBug.new(1, 2, 3) }
44
+ end
45
+ end
@@ -37,7 +37,7 @@ describe Bogus::AddsContractVerification do
37
37
  it "verifies the contract in after_suite" do
38
38
  syntax.run_after_suite
39
39
 
40
- expect(verifies_contracts).to have_received.verify(:some_fake)
40
+ expect(verifies_contracts).to have_received(:verify).with(:some_fake)
41
41
  end
42
42
  end
43
43
 
@@ -49,17 +49,17 @@ describe Bogus::AddsContractVerification do
49
49
 
50
50
  let(:overwritten_class) { :the_overwritten_class }
51
51
 
52
- let(:adds_recording) { stub }
53
- let(:verifies_contracts) { stub }
54
- let(:converts_name_to_class) { stub }
52
+ let(:adds_recording) { double }
53
+ let(:verifies_contracts) { double }
54
+ let(:converts_name_to_class) { double }
55
55
  let(:syntax) { FakeSyntax.new(described_class) }
56
56
 
57
57
  let(:adds_contract_verification) { isolate(Bogus::AddsContractVerification) }
58
58
 
59
59
  before do
60
- stub(adds_recording).add { overwritten_class }
61
- stub(verifies_contracts).verify
62
- stub(converts_name_to_class).convert { ClassGuessedFromFakeName }
60
+ allow(adds_recording).to receive(:add) { overwritten_class }
61
+ allow(verifies_contracts).to receive(:verify)
62
+ allow(converts_name_to_class).to receive(:convert) { ClassGuessedFromFakeName }
63
63
  end
64
64
 
65
65
  context "with described_class" do
@@ -87,7 +87,7 @@ describe Bogus::AddsContractVerification do
87
87
  it "adds recording to described_class" do
88
88
  syntax.run_before
89
89
 
90
- expect(adds_recording).to have_received.add(:some_fake, SomeClass)
90
+ expect(adds_recording).to have_received(:add).with(:some_fake, SomeClass)
91
91
  end
92
92
  end
93
93
 
@@ -119,7 +119,7 @@ describe Bogus::AddsContractVerification do
119
119
  it "adds recording to custom class" do
120
120
  syntax.run_before
121
121
 
122
- expect(adds_recording).to have_received.add(:some_fake, ClassToOverwrite)
122
+ expect(adds_recording).to have_received(:add).with(:some_fake, ClassToOverwrite)
123
123
  end
124
124
  end
125
125
 
@@ -148,7 +148,7 @@ describe Bogus::AddsContractVerification do
148
148
  it "adds recording to class based on fake name" do
149
149
  syntax.run_before
150
150
 
151
- expect(adds_recording).to have_received.add(:some_fake, ClassGuessedFromFakeName)
151
+ expect(adds_recording).to have_received(:add).with(:some_fake, ClassGuessedFromFakeName)
152
152
  end
153
153
  end
154
154
  end
@@ -9,16 +9,16 @@ describe Bogus::AddsRecording do
9
9
  end
10
10
  end
11
11
 
12
- let(:create_proxy_class) { stub }
13
- let(:overwrites_classes) { stub }
14
- let(:overwritten_classes) { stub }
12
+ let(:create_proxy_class) { double }
13
+ let(:overwrites_classes) { double }
14
+ let(:overwritten_classes) { double }
15
15
 
16
16
  let(:adds_recording) { isolate(Bogus::AddsRecording) }
17
17
 
18
18
  before do
19
- stub(create_proxy_class).call { Object }
20
- stub(overwrites_classes).overwrite
21
- stub(overwritten_classes).add
19
+ allow(create_proxy_class).to receive(:call) { Object }
20
+ allow(overwrites_classes).to receive(:overwrite)
21
+ allow(overwritten_classes).to receive(:add)
22
22
  end
23
23
 
24
24
  before do
@@ -26,15 +26,15 @@ describe Bogus::AddsRecording do
26
26
  end
27
27
 
28
28
  it "creates the proxy" do
29
- expect(create_proxy_class).to have_received.call(:library, SampleModule::Library)
29
+ expect(create_proxy_class).to have_received(:call).with(:library, SampleModule::Library)
30
30
  end
31
31
 
32
32
  it "swaps the classes" do
33
- expect(overwrites_classes).to have_received.overwrite('SampleModule::Library', Object)
33
+ expect(overwrites_classes).to have_received(:overwrite).with('SampleModule::Library', Object)
34
34
  end
35
35
 
36
36
  it "records the overwritten class, so that it can be later restored" do
37
- expect(overwritten_classes).to have_received.add("SampleModule::Library", SampleModule::Library)
37
+ expect(overwritten_classes).to have_received(:add).with("SampleModule::Library", SampleModule::Library)
38
38
  end
39
39
 
40
40
  it "returns the proxy class" do
@@ -10,43 +10,43 @@ describe Bogus::InteractionsRepository do
10
10
  it "considers the interaction recorded if it was recorded previously" do
11
11
  interactions_repository.record(:foo, :bar, 1, 2, 3)
12
12
 
13
- expect(recorded?(:foo, :bar, 1, 2, 3)).to be_true
13
+ expect(recorded?(:foo, :bar, 1, 2, 3)).to be(true)
14
14
  end
15
15
 
16
16
  it "considers the interaction recorded if it returned the same value as passed block" do
17
17
  interactions_repository.record(:foo, :bar) { "a result" }
18
18
  interaction = Bogus::Interaction.new(:bar, []) { "a result" }
19
19
 
20
- expect(interactions_repository.recorded?(:foo, interaction)).to be_true
20
+ expect(interactions_repository.recorded?(:foo, interaction)).to be(true)
21
21
  end
22
22
 
23
23
  it "does not consider any interactions recorded prior to any recordings" do
24
- expect(recorded?(:foo, :bar, 1)).to be_false
24
+ expect(recorded?(:foo, :bar, 1)).to be(false)
25
25
  end
26
26
 
27
27
  it "does not consider the interaction recorded with a different fake name" do
28
28
  interactions_repository.record(:baz, :bar, 1)
29
29
 
30
- expect(recorded?(:foo, :bar, 1)).to be_false
30
+ expect(recorded?(:foo, :bar, 1)).to be(false)
31
31
  end
32
32
 
33
33
  it "does not consider the interaction recorded with a different method name" do
34
34
  interactions_repository.record(:foo, :baz, 1)
35
35
 
36
- expect(recorded?(:foo, :bar, 1)).to be_false
36
+ expect(recorded?(:foo, :bar, 1)).to be(false)
37
37
  end
38
38
 
39
39
  it "does not consider the interaction recorded with different method arguments" do
40
40
  interactions_repository.record(:foo, :bar, 1, 2)
41
41
 
42
- expect(recorded?(:foo, :bar, 1)).to be_false
42
+ expect(recorded?(:foo, :bar, 1)).to be(false)
43
43
  end
44
44
 
45
45
  it "returns a list of interactions for given fake" do
46
46
  interactions_repository.record(:foo, :bar, 1, 2)
47
47
 
48
48
  interactions = interactions_repository.for_fake(:foo)
49
- expect(interactions).to have(1).item
49
+ expect(interactions.size).to eq(1)
50
50
  expect(interactions.first.method).to eq :bar
51
51
  expect(interactions.first.args).to eq [1, 2]
52
52
  end
@@ -54,36 +54,36 @@ describe Bogus::InteractionsRepository do
54
54
  it "ignores arguments if the checked interaction has any_args" do
55
55
  interactions_repository.record(:foo, :bar, 1)
56
56
 
57
- expect(recorded?(:foo, :bar, Bogus::AnyArgs)).to be_true
57
+ expect(recorded?(:foo, :bar, Bogus::AnyArgs)).to be(true)
58
58
  end
59
59
 
60
60
  it "takes method name into account when matching interaction with wildcard arguments" do
61
61
  interactions_repository.record(:foo, :baz, 1)
62
62
 
63
- expect(recorded?(:foo, :bar, Bogus::AnyArgs)).to be_false
63
+ expect(recorded?(:foo, :bar, Bogus::AnyArgs)).to be(false)
64
64
  end
65
65
 
66
66
  it "ignores arguments if the recorded interaction was recorded with wildcard argument" do
67
67
  interactions_repository.record(:foo, :bar, 1, 2)
68
68
 
69
- expect(recorded?(:foo, :bar, 1, Bogus::Anything)).to be_true
69
+ expect(recorded?(:foo, :bar, 1, Bogus::Anything)).to be(true)
70
70
  end
71
71
 
72
72
  it "takes other arguments into account when matching interactions with wildcards" do
73
73
  interactions_repository.record(:foo, :bar, 1, 2)
74
74
 
75
- expect(recorded?(:foo, :bar, 2, Bogus::Anything)).to be_false
75
+ expect(recorded?(:foo, :bar, 2, Bogus::Anything)).to be(false)
76
76
  end
77
77
 
78
78
  it "ignores arguments if the checked interaction has any_args" do
79
79
  interactions_repository.record(:foo, :bar, 1, 2)
80
80
 
81
- expect(recorded?(:foo, :bar, 1, Bogus::Anything)).to be_true
81
+ expect(recorded?(:foo, :bar, 1, Bogus::Anything)).to be(true)
82
82
  end
83
83
 
84
84
  it "takes method name into account when matching interaction with wildcard arguments" do
85
85
  interactions_repository.record(:foo, :baz, 1, 2)
86
86
 
87
- expect(recorded?(:foo, :bar, 1, Bogus::Anything)).to be_false
87
+ expect(recorded?(:foo, :bar, 1, Bogus::Anything)).to be(false)
88
88
  end
89
89
  end
@@ -1,25 +1,27 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Bogus::RecordsDoubleInteractions do
4
- let(:fake_registry) { stub }
5
- let(:doubled_interactions) { stub }
4
+ let(:fake_registry) { double }
5
+ let(:doubled_interactions) { double }
6
6
  let(:object) { Object.new }
7
7
 
8
8
  let(:records_double_interactions) { isolate(Bogus::RecordsDoubleInteractions) }
9
9
 
10
10
  it "records the call in double interaction repository" do
11
- stub(fake_registry).name(object) { :object_name }
12
- stub(doubled_interactions).record
11
+ allow(fake_registry).to receive(:name).with(object) { :object_name }
12
+ allow(doubled_interactions).to receive(:record)
13
13
 
14
14
  records_double_interactions.record(object, :method_name, [:foo, 1])
15
15
 
16
- expect(doubled_interactions).to have_received.record(:object_name, :method_name, :foo, 1)
16
+ expect(doubled_interactions).to have_received(:record).with(:object_name, :method_name, :foo, 1)
17
17
  end
18
18
 
19
19
  it "does not record the interaction if object is not a fake" do
20
- stub(fake_registry).name(object) { nil }
21
- dont_allow(doubled_interactions).record
20
+ allow(fake_registry).to receive(:name).with(object) { nil }
21
+ allow(doubled_interactions).to receive(:record)
22
22
 
23
23
  records_double_interactions.record(object, :method_name, [:foo, 1])
24
+
25
+ expect(doubled_interactions).not_to have_received(:record)
24
26
  end
25
27
  end
@@ -1,8 +1,8 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Bogus::VerifiesContracts do
4
- let(:real_interactions) { stub }
5
- let(:doubled_interactions) { stub }
4
+ let(:real_interactions) { double }
5
+ let(:doubled_interactions) { double }
6
6
  let(:verifies_contracts) { isolate(Bogus::VerifiesContracts) }
7
7
 
8
8
  let(:matched_interaction) { interaction("matched") }
@@ -12,12 +12,12 @@ describe Bogus::VerifiesContracts do
12
12
  second_interaction = interaction("second")
13
13
  other_interaction = interaction("other")
14
14
 
15
- stub(doubled_interactions).for_fake(:fake_name){[first_interaction, matched_interaction, second_interaction]}
16
- stub(real_interactions).for_fake(:fake_name){[matched_interaction, other_interaction]}
15
+ allow(doubled_interactions).to receive(:for_fake).with(:fake_name){[first_interaction, matched_interaction, second_interaction]}
16
+ allow(real_interactions).to receive(:for_fake).with(:fake_name){[matched_interaction, other_interaction]}
17
17
 
18
- stub(real_interactions).recorded?(:fake_name, first_interaction) { false }
19
- stub(real_interactions).recorded?(:fake_name, second_interaction) { false }
20
- stub(real_interactions).recorded?(:fake_name, matched_interaction) { true }
18
+ allow(real_interactions).to receive(:recorded?).with(:fake_name, first_interaction) { false }
19
+ allow(real_interactions).to receive(:recorded?).with(:fake_name, second_interaction) { false }
20
+ allow(real_interactions).to receive(:recorded?).with(:fake_name, matched_interaction) { true }
21
21
 
22
22
  expect_verify_to_raise_error_with_interactions(:fake_name,
23
23
  [first_interaction, second_interaction],
@@ -25,8 +25,8 @@ describe Bogus::VerifiesContracts do
25
25
  end
26
26
 
27
27
  it "passes with all calls matched" do
28
- stub(doubled_interactions).for_fake(:fake_name) { [matched_interaction] }
29
- stub(real_interactions).recorded?(:fake_name, matched_interaction) { true }
28
+ allow(doubled_interactions).to receive(:for_fake).with(:fake_name) { [matched_interaction] }
29
+ allow(real_interactions).to receive(:recorded?).with(:fake_name, matched_interaction) { true }
30
30
 
31
31
  expect {
32
32
  verifies_contracts.verify(:fake_name)