bogus 0.1.6 → 0.1.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 4056fb1f5ddc7c47b6e82b777c0d220caff62b21
4
- data.tar.gz: 3cc4493f6798d729ddc5b14bc9460a1c35632b88
2
+ SHA256:
3
+ metadata.gz: f19fb1ce0b29dead39cdc4fefdd2fb496abafbfc2fe1ce958f31a6dcf91cf708
4
+ data.tar.gz: 3694b31fbc3f9211de7e309d72042abd98e35fc5c63cb4fb32dce87484d7fde3
5
5
  SHA512:
6
- metadata.gz: c010976d4a8cdf3a2222f467bf41db819bea5178107c8fee3f907cb3648942c15e37f255d49d3bf0d367156a2ff716dff1f56705dbe727ca2571eaeb6702469b
7
- data.tar.gz: bb1aa720bdd300d3b2ecc6b471f62673ed702deec6159e0e53658f2e3d6a33d5cfc55bdbc60b7418cc12f174e8eda0ac44f823701a85a3efa7657bb43981c0dd
6
+ metadata.gz: e324b7b0f9e4c1a8c5403de4d6ccd3a9a1e694a72d63a88af4c27819c59d3cd0c26e6ca22de87a304853b2c0189902a764efc543d6493c12a60a0ba262e5c737
7
+ data.tar.gz: d7489aa2eb177b1fd20409b808ad16f1b37183bfc226b56ce15ce3126472dc3e47a87a8c7724faf9daf910b789c96184c5925d86274b72314f9791a62d265c84
data/.travis.yml CHANGED
@@ -1,8 +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
7
8
  - rbx
8
9
  script: bundle exec rspec spec && bundle exec cucumber --tag ~@wip
10
+ sudo: false
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) }
@@ -36,7 +34,7 @@ Gem::Specification.new do |s|
36
34
  s.add_development_dependency 'coveralls'
37
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
@@ -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,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.6"
2
+ VERSION = "0.1.7"
3
3
  end
data/license.md ADDED
@@ -0,0 +1 @@
1
+ features/license.md
@@ -81,7 +81,7 @@ describe Bogus::FakeConfiguration do
81
81
  end
82
82
 
83
83
  block = stubs(:foo)[:bar]
84
- expect{ block.call }.to raise_error
84
+ expect{ block.call }.to raise_error RuntimeError
85
85
  end
86
86
  end
87
87
 
@@ -14,7 +14,7 @@ module Bogus
14
14
 
15
15
  expect {
16
16
  double_instance.stub.foo("a", "b") { "the result" }
17
- }.to raise_error
17
+ }.to raise_error NameError
18
18
 
19
19
  expect(double_tracker).not_to have_received(:track).with(object)
20
20
  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,9 +1,9 @@
1
1
  require 'simplecov'
2
2
  begin
3
3
  require "coveralls"
4
- SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[
4
+ SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter.new([
5
5
  SimpleCov::Formatter::HTMLFormatter,
6
- Coveralls::SimpleCov::Formatter]
6
+ Coveralls::SimpleCov::Formatter])
7
7
  rescue LoadError
8
8
  warn "warning: coveralls gem not found; skipping Coveralls"
9
9
  SimpleCov.formatter = SimpleCov::Formatter::HTMLFormatter
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.6
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: 2015-01-02 00:00:00.000000000 Z
11
+ date: 2024-07-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: dependor
@@ -215,7 +215,7 @@ dependencies:
215
215
  version: '3'
216
216
  - - "<"
217
217
  - !ruby/object:Gem::Version
218
- version: '5'
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: '5'
228
+ version: '7'
229
229
  - !ruby/object:Gem::Dependency
230
230
  name: activerecord-nulldb-adapter
231
231
  requirement: !ruby/object:Gem::Requirement
@@ -462,8 +462,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
462
462
  - !ruby/object:Gem::Version
463
463
  version: '0'
464
464
  requirements: []
465
- rubyforge_project: bogus
466
- rubygems_version: 2.2.2
465
+ rubygems_version: 3.4.10
467
466
  signing_key:
468
467
  specification_version: 4
469
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.