should_not 0.0.1 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +1 -0
- data/Rakefile +20 -2
- data/integration/minitest.rb +32 -0
- data/integration/rspec.rb +10 -0
- data/lib/should_not/constants.rb +6 -0
- data/lib/should_not/minitest.rb +7 -0
- data/lib/should_not/rspec.rb +2 -2
- data/lib/should_not/version.rb +1 -1
- data/should_not.gemspec +10 -2
- data/spec/should_not_spec.rb +46 -1
- metadata +29 -5
data/README.md
CHANGED
@@ -2,6 +2,7 @@
|
|
2
2
|
|
3
3
|
[![Build Status](https://travis-ci.org/mark-rushakoff/should_not.png?branch=master)](https://travis-ci.org/mark-rushakoff/should_not)
|
4
4
|
[![Code Climate](https://codeclimate.com/github/mark-rushakoff/should_not.png)](https://codeclimate.com/github/mark-rushakoff/should_not)
|
5
|
+
[![Gem Version](https://badge.fury.io/rb/should_not.png)](http://badge.fury.io/rb/should_not)
|
5
6
|
|
6
7
|
You `should_not` start your specs with the string `"should"`.
|
7
8
|
Use this gem to enforce that rule.
|
data/Rakefile
CHANGED
@@ -4,15 +4,33 @@ require 'stringio'
|
|
4
4
|
|
5
5
|
RSpec::Core::RakeTask.new(:spec)
|
6
6
|
|
7
|
-
task :default => :spec
|
7
|
+
task :default => [:spec, :integration]
|
8
8
|
|
9
|
+
desc 'Run specs against RSpec'
|
9
10
|
task :rspec do
|
10
11
|
require 'rspec/core'
|
11
12
|
err = StringIO.new
|
12
13
|
out = StringIO.new
|
13
14
|
RSpec::Core::Runner.run([integration_file('rspec')], err, out)
|
14
15
|
|
15
|
-
assert_contains!(out.string, '
|
16
|
+
assert_contains!(out.string, '8 examples, 2 failures')
|
17
|
+
puts "RSpec integration spec passed"
|
18
|
+
end
|
19
|
+
|
20
|
+
desc 'Run specs against MiniTest'
|
21
|
+
task :minitest do
|
22
|
+
require 'rbconfig'
|
23
|
+
ruby = File.join(RbConfig::CONFIG['bindir'], RbConfig::CONFIG['ruby_install_name'])
|
24
|
+
output = `#{ruby} #{integration_file('minitest')}`
|
25
|
+
|
26
|
+
assert_contains!(output, '6 tests')
|
27
|
+
assert_contains!(output, '2 failures')
|
28
|
+
puts "MiniTest integration spec passed"
|
29
|
+
end
|
30
|
+
|
31
|
+
desc 'Run all integration specs'
|
32
|
+
task :integration => [:rspec, :minitest] do
|
33
|
+
puts "All integration specs passed!"
|
16
34
|
end
|
17
35
|
|
18
36
|
INTEGRATION_DIR = File.expand_path(File.join(File.dirname(__FILE__), 'integration'))
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require 'should_not/minitest'
|
2
|
+
require 'minitest/autorun'
|
3
|
+
|
4
|
+
describe MiniTest do
|
5
|
+
it 'should fail when the string starts with should' do
|
6
|
+
1.must_equal 1
|
7
|
+
end
|
8
|
+
|
9
|
+
it 'can pass a normal test' do
|
10
|
+
1.must_equal 1
|
11
|
+
end
|
12
|
+
|
13
|
+
it 'passes when "should" is in the middle of the description' do
|
14
|
+
1.must_equal 1
|
15
|
+
end
|
16
|
+
|
17
|
+
describe 'a nested context' do
|
18
|
+
it 'should also fail when the string starts with should' do
|
19
|
+
1.must_equal 1
|
20
|
+
end
|
21
|
+
|
22
|
+
it 'can also pass a normal test' do
|
23
|
+
1.must_equal 1
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
describe 'another nested context with should in the string' do
|
28
|
+
it 'can pass yet another normal test' do
|
29
|
+
1.must_equal 1
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
data/integration/rspec.rb
CHANGED
@@ -26,4 +26,14 @@ describe RSpec do
|
|
26
26
|
1.should == 1
|
27
27
|
end
|
28
28
|
end
|
29
|
+
|
30
|
+
describe 'another nested context', :should => true do
|
31
|
+
it 'can pass yet another normal test' do
|
32
|
+
1.should == 1
|
33
|
+
end
|
34
|
+
|
35
|
+
it 'should not care if a spec starts with should' do
|
36
|
+
1.should == 1
|
37
|
+
end
|
38
|
+
end
|
29
39
|
end
|
data/lib/should_not/rspec.rb
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
require 'rspec/core'
|
2
|
+
require 'should_not/constants'
|
2
3
|
|
3
4
|
RSpec.configure do |config|
|
4
|
-
STARTS_WITH_SHOULD = /\Ashould\s/.freeze
|
5
5
|
config.before(:each) do
|
6
6
|
next if example.metadata[:should] == true
|
7
7
|
# Not sure that last is correct here -- is the array ever larger than one element?
|
8
8
|
description = example.metadata[:description_args].last.to_s
|
9
|
-
fail(
|
9
|
+
fail(ShouldNot::FAILURE_MESSAGE) if description.match(ShouldNot::STARTS_WITH_SHOULD)
|
10
10
|
end
|
11
11
|
end
|
data/lib/should_not/version.rb
CHANGED
data/should_not.gemspec
CHANGED
@@ -8,17 +8,25 @@ Gem::Specification.new do |spec|
|
|
8
8
|
spec.version = ShouldNot::VERSION
|
9
9
|
spec.authors = ["Mark Rushakoff"]
|
10
10
|
spec.email = ["mark.rushakoff@gmail.com"]
|
11
|
-
spec.description =
|
11
|
+
spec.description = <<-DESC
|
12
|
+
You should_not start your specs with the string "should".
|
13
|
+
If every spec starts with "should", then it's redundant everywhere.
|
14
|
+
|
15
|
+
Instead, write in an active tone:
|
16
|
+
`it "should ignore nil elements"` - BAD
|
17
|
+
`it "ignores nil elements"` - GOOD
|
18
|
+
DESC
|
12
19
|
spec.summary = %q{Fail specs that start with should.}
|
13
20
|
spec.homepage = "https://github.com/mark-rushakoff/should_not"
|
14
21
|
spec.license = "MIT"
|
15
22
|
|
16
23
|
spec.files = `git ls-files`.split($/)
|
17
24
|
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
-
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
25
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features|integration)/})
|
19
26
|
spec.require_paths = ["lib"]
|
20
27
|
|
21
28
|
spec.add_development_dependency "bundler", "~> 1.3"
|
22
29
|
spec.add_development_dependency "rake"
|
30
|
+
spec.add_development_dependency "minitest"
|
23
31
|
spec.add_development_dependency "rspec"
|
24
32
|
end
|
data/spec/should_not_spec.rb
CHANGED
@@ -1,8 +1,53 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
require 'should_not'
|
3
|
+
require 'should_not/rspec'
|
3
4
|
|
4
5
|
describe ShouldNot do
|
5
|
-
it '
|
6
|
+
it 'has a version number' do
|
6
7
|
ShouldNot::VERSION.should_not be_nil
|
7
8
|
end
|
9
|
+
|
10
|
+
describe 'constants' do
|
11
|
+
describe 'STARTS_WITH_SHOULD' do
|
12
|
+
subject { ShouldNot::STARTS_WITH_SHOULD }
|
13
|
+
|
14
|
+
it 'matches the whole word "should" at the beginning of the string' do
|
15
|
+
'should foo bar'.should match(subject)
|
16
|
+
end
|
17
|
+
|
18
|
+
it 'matches when "should" is capitalized' do
|
19
|
+
'Should foo bar'.should match(subject)
|
20
|
+
end
|
21
|
+
|
22
|
+
it 'does not match the word "should" in the middle of a string' do
|
23
|
+
'foo should bar'.should_not match(subject)
|
24
|
+
end
|
25
|
+
|
26
|
+
it "matches shouldn't at the beggining" do
|
27
|
+
"shouldn't foo bar".should match(subject)
|
28
|
+
end
|
29
|
+
|
30
|
+
it "does not match shouldn't in the middle" do
|
31
|
+
"foo shouldn't bar".should_not match(subject)
|
32
|
+
end
|
33
|
+
|
34
|
+
it 'does not other words starting with should' do
|
35
|
+
'shoulders are nice to have'.should_not match(subject)
|
36
|
+
'shoulda is a helpful library for testing Rails'.should_not match(subject)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
describe 'MINITEST_DESCRIPTION_PREFIX' do
|
40
|
+
subject { ShouldNot::MINITEST_DESCRIPTION_PREFIX }
|
41
|
+
|
42
|
+
it 'matches the irrelevant part of the test method name' do
|
43
|
+
stripped = 'test_0000_foo bar'.gsub(subject, '')
|
44
|
+
stripped.should == 'foo bar'
|
45
|
+
end
|
46
|
+
|
47
|
+
it 'handles when there are more than 10k tests' do
|
48
|
+
stripped = 'test_12345_foo bar'.gsub(subject, '')
|
49
|
+
stripped.should == 'foo bar'
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
8
53
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: should_not
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.7.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-04-
|
12
|
+
date: 2013-04-14 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
@@ -43,6 +43,22 @@ dependencies:
|
|
43
43
|
- - ! '>='
|
44
44
|
- !ruby/object:Gem::Version
|
45
45
|
version: '0'
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: minitest
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ! '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
54
|
+
type: :development
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
46
62
|
- !ruby/object:Gem::Dependency
|
47
63
|
name: rspec
|
48
64
|
requirement: !ruby/object:Gem::Requirement
|
@@ -59,7 +75,10 @@ dependencies:
|
|
59
75
|
- - ! '>='
|
60
76
|
- !ruby/object:Gem::Version
|
61
77
|
version: '0'
|
62
|
-
description: You should_not start your specs with the string "should"
|
78
|
+
description: ! " You should_not start your specs with the string \"should\".\n If
|
79
|
+
every spec starts with \"should\", then it's redundant everywhere.\n\n Instead,
|
80
|
+
write in an active tone:\n `it \"should ignore nil elements\"` - BAD\n `it \"ignores
|
81
|
+
nil elements\"` - GOOD\n"
|
63
82
|
email:
|
64
83
|
- mark.rushakoff@gmail.com
|
65
84
|
executables: []
|
@@ -73,8 +92,11 @@ files:
|
|
73
92
|
- LICENSE.txt
|
74
93
|
- README.md
|
75
94
|
- Rakefile
|
95
|
+
- integration/minitest.rb
|
76
96
|
- integration/rspec.rb
|
77
97
|
- lib/should_not.rb
|
98
|
+
- lib/should_not/constants.rb
|
99
|
+
- lib/should_not/minitest.rb
|
78
100
|
- lib/should_not/rspec.rb
|
79
101
|
- lib/should_not/version.rb
|
80
102
|
- should_not.gemspec
|
@@ -95,7 +117,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
95
117
|
version: '0'
|
96
118
|
segments:
|
97
119
|
- 0
|
98
|
-
hash: -
|
120
|
+
hash: -3511363848172378781
|
99
121
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
100
122
|
none: false
|
101
123
|
requirements:
|
@@ -104,7 +126,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
104
126
|
version: '0'
|
105
127
|
segments:
|
106
128
|
- 0
|
107
|
-
hash: -
|
129
|
+
hash: -3511363848172378781
|
108
130
|
requirements: []
|
109
131
|
rubyforge_project:
|
110
132
|
rubygems_version: 1.8.25
|
@@ -112,5 +134,7 @@ signing_key:
|
|
112
134
|
specification_version: 3
|
113
135
|
summary: Fail specs that start with should.
|
114
136
|
test_files:
|
137
|
+
- integration/minitest.rb
|
138
|
+
- integration/rspec.rb
|
115
139
|
- spec/should_not_spec.rb
|
116
140
|
- spec/spec_helper.rb
|