minitest-rspec_mocks 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,34 @@
1
+ require 'minitest/autorun'
2
+ require 'rspec/mocks'
3
+ require 'minitest/rspec_mocks/version'
4
+
5
+ class Object
6
+ # remove Minitest's stub method so RSpec's version on BasicObject will work
7
+ if self.method_defined?(:stub) && !defined?(removed_minitest)
8
+ remove_method :stub
9
+ removed_minitest = true
10
+ end
11
+ end
12
+
13
+ module Minitest
14
+ module RSpecMocks
15
+ include RSpec::Mocks::ExampleMethods unless ::RSpec::Mocks::Version::STRING < "3"
16
+ def before_setup
17
+ if ::RSpec::Mocks::Version::STRING < "3"
18
+ ::RSpec::Mocks.setup(self)
19
+ else
20
+ ::RSpec::Mocks.setup
21
+ end
22
+ super
23
+ end
24
+
25
+ def after_teardown
26
+ begin
27
+ ::RSpec::Mocks.verify
28
+ ensure
29
+ ::RSpec::Mocks.teardown
30
+ end
31
+ super
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,38 @@
1
+ gem 'minitest'
2
+ require_relative '../../lib/minitest/rspec_mocks'
3
+ require "minitest/autorun"
4
+
5
+ # I am not sure how/if this test ever passed. We remove minitest stub
6
+ # when we require minitest_spec_mocks, so it doesn't make sense to
7
+ # have this test.
8
+ #
9
+ # class MinitestWithoutRspecMocksTest < Minitest::Unit::TestCase
10
+ # def test_it_should_use_minitest_stub
11
+ # string = "hello"
12
+ # string.stub(:to_i, 100) do
13
+ # assert string.to_i == 100
14
+ # end
15
+ # end
16
+ # end
17
+
18
+ class MinitestWithRspecMocksShouldStyleTest < Minitest::Unit::TestCase
19
+ include Minitest::RSpecMocks
20
+ def test_it_should_use_rspec_stub
21
+ RSpec::Mocks.configuration.syntax = :should
22
+ string = "hello"
23
+ assert string.to_i == 0
24
+ string.stub(to_i: 100)
25
+ assert string.to_i == 100
26
+ end
27
+ end
28
+
29
+ class MinitestWithRspecMocksExpectStyleTest < Minitest::Unit::TestCase
30
+ include Minitest::RSpecMocks
31
+ def test_it_should_use_rspec_expect
32
+ RSpec::Mocks.configuration.syntax = :expect
33
+ string = "hello"
34
+ assert string.to_i == 0
35
+ expect(string).to receive(:to_i).and_return 100
36
+ assert string.to_i == 100
37
+ end
38
+ end
metadata ADDED
@@ -0,0 +1,100 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: minitest-rspec_mocks
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Sammy Larbi
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2014-01-23 00:00:00.000000000Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: bundler
16
+ requirement: &2166803160 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: '1.3'
22
+ type: :development
23
+ prerelease: false
24
+ version_requirements: *2166803160
25
+ - !ruby/object:Gem::Dependency
26
+ name: rake
27
+ requirement: &2166802620 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ! '>='
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
33
+ type: :development
34
+ prerelease: false
35
+ version_requirements: *2166802620
36
+ - !ruby/object:Gem::Dependency
37
+ name: minitest
38
+ requirement: &2166801960 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ! '>='
42
+ - !ruby/object:Gem::Version
43
+ version: '4.0'
44
+ - - <
45
+ - !ruby/object:Gem::Version
46
+ version: '5.3'
47
+ type: :runtime
48
+ prerelease: false
49
+ version_requirements: *2166801960
50
+ - !ruby/object:Gem::Dependency
51
+ name: rspec-mocks
52
+ requirement: &2166801120 !ruby/object:Gem::Requirement
53
+ none: false
54
+ requirements:
55
+ - - ! '>='
56
+ - !ruby/object:Gem::Version
57
+ version: '2.14'
58
+ - - <=
59
+ - !ruby/object:Gem::Version
60
+ version: 3.0.0
61
+ type: :runtime
62
+ prerelease: false
63
+ version_requirements: *2166801120
64
+ description: Use rspec-mocks with minitest. A description of what this does doesn't
65
+ get longer than that.
66
+ email:
67
+ - sam@codeodor.com
68
+ executables: []
69
+ extensions: []
70
+ extra_rdoc_files: []
71
+ files:
72
+ - lib/minitest/rspec_mocks.rb
73
+ - test/minitest/rspec_mocks_test.rb
74
+ homepage: https://github.com/codeodor/minitest-rspec_mocks
75
+ licenses:
76
+ - MIT
77
+ post_install_message:
78
+ rdoc_options: []
79
+ require_paths:
80
+ - lib
81
+ required_ruby_version: !ruby/object:Gem::Requirement
82
+ none: false
83
+ requirements:
84
+ - - ! '>='
85
+ - !ruby/object:Gem::Version
86
+ version: '0'
87
+ required_rubygems_version: !ruby/object:Gem::Requirement
88
+ none: false
89
+ requirements:
90
+ - - ! '>='
91
+ - !ruby/object:Gem::Version
92
+ version: '0'
93
+ requirements: []
94
+ rubyforge_project:
95
+ rubygems_version: 1.8.8
96
+ signing_key:
97
+ specification_version: 3
98
+ summary: Use rspec-mocks with minitest
99
+ test_files:
100
+ - test/minitest/rspec_mocks_test.rb