rspec_stubout 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- MjI3NTRlZjE4YzAzMzNjMjllMzc3N2I3ODE4OWNlMGYwZGVmMDY0OA==
4
+ NTEwYjc3YjZkZWUxOWFhMWVmODcyMWRmNWIwNTAzMTUyNTg3NDAwZA==
5
5
  data.tar.gz: !binary |-
6
- NjQ4NDZmMGEyZjcwZjE2ZDEzZWE5ZmYzNmYzNjhiZjEwZjE5MmVjNA==
6
+ OTM5M2ZkYzRjNTEzYjVkOWEzOWNkMDI5ZGNmNmI0MDBhNTAxNTYyMg==
7
7
  !binary "U0hBNTEy":
8
8
  metadata.gz: !binary |-
9
- NzcyMmRhMWJiYTRmN2E5ZTJiODI2ZWFhMTkxYzE5MDE1ZjJiNjkzNjZkZjll
10
- NDY0NTgyZTk4NDdjYzAyOGYwOTU1YmEyNDMxNDc2NjI5YTlhMGU2OTY0ZDE4
11
- ODQ4Y2QzODBkMmRhMjYxZjNiYmJkNjZlNWRlZTY5YjE1MzE2ZWI=
9
+ NWFiMzI3MDlkMmU1NmI3OTE2NTA4N2E4NWQ3ODBhMzg3Nzc0ZTI4MTJjM2Vi
10
+ NWI4NTU1ZjBkZGMxODhjZGI1YmE1MWQyZDQ2YWNjNWUzNWU2MmIyMDYzMjUx
11
+ YWY0NGRjZWRjMDc3N2U4YTFjYjRhNjFjMTJhMGRlMjAwMWY3OWI=
12
12
  data.tar.gz: !binary |-
13
- OGFiYmJmYmFhYWE5OGMxNzM0NDQyMmJiNGQ5YzRmNTVjYjBjNDdmYTU4N2Ri
14
- MzQ0NjA3ZThlNzVmNGU5ZDdjYzUzMGJjNWVmYWQ0MWYyN2ExZDYzMGE4NDRi
15
- ZDNmMzNiOGNkYTUzYTEyOTM5NDBjZWExYTc1ODc0ZTIyZDk0MWM=
13
+ NzhjMTc5MGRiNzdiYzgxMmQ0ODZjNGVmZWNhOGExYTc5YzY3N2RmZmFiYjZi
14
+ ZTdiZTcxNGE3NjE0YTUwMTM4MGUwNTQwYTczN2E0NmZjN2VlMjE0MWJjOTBl
15
+ OTA4MDA0OWUwNzVhMDhlY2RjNmE1YmE4NDM5ZTEwY2U2NzExNGM=
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License
2
+
3
+ Copyright (c) 2013 Matthew M. Boedicker
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -7,8 +7,16 @@ module RspecStubout
7
7
  def prevent_stubout(rspec_config)
8
8
  rspec_config.before(:each) do
9
9
  unless example.metadata[:allow_stubout]
10
- subject.stub(:stub) do
11
- raise "#{subject.inspect} is the object under test and should not be stubbed"
10
+ begin
11
+ described_class.stub(:stub) do
12
+ raise "#{described_class} is the object under test and should not be stubbed"
13
+ end
14
+
15
+ subject.stub(:stub) do
16
+ raise "#{subject} is the object under test and should not be stubbed"
17
+ end
18
+ rescue => e
19
+ warn "rspec stubout setup failed, possibly setup in another before(:each) has not run yet: #{e.inspect}"
12
20
  end
13
21
  end
14
22
  end
@@ -1,5 +1,5 @@
1
1
  # encoding: UTF-8
2
2
 
3
3
  module RspecStubout
4
- VERSION = '0.0.1'
4
+ VERSION = '0.0.2'
5
5
  end
