shindo 0.0.18 → 0.1.0
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.
- data/Gemfile +1 -2
- data/Gemfile.lock +10 -16
- data/README.rdoc +15 -34
- data/bin/shindo +24 -8
- data/lib/shindo.rb +133 -98
- data/shindo.gemspec +7 -6
- data/tests/basic_tests.rb +3 -21
- data/tests/bin_tests.rb +27 -0
- data/tests/data/negative +6 -3
- data/tests/data/positive +6 -3
- data/tests/tag_tests.rb +9 -9
- data/tests/tests_helper.rb +14 -0
- metadata +9 -8
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,24 +1,18 @@
|
|
1
1
|
---
|
2
|
-
specs:
|
3
|
-
- rake:
|
4
|
-
version: 0.8.7
|
5
|
-
- formatador:
|
6
|
-
version: 0.0.14
|
7
|
-
- gestalt:
|
8
|
-
version: 0.0.6
|
9
|
-
hash: 967644697cb16cde400ae3abbd4c764876c4a3b0
|
10
|
-
sources: []
|
11
|
-
|
12
2
|
dependencies:
|
13
3
|
formatador:
|
14
|
-
version: ">= 0.0.14"
|
15
|
-
group:
|
16
|
-
- :default
|
17
|
-
rake:
|
18
|
-
version: ">= 0"
|
19
4
|
group:
|
20
5
|
- :default
|
6
|
+
version: ">= 0.0.14"
|
21
7
|
gestalt:
|
22
|
-
version: ">= 0.0.6"
|
23
8
|
group:
|
24
9
|
- :default
|
10
|
+
version: ">= 0.0.11"
|
11
|
+
specs:
|
12
|
+
- formatador:
|
13
|
+
version: 0.0.14
|
14
|
+
- gestalt:
|
15
|
+
version: 0.0.11
|
16
|
+
hash: 5c2e77551db0a4772439a57b49e0ecc967e4dfe3
|
17
|
+
sources: []
|
18
|
+
|
data/README.rdoc
CHANGED
@@ -4,62 +4,43 @@ Simple depth first ruby testing, watch and learn.
|
|
4
4
|
|
5
5
|
== Writing tests
|
6
6
|
|
7
|
-
|
7
|
+
Tests group similar assertions, but their return value is ignored.
|
8
8
|
|
9
|
-
|
9
|
+
After that you just test based on the two things a ruby thing should do, raise or return.
|
10
10
|
|
11
|
-
|
12
|
-
test('something really important') { true }
|
13
|
-
end
|
14
|
-
|
15
|
-
A failing test should return false or nil. (boo)
|
11
|
+
Returns takes what you expect and checks a block to see if the return value matches:
|
16
12
|
|
17
13
|
Shindo.tests do
|
18
|
-
|
14
|
+
returns(true) { true }
|
15
|
+
returns(false) { false }
|
19
16
|
end
|
20
17
|
|
21
|
-
|
18
|
+
Raises takes what error you expect and checks to see if the block will raise it:
|
22
19
|
|
23
20
|
Shindo.tests do
|
24
|
-
|
25
|
-
end
|
26
|
-
|
27
|
-
Grouping tests
|
28
|
-
|
29
|
-
Shindo.tests do
|
30
|
-
tests('foo/bar') do
|
31
|
-
test('foo') { true }
|
32
|
-
test('bar') { true }
|
33
|
-
end
|
21
|
+
raises(StandardError) { StandardError.new }
|
34
22
|
end
|
35
23
|
|
36
|
-
You can also
|
24
|
+
You can also override the default descriptions:
|
37
25
|
|
38
26
|
Shindo.tests('foo/bar') do
|
39
|
-
|
40
|
-
|
27
|
+
returns('foo', 'returns foo when bar') { 'foo' }
|
28
|
+
returns('bar', 'returns bar when qux') { 'bar' }
|
41
29
|
end
|
42
30
|
|
43
|
-
Nest tests as deeply as you would like.
|
44
|
-
|
45
31
|
Then, if you want to get real fancy you can also tag your tests, to help narrow down which ones to run
|
46
32
|
|
47
|
-
Shindo.tests do
|
48
|
-
tests('foo/bar', ['foo', 'bar']) do
|
33
|
+
Shindo.tests('tests for foo', 'foo') do
|
49
34
|
test('foo') { true }
|
50
|
-
test('bar') { true }
|
51
|
-
end
|
52
35
|
end
|
53
36
|
|
54
|
-
|
55
|
-
|
56
|
-
Shindo.tests do
|
57
|
-
tests('foo/bar') do
|
58
|
-
test('foo', ['foo']) { true }
|
59
|
-
test('bar', ['bar']) { true }
|
37
|
+
Shindo.tests('tests for bar', 'bar') do
|
38
|
+
test('bar') { true }
|
60
39
|
end
|
61
40
|
end
|
62
41
|
|
42
|
+
Note: you'll have to supply a non-default description first, and then follow up with tags.
|
43
|
+
|
63
44
|
== Running tests
|
64
45
|
|
65
46
|
Run tests with the shindo command, the easiest is to specify a file name:
|
data/bin/shindo
CHANGED
@@ -1,8 +1,7 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
require File.join(File.dirname(__FILE__), '..', 'lib', 'shindo')
|
3
3
|
|
4
|
-
helpers = Dir.glob(File.join(Dir.pwd, 'tests', '**', '*helper.rb'))
|
5
|
-
tests = []
|
4
|
+
helpers = Dir.glob(File.join(Dir.pwd, 'tests', '**', '*helper.rb')).sort_by {|helper| helper.count(File::SEPARATOR)}
|
6
5
|
tags = []
|
7
6
|
for argument in ARGV
|
8
7
|
if argument.match(/^[\+\-]/)
|
@@ -10,18 +9,24 @@ for argument in ARGV
|
|
10
9
|
else
|
11
10
|
path = File.expand_path(argument)
|
12
11
|
if File.directory?(path)
|
12
|
+
tests ||= []
|
13
13
|
tests |= Dir.glob(File.join(path, '**', '*tests.rb'))
|
14
|
-
|
14
|
+
elsif File.exists?(path)
|
15
|
+
tests ||= []
|
15
16
|
tests << path
|
17
|
+
else
|
18
|
+
Formatador.display_line("[red][bold]#{argument}[/] [red]does not exist, please fix this path and try again.[/]")
|
19
|
+
Kernel.exit(1)
|
16
20
|
end
|
17
21
|
end
|
18
22
|
end
|
19
23
|
|
20
|
-
|
21
|
-
|
24
|
+
# ARGV was empty or only contained tags
|
25
|
+
unless tests
|
26
|
+
tests = Dir.glob(File.join('tests', '**', '*tests.rb'))
|
22
27
|
end
|
23
28
|
|
24
|
-
@
|
29
|
+
@started_at = Time.now
|
25
30
|
def run_in_thread(helpers, tests, tags)
|
26
31
|
shindo = Thread.new {
|
27
32
|
Thread.current[:tags] = tags
|
@@ -34,14 +39,25 @@ def run_in_thread(helpers, tests, tags)
|
|
34
39
|
}
|
35
40
|
shindo.join
|
36
41
|
if shindo[:reload]
|
37
|
-
@success = true
|
38
42
|
run_in_thread(helpers, tests, tags)
|
39
43
|
else
|
40
|
-
@
|
44
|
+
@totals = shindo[:totals]
|
41
45
|
end
|
42
46
|
end
|
43
47
|
run_in_thread(helpers, tests, tags)
|
44
48
|
|
49
|
+
@totals ||= { :failed => 0, :pending => 0, :succeeded => 0 }
|
50
|
+
@success = @totals[:failed] == 0
|
51
|
+
lines = []
|
52
|
+
lines << "[red]#{@totals[:failed]} failed[/]," if @totals[:failed] > 0
|
53
|
+
lines << "[yellow]#{@totals[:pending]} pending[/]," if @totals[:pending] > 0
|
54
|
+
lines << "[green]#{@totals[:succeeded]} succeeded[/]"
|
55
|
+
lines = lines[0...-2].join(', ') << ' and ' << lines[-1] if lines.length > 3
|
56
|
+
lines << "in [bold]#{Time.now - @started_at}[/] seconds"
|
57
|
+
Formatador.display_line
|
58
|
+
Formatador.display_line(lines.join(' '))
|
59
|
+
Formatador.display_line
|
60
|
+
|
45
61
|
if @success
|
46
62
|
Kernel.exit(0)
|
47
63
|
else
|
data/lib/shindo.rb
CHANGED
@@ -1,10 +1,11 @@
|
|
1
1
|
require 'rubygems'
|
2
2
|
require 'formatador'
|
3
|
+
require 'gestalt'
|
3
4
|
|
4
5
|
module Shindo
|
5
6
|
|
6
|
-
unless VERSION
|
7
|
-
VERSION = '0.0
|
7
|
+
unless const_defined?(:VERSION)
|
8
|
+
VERSION = '0.1.0'
|
8
9
|
end
|
9
10
|
|
10
11
|
def self.tests(description = nil, tags = [], &block)
|
@@ -20,8 +21,8 @@ module Shindo
|
|
20
21
|
@formatador = Formatador.new
|
21
22
|
@tag_stack = []
|
22
23
|
Thread.current[:reload] = false
|
23
|
-
Thread.current[:success] = true
|
24
24
|
Thread.current[:tags] ||= []
|
25
|
+
Thread.current[:totals] ||= { :failed => 0, :pending => 0, :skipped => 0, :succeeded => 0 }
|
25
26
|
@if_tagged = []
|
26
27
|
@unless_tagged = []
|
27
28
|
for tag in Thread.current[:tags]
|
@@ -45,20 +46,130 @@ module Shindo
|
|
45
46
|
@befores.last.push(block)
|
46
47
|
end
|
47
48
|
|
49
|
+
def tests(description, tags = [], &block)
|
50
|
+
return if @exit || Thread.current[:reload]
|
51
|
+
|
52
|
+
tags = [*tags]
|
53
|
+
@tag_stack.push(tags)
|
54
|
+
@befores.push([])
|
55
|
+
@afters.push([])
|
56
|
+
|
57
|
+
@description = nil
|
58
|
+
description ||= 'Shindo.tests'
|
59
|
+
description = "[bold]#{description}[normal]"
|
60
|
+
unless tags.empty?
|
61
|
+
description << " (#{tags.join(', ')})"
|
62
|
+
end
|
63
|
+
|
64
|
+
# if the test includes +tags and discludes -tags, evaluate it
|
65
|
+
if (@if_tagged.empty? || !(@if_tagged & @tag_stack.flatten).empty?) &&
|
66
|
+
(@unless_tagged.empty? || (@unless_tagged & @tag_stack.flatten).empty?)
|
67
|
+
if block_given?
|
68
|
+
@formatador.display_line(description)
|
69
|
+
@formatador.indent { instance_eval(&block) }
|
70
|
+
else
|
71
|
+
@description = description
|
72
|
+
end
|
73
|
+
else
|
74
|
+
@formatador.display_line("[light_black]#{description}[/]")
|
75
|
+
end
|
76
|
+
|
77
|
+
@afters.pop
|
78
|
+
@befores.pop
|
79
|
+
@tag_stack.pop
|
80
|
+
|
81
|
+
Thread.exit if @exit || Thread.current[:reload]
|
82
|
+
self
|
83
|
+
end
|
84
|
+
|
85
|
+
def raises(error, &block)
|
86
|
+
assert(:raises, error, "raises #{error.inspect}", &block)
|
87
|
+
end
|
88
|
+
|
89
|
+
def returns(expectation, &block)
|
90
|
+
assert(:returns, expectation, "returns #{expectation.inspect}", &block)
|
91
|
+
end
|
92
|
+
|
93
|
+
def test(description = 'returns true', &block)
|
94
|
+
assert(:returns, true, description, &block)
|
95
|
+
end
|
96
|
+
|
97
|
+
private
|
98
|
+
|
99
|
+
def assert(type, expectation, description, &block)
|
100
|
+
return if @exit || Thread.current[:reload]
|
101
|
+
description = [@description, description].compact.join(' ')
|
102
|
+
success = nil
|
103
|
+
@gestalt = Gestalt.new({'formatador' => @formatador})
|
104
|
+
if block_given?
|
105
|
+
begin
|
106
|
+
for before in @befores.flatten.compact
|
107
|
+
before.call
|
108
|
+
end
|
109
|
+
value = @gestalt.run(&block)
|
110
|
+
success = case type
|
111
|
+
when :raises
|
112
|
+
value.is_a?(expectation)
|
113
|
+
when :returns
|
114
|
+
value == expectation
|
115
|
+
end
|
116
|
+
for after in @afters.flatten.compact
|
117
|
+
after.call
|
118
|
+
end
|
119
|
+
rescue => error
|
120
|
+
@formatador.display_line("[red]#{error.message} (#{error.class})[/]")
|
121
|
+
end
|
122
|
+
if success
|
123
|
+
success(description)
|
124
|
+
else
|
125
|
+
failure(description)
|
126
|
+
@message ||= [
|
127
|
+
"expected => #{expectation.inspect}",
|
128
|
+
"returned => #{value.inspect}"
|
129
|
+
]
|
130
|
+
@formatador.indent do
|
131
|
+
@formatador.display_lines([*@message].map {|message| "[red]#{message}[/]"})
|
132
|
+
end
|
133
|
+
@message = nil
|
134
|
+
if STDOUT.tty?
|
135
|
+
prompt(description, &block)
|
136
|
+
end
|
137
|
+
end
|
138
|
+
else
|
139
|
+
pending(description)
|
140
|
+
end
|
141
|
+
success
|
142
|
+
end
|
143
|
+
|
144
|
+
def failure(description, &block)
|
145
|
+
Thread.current[:totals][:failed] += 1
|
146
|
+
@formatador.display_line("[red]- #{description}[/]")
|
147
|
+
end
|
148
|
+
|
149
|
+
def pending(description, &block)
|
150
|
+
Thread.current[:totals][:pending] += 1
|
151
|
+
@formatador.display_line("[yellow]# #{description}[/]")
|
152
|
+
end
|
153
|
+
|
48
154
|
def prompt(description, &block)
|
49
155
|
@formatador.display("Action? [c,e,i,q,r,t,?]? ")
|
50
156
|
choice = STDIN.gets.strip
|
157
|
+
continue = false
|
51
158
|
@formatador.display_line
|
52
159
|
@formatador.indent do
|
53
160
|
case choice
|
54
161
|
when 'c', 'continue'
|
55
|
-
|
162
|
+
continue = true
|
56
163
|
when /^e .*/, /^eval .*/
|
57
|
-
|
58
|
-
|
59
|
-
value
|
164
|
+
begin
|
165
|
+
value = eval(choice[2..-1], @gestalt.bindings.last)
|
166
|
+
if value.nil?
|
167
|
+
value = 'nil'
|
168
|
+
end
|
169
|
+
@formatador.display_line(value)
|
170
|
+
rescue => error
|
171
|
+
@formatador.display_line("[red]#{error.message} (#{error.class})[/]")
|
60
172
|
end
|
61
|
-
@formatador.display_line(value)
|
62
173
|
when 'i', 'interactive', 'irb'
|
63
174
|
@formatador.display_line('Starting interactive session...')
|
64
175
|
if @irb.nil?
|
@@ -73,21 +184,23 @@ module Shindo
|
|
73
184
|
IRB.conf[:PROMPT][:SHINDO][key] = "#{@formatador.indentation}#{value}"
|
74
185
|
end
|
75
186
|
@irb.context.prompt_mode = :SHINDO
|
76
|
-
@irb.context.workspace = IRB::WorkSpace.new(
|
187
|
+
@irb.context.workspace = IRB::WorkSpace.new(@gestalt.bindings.last)
|
77
188
|
begin
|
78
189
|
@irb.eval_input
|
79
190
|
rescue SystemExit
|
80
191
|
end
|
81
192
|
when 'q', 'quit', 'exit'
|
82
|
-
|
83
|
-
|
193
|
+
@formatador.display_line("Exiting...")
|
194
|
+
@exit = true
|
84
195
|
when 'r', 'reload'
|
85
196
|
@formatador.display_line("Reloading...")
|
86
197
|
Thread.current[:reload] = true
|
87
|
-
Thread.exit
|
88
198
|
when 't', 'backtrace', 'trace'
|
89
|
-
|
90
|
-
|
199
|
+
if @gestalt.calls.empty?
|
200
|
+
@formatador.display_line("[red]No methods were called, so no backtrace was captured.[/]")
|
201
|
+
else
|
202
|
+
@gestalt.display_calls
|
203
|
+
end
|
91
204
|
when '?', 'help'
|
92
205
|
@formatador.display_lines([
|
93
206
|
'c - ignore this error and continue',
|
@@ -102,93 +215,15 @@ module Shindo
|
|
102
215
|
end
|
103
216
|
@formatador.display_line
|
104
217
|
end
|
105
|
-
@
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
def tests(description, tags = [], &block)
|
110
|
-
tags = [*tags]
|
111
|
-
@tag_stack.push(tags)
|
112
|
-
@befores.push([])
|
113
|
-
@afters.push([])
|
114
|
-
|
115
|
-
unless tags.empty?
|
116
|
-
taggings = " (#{tags.join(', ')})"
|
117
|
-
end
|
118
|
-
|
119
|
-
@formatador.display_line((description || 'Shindo.tests') << taggings.to_s)
|
120
|
-
if block_given?
|
121
|
-
@formatador.indent { instance_eval(&block) }
|
122
|
-
end
|
123
|
-
|
124
|
-
@afters.pop
|
125
|
-
@befores.pop
|
126
|
-
@tag_stack.pop
|
127
|
-
end
|
128
|
-
|
129
|
-
def test(description, tags = [], &block)
|
130
|
-
tags = [*tags]
|
131
|
-
@tag_stack.push(tags)
|
132
|
-
unless tags.empty?
|
133
|
-
taggings = " (#{tags.join(', ')})"
|
134
|
-
end
|
135
|
-
|
136
|
-
# if the test includes +tags and discludes -tags, evaluate it
|
137
|
-
if (@if_tagged.empty? || !(@if_tagged & @tag_stack.flatten).empty?) &&
|
138
|
-
(@unless_tagged.empty? || (@unless_tagged & @tag_stack.flatten).empty?)
|
139
|
-
if block_given?
|
140
|
-
begin
|
141
|
-
for before in @befores.flatten.compact
|
142
|
-
before.call
|
143
|
-
end
|
144
|
-
Thread.current[:success] = instance_eval(&block)
|
145
|
-
for after in @afters.flatten.compact
|
146
|
-
after.call
|
147
|
-
end
|
148
|
-
rescue => error
|
149
|
-
Thread.current[:success] = false
|
150
|
-
@formatador.display_line("[red]#{error.message} (#{error.class})[/]")
|
151
|
-
end
|
152
|
-
if Thread.current[:success]
|
153
|
-
@formatador.display_line("[green]+ #{description}#{taggings.to_s}[/]")
|
154
|
-
else
|
155
|
-
@formatador.display_line("[red]- #{description}#{taggings.to_s}[/]")
|
156
|
-
if STDOUT.tty?
|
157
|
-
prompt(description, &block)
|
158
|
-
end
|
159
|
-
end
|
160
|
-
else
|
161
|
-
@formatador.display_line("[yellow]* #{description}#{taggings.to_s}[/]")
|
162
|
-
end
|
163
|
-
else
|
164
|
-
@formatador.display_line("_ #{description}#{taggings.to_s}")
|
218
|
+
unless continue || @exit
|
219
|
+
@formatador.display_line("[red]- #{description}[/]")
|
220
|
+
prompt(description, &block)
|
165
221
|
end
|
166
|
-
|
167
|
-
@tag_stack.pop
|
168
222
|
end
|
169
223
|
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
if __FILE__ == $0
|
176
|
-
|
177
|
-
def bar(string, remaining = ['b','a','r'])
|
178
|
-
if remaining.empty?
|
179
|
-
string
|
180
|
-
else
|
181
|
-
bar(string << remaining.shift, remaining)
|
182
|
-
end
|
183
|
-
end
|
184
|
-
|
185
|
-
Shindo.tests do
|
186
|
-
|
187
|
-
test('failure') do
|
188
|
-
raise StandardError.new('exception')
|
189
|
-
@foo = ''
|
190
|
-
bar(@foo)
|
191
|
-
@foo == 'foo'
|
224
|
+
def success(description, &block)
|
225
|
+
Thread.current[:totals][:succeeded] += 1
|
226
|
+
@formatador.display_line("[green]+ #{description}[/]")
|
192
227
|
end
|
193
228
|
|
194
229
|
end
|
data/shindo.gemspec
CHANGED
@@ -13,21 +13,21 @@ Gem::Specification.new do |s|
|
|
13
13
|
## If your rubyforge_project name is different, then edit it and comment out
|
14
14
|
## the sub! line in the Rakefile
|
15
15
|
s.name = 'shindo'
|
16
|
-
s.version = '0.0
|
17
|
-
s.date = '2010-05-
|
16
|
+
s.version = '0.1.0'
|
17
|
+
s.date = '2010-05-21'
|
18
18
|
s.rubyforge_project = 'shindo'
|
19
19
|
|
20
20
|
## Make sure your summary is short. The description may be as long
|
21
21
|
## as you like.
|
22
|
-
s.summary = "Ruby testing."
|
23
|
-
s.description = "
|
22
|
+
s.summary = "Simple depth first Ruby testing."
|
23
|
+
s.description = "Work with your tests, not against them."
|
24
24
|
|
25
25
|
## List the primary authors. If there are a bunch of authors, it's probably
|
26
26
|
## better to set the email to an email list or something. If you don't have
|
27
27
|
## a custom homepage, consider using your GitHub URL or the like.
|
28
28
|
s.authors = ["geemus (Wesley Beary)"]
|
29
29
|
s.email = 'geemus@gmail.com'
|
30
|
-
s.homepage = 'http://github.com/geemus/
|
30
|
+
s.homepage = 'http://github.com/geemus/shindo'
|
31
31
|
|
32
32
|
## This gets added to the $LOAD_PATH so that 'lib/NAME.rb' can be required as
|
33
33
|
## require 'NAME.rb' or'/lib/NAME/file.rb' can be as require 'NAME/file.rb'
|
@@ -49,7 +49,7 @@ Gem::Specification.new do |s|
|
|
49
49
|
## List your runtime dependencies here. Runtime dependencies are those
|
50
50
|
## that are needed for an end user to actually USE your code.
|
51
51
|
s.add_dependency('formatador', '>=0.0.14')
|
52
|
-
s.add_dependency('gestalt', '>=0.0.
|
52
|
+
s.add_dependency('gestalt', '>=0.0.11')
|
53
53
|
|
54
54
|
## List your development dependencies here. Development dependencies are
|
55
55
|
## those that are only needed during development
|
@@ -69,6 +69,7 @@ Gem::Specification.new do |s|
|
|
69
69
|
lib/shindo/rake.rb
|
70
70
|
shindo.gemspec
|
71
71
|
tests/basic_tests.rb
|
72
|
+
tests/bin_tests.rb
|
72
73
|
tests/data/exception
|
73
74
|
tests/data/failure
|
74
75
|
tests/data/negative
|
data/tests/basic_tests.rb
CHANGED
@@ -1,27 +1,9 @@
|
|
1
1
|
Shindo.tests('basics') do
|
2
2
|
|
3
|
-
|
4
|
-
@output = bin(path('exception'))
|
5
|
-
test('output') { @output.include?('- exception') }
|
6
|
-
test('status') { $?.exitstatus == 1 }
|
7
|
-
end
|
3
|
+
returns(false) { false }
|
8
4
|
|
9
|
-
|
10
|
-
@output = bin(path('failure'))
|
11
|
-
test('output') { @output.include?('- failure') }
|
12
|
-
test('status') { $?.exitstatus == 1 }
|
13
|
-
end
|
5
|
+
raises(StandardError) { raise StandardError.new }
|
14
6
|
|
15
|
-
|
16
|
-
@output = bin(path('pending'))
|
17
|
-
test('output') { @output.include?('* pending') }
|
18
|
-
test('status') { $?.exitstatus == 0 }
|
19
|
-
end
|
20
|
-
|
21
|
-
tests('success') do
|
22
|
-
@output = bin(path('success'))
|
23
|
-
test('output') { @output.include?('+ success') }
|
24
|
-
test('status') { $?.exitstatus == 0 }
|
25
|
-
end
|
7
|
+
test('returns true') { true }
|
26
8
|
|
27
9
|
end
|
data/tests/bin_tests.rb
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
Shindo.tests('bin') do
|
2
|
+
|
3
|
+
tests('exception') do
|
4
|
+
@output = bin(path('exception'))
|
5
|
+
includes('- exception') { @output }
|
6
|
+
tests('$?.exitstatus').returns(1) { $?.exitstatus }
|
7
|
+
end
|
8
|
+
|
9
|
+
tests('failure') do
|
10
|
+
@output = bin(path('failure'))
|
11
|
+
includes('- failure') { @output }
|
12
|
+
tests('$?.exitstatus').returns(1) { $?.exitstatus }
|
13
|
+
end
|
14
|
+
|
15
|
+
tests('pending') do
|
16
|
+
@output = bin(path('pending'))
|
17
|
+
includes('# pending') { @output }
|
18
|
+
tests('$?.exitstatus').returns(0) { $?.exitstatus }
|
19
|
+
end
|
20
|
+
|
21
|
+
tests('success') do
|
22
|
+
@output = bin(path('success'))
|
23
|
+
includes('+ success') { @output }
|
24
|
+
tests('$?.exitstatus').returns(0) { $?.exitstatus }
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
data/tests/data/negative
CHANGED
data/tests/data/positive
CHANGED
data/tests/tag_tests.rb
CHANGED
@@ -1,17 +1,17 @@
|
|
1
|
-
Shindo.tests('
|
1
|
+
Shindo.tests('bin') do
|
2
2
|
|
3
|
-
tests(
|
3
|
+
tests("negative -negative") do
|
4
4
|
@output = bin("#{path('negative')} -negative")
|
5
|
-
|
6
|
-
|
7
|
-
|
5
|
+
includes('+ is tested') { @output }
|
6
|
+
includes('skipped (negative)') { @output }
|
7
|
+
tests('$?.exitstatus').returns(0) { $?.exitstatus }
|
8
8
|
end
|
9
9
|
|
10
|
-
tests(
|
10
|
+
tests("positive +positive") do
|
11
11
|
@output = bin("#{path('positive')} +positive")
|
12
|
-
|
13
|
-
|
14
|
-
|
12
|
+
includes('+ is tested') { @output }
|
13
|
+
includes('skipped') { @output }
|
14
|
+
tests('$?.exitstatus').returns(0) { $?.exitstatus }
|
15
15
|
end
|
16
16
|
|
17
17
|
end
|
data/tests/tests_helper.rb
CHANGED
@@ -9,3 +9,17 @@ end
|
|
9
9
|
def path(name)
|
10
10
|
File.join(File.dirname(__FILE__), 'data', name)
|
11
11
|
end
|
12
|
+
|
13
|
+
module Shindo
|
14
|
+
class Tests
|
15
|
+
|
16
|
+
def includes(expectation, description = "includes #{expectation.inspect}", &block)
|
17
|
+
test(description) do
|
18
|
+
value = instance_eval(&block)
|
19
|
+
@message = "expected #{value.inspect} to include #{expectation.inspect}"
|
20
|
+
value.include?(expectation)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
end
|
metadata
CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
|
|
4
4
|
prerelease: false
|
5
5
|
segments:
|
6
6
|
- 0
|
7
|
+
- 1
|
7
8
|
- 0
|
8
|
-
|
9
|
-
version: 0.0.18
|
9
|
+
version: 0.1.0
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- geemus (Wesley Beary)
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-05-
|
17
|
+
date: 2010-05-21 00:00:00 -07:00
|
18
18
|
default_executable: shindo
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
@@ -41,11 +41,11 @@ dependencies:
|
|
41
41
|
segments:
|
42
42
|
- 0
|
43
43
|
- 0
|
44
|
-
-
|
45
|
-
version: 0.0.
|
44
|
+
- 11
|
45
|
+
version: 0.0.11
|
46
46
|
type: :runtime
|
47
47
|
version_requirements: *id002
|
48
|
-
description:
|
48
|
+
description: Work with your tests, not against them.
|
49
49
|
email: geemus@gmail.com
|
50
50
|
executables:
|
51
51
|
- shindo
|
@@ -63,6 +63,7 @@ files:
|
|
63
63
|
- lib/shindo/rake.rb
|
64
64
|
- shindo.gemspec
|
65
65
|
- tests/basic_tests.rb
|
66
|
+
- tests/bin_tests.rb
|
66
67
|
- tests/data/exception
|
67
68
|
- tests/data/failure
|
68
69
|
- tests/data/negative
|
@@ -72,7 +73,7 @@ files:
|
|
72
73
|
- tests/tag_tests.rb
|
73
74
|
- tests/tests_helper.rb
|
74
75
|
has_rdoc: true
|
75
|
-
homepage: http://github.com/geemus/
|
76
|
+
homepage: http://github.com/geemus/shindo
|
76
77
|
licenses: []
|
77
78
|
|
78
79
|
post_install_message:
|
@@ -100,6 +101,6 @@ rubyforge_project: shindo
|
|
100
101
|
rubygems_version: 1.3.6
|
101
102
|
signing_key:
|
102
103
|
specification_version: 2
|
103
|
-
summary: Ruby testing.
|
104
|
+
summary: Simple depth first Ruby testing.
|
104
105
|
test_files: []
|
105
106
|
|