testrbl 0.1.4 → 0.1.5
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile.lock +1 -1
- data/lib/testrbl.rb +19 -5
- data/lib/testrbl/version.rb +1 -1
- data/spec/testrbl_spec.rb +65 -2
- metadata +4 -4
data/Gemfile.lock
CHANGED
data/lib/testrbl.rb
CHANGED
@@ -2,8 +2,9 @@ require 'testrbl/version'
|
|
2
2
|
|
3
3
|
module Testrbl
|
4
4
|
PATTERNS = [
|
5
|
-
/^(\s+)(
|
6
|
-
/^(\s+)
|
5
|
+
/^(\s+)(should|test)\s+['"](.*)['"]\s+do\s*$/,
|
6
|
+
/^(\s+)(context)\s+['"]?(.*?)['"]?\s+do\s*$/,
|
7
|
+
/^(\s+)def\s+(test_)([a-z_\d]+)\s*$/
|
7
8
|
]
|
8
9
|
|
9
10
|
def self.run_from_cli(argv)
|
@@ -32,8 +33,7 @@ module Testrbl
|
|
32
33
|
|
33
34
|
last_spaces = " " * 100
|
34
35
|
found = search.map{|line| pattern_from_line(line) }.compact
|
35
|
-
|
36
|
-
found.select! do |spaces, name|
|
36
|
+
found = found.select do |spaces, name|
|
37
37
|
last_spaces = spaces if spaces.size < last_spaces.size
|
38
38
|
end
|
39
39
|
|
@@ -44,7 +44,21 @@ module Testrbl
|
|
44
44
|
|
45
45
|
def self.pattern_from_line(line)
|
46
46
|
PATTERNS.each do |r|
|
47
|
-
|
47
|
+
if line =~ r
|
48
|
+
whitespace, method, test_name = $1, $2, $3
|
49
|
+
regex = Regexp.escape(test_name).gsub("'",".").gsub("\\ "," ")
|
50
|
+
|
51
|
+
if method == "should"
|
52
|
+
regex = "#{method} #{regex}\. $"
|
53
|
+
elsif method == "test"
|
54
|
+
regex = "^#{method}: #{regex}$"
|
55
|
+
end
|
56
|
+
|
57
|
+
return [
|
58
|
+
whitespace,
|
59
|
+
regex
|
60
|
+
]
|
61
|
+
end
|
48
62
|
end
|
49
63
|
nil
|
50
64
|
end
|
data/lib/testrbl/version.rb
CHANGED
data/spec/testrbl_spec.rb
CHANGED
@@ -91,9 +91,13 @@ describe Testrbl do
|
|
91
91
|
puts 'BCD'
|
92
92
|
end
|
93
93
|
|
94
|
-
test "c" do
|
94
|
+
test "c d" do
|
95
95
|
puts 'CDE'
|
96
96
|
end
|
97
|
+
|
98
|
+
test "c" do
|
99
|
+
puts 'DEF'
|
100
|
+
end
|
97
101
|
end
|
98
102
|
RUBY
|
99
103
|
end
|
@@ -104,6 +108,12 @@ describe Testrbl do
|
|
104
108
|
result.should include "BCD\n"
|
105
109
|
result.should_not include "CDE\n"
|
106
110
|
end
|
111
|
+
|
112
|
+
it "runs test explicitly" do
|
113
|
+
result = testrbl "a_test.rb:16"
|
114
|
+
result.should_not include "CDE\n"
|
115
|
+
result.should include "DEF\n"
|
116
|
+
end
|
107
117
|
end
|
108
118
|
|
109
119
|
context "shoulda" do
|
@@ -135,11 +145,15 @@ describe Testrbl do
|
|
135
145
|
end
|
136
146
|
end
|
137
147
|
|
138
|
-
context "g" do
|
148
|
+
context "g a" do
|
139
149
|
should "a" do
|
140
150
|
puts "FGH"
|
141
151
|
end
|
142
152
|
end
|
153
|
+
|
154
|
+
should "g" do
|
155
|
+
puts "GHI"
|
156
|
+
end
|
143
157
|
end
|
144
158
|
RUBY
|
145
159
|
end
|
@@ -171,6 +185,13 @@ describe Testrbl do
|
|
171
185
|
result.should_not include "EFG\n"
|
172
186
|
result.should include "FGH\n"
|
173
187
|
end
|
188
|
+
|
189
|
+
it "runs should explicitly" do
|
190
|
+
result = testrbl "a_test.rb:33"
|
191
|
+
result.should_not include "ABC\n"
|
192
|
+
result.should include "GHI\n"
|
193
|
+
result.should_not include "FGH\n"
|
194
|
+
end
|
174
195
|
end
|
175
196
|
|
176
197
|
context "multiple files / folders" do
|
@@ -239,4 +260,46 @@ describe Testrbl do
|
|
239
260
|
result.should include "DEF\n"
|
240
261
|
end
|
241
262
|
end
|
263
|
+
|
264
|
+
describe ".pattern_from_line" do
|
265
|
+
def call(line)
|
266
|
+
Testrbl.pattern_from_line(line)
|
267
|
+
end
|
268
|
+
|
269
|
+
it "finds simple tests" do
|
270
|
+
call(" def test_xxx\n").should == [" ", "xxx"]
|
271
|
+
end
|
272
|
+
|
273
|
+
it "does not find other methods" do
|
274
|
+
call(" def xxx\n").should == nil
|
275
|
+
end
|
276
|
+
|
277
|
+
it "finds calls with single quotes" do
|
278
|
+
call(" test 'xx xx' do\n").should == [" ", "^test: xx xx$"]
|
279
|
+
end
|
280
|
+
|
281
|
+
it "finds test do calls" do
|
282
|
+
call(" test \"xx xx\" do\n").should == [" ", "^test: xx xx$"]
|
283
|
+
end
|
284
|
+
|
285
|
+
it "finds should do calls" do
|
286
|
+
call(" should \"xx xx\" do\n").should == [" ", "should xx xx. $"]
|
287
|
+
end
|
288
|
+
|
289
|
+
it "finds context do calls" do
|
290
|
+
call(" context \"xx xx\" do\n").should == [" ", "xx xx"]
|
291
|
+
end
|
292
|
+
|
293
|
+
it "finds context do calls with classes" do
|
294
|
+
call(" context Foobar do\n").should == [" ", "Foobar"]
|
295
|
+
end
|
296
|
+
|
297
|
+
it "escapes regex chars" do
|
298
|
+
call(" context \"xx .* xx\" do\n").should == [" ", "xx \\.\\* xx"]
|
299
|
+
end
|
300
|
+
|
301
|
+
it "escapes single quotes which we use to build the pattern" do
|
302
|
+
call(" context \"xx ' xx\" do\n").should == [" ", "xx . xx"]
|
303
|
+
end
|
304
|
+
end
|
242
305
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: testrbl
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.5
|
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: 2012-06-
|
12
|
+
date: 2012-06-09 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description:
|
15
15
|
email: michael@grosser.it
|
@@ -44,7 +44,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
44
44
|
version: '0'
|
45
45
|
segments:
|
46
46
|
- 0
|
47
|
-
hash:
|
47
|
+
hash: 155105848634394199
|
48
48
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
49
49
|
none: false
|
50
50
|
requirements:
|
@@ -53,7 +53,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
53
53
|
version: '0'
|
54
54
|
segments:
|
55
55
|
- 0
|
56
|
-
hash:
|
56
|
+
hash: 155105848634394199
|
57
57
|
requirements: []
|
58
58
|
rubyforge_project:
|
59
59
|
rubygems_version: 1.8.24
|