@@ -12,6 +12,7 @@ Gem::Specification.new do |s|
12
12
  s.homepage = 'https://github.com/mmb/rspec_stubout'
13
13
  s.authors = ['Matthew M. Boedicker']
14
14
  s.email = %w{matthewm@boedicker.org}
15
+ s.license = 'MIT'
15
16
 
16
17
  s.add_dependency 'rspec'
17
18
 
@@ -0,0 +1,15 @@
1
+ require 'spec_helper'
2
+
3
+ class C
4
+ end
5
+
6
+ describe C do
7
+
8
+ it 'raises an error when subject is stubbed' do
9
+ expect {
10
+ subject.stub(method1: 'foo')
11
+ }.to raise_error(
12
+ /<C.* is the object under test and should not be stubbed/)
13
+ end
14
+
15
+ end
@@ -12,7 +12,7 @@ describe RspecStubout do
12
12
  expect {
13
13
  subject.stub(method1: 'foo')
14
14
  }.to raise_error(
15
- '"subject" is the object under test and should not be stubbed')
15
+ 'subject is the object under test and should not be stubbed')
16
16
  end
17
17
 
18
18
  end
@@ -23,7 +23,7 @@ describe RspecStubout do
23
23
  expect {
24
24
  subject.stub_chain(:method1, :method2) { 'foo' }
25
25
  }.to raise_error(
26
- '"subject" is the object under test and should not be stubbed')
26
+ 'subject is the object under test and should not be stubbed')
27
27
  end
28
28
 
29
29
  end
@@ -37,7 +37,7 @@ describe RspecStubout do
37
37
  expect {
38
38
  object.stub(method1: 'foo')
39
39
  }.to raise_error(
40
- '"subject" is the object under test and should not be stubbed')
40
+ "subject is the object under test and should not be stubbed")
41
41
  end
42
42
 
43
43
  end
@@ -50,7 +50,7 @@ describe RspecStubout do
50
50
  expect {
51
51
  object.stub(method1: 'foo')
52
52
  }.to raise_error(
53
- '"subject" is the object under test and should not be stubbed')
53
+ "subject is the object under test and should not be stubbed")
54
54
  end
55
55
 
56
56
  end
@@ -64,4 +64,31 @@ describe RspecStubout do
64
64
 
65
65
  end
66
66
 
67
+ context 'when subject requires setup in group before(:each)' do
68
+
69
+ before(:each) do
70
+ @a = 1
71
+ end
72
+
73
+ subject {
74
+ raise if @a.nil?
75
+ 'subject'
76
+ }
77
+
78
+ it 'does not raise an error' do
79
+ subject.stub(method1: 'foo')
80
+ end
81
+
82
+ end
83
+
84
+ context 'when described_class is stubbed' do
85
+
86
+ it 'raises an error' do
87
+ expect {
88
+ described_class.stub(method1: 'foo')
89
+ }.to raise_error('RspecStubout is the object under test and should not be stubbed')
90
+ end
91
+
92
+ end
93
+
67
94
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rspec_stubout
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matthew M. Boedicker
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-07-31 00:00:00.000000000 Z
11
+ date: 2013-08-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec
@@ -47,15 +47,18 @@ extra_rdoc_files: []
47
47
  files:
48
48
  - .travis.yml
49
49
  - Gemfile
50
+ - LICENSE
50
51
  - README.md
51
52
  - Rakefile
52
53
  - lib/rspec_stubout/prevent_stubout.rb
53
54
  - lib/rspec_stubout/version.rb
54
55
  - rspec_stubout.gemspec
56
+ - spec/implicit_subject_spec.rb
55
57
  - spec/rspec_stubout_spec.rb
56
58
  - spec/spec_helper.rb
57
59
  homepage: https://github.com/mmb/rspec_stubout
58
- licenses: []
60
+ licenses:
61
+ - MIT
59
62
  metadata: {}
60
63
  post_install_message:
61
64
  rdoc_options: []