testrbl 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile.lock +2 -2
- data/lib/testrbl/version.rb +1 -1
- data/lib/testrbl.rb +12 -15
- data/spec/testrbl_spec.rb +40 -9
- metadata +4 -4
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
testrbl (0.
|
4
|
+
testrbl (0.3.0)
|
5
5
|
|
6
6
|
GEM
|
7
7
|
remote: https://rubygems.org/
|
@@ -9,7 +9,7 @@ GEM
|
|
9
9
|
activesupport (2.3.14)
|
10
10
|
bump (0.3.3)
|
11
11
|
diff-lcs (1.1.3)
|
12
|
-
minitest (
|
12
|
+
minitest (5.0.3)
|
13
13
|
rake (0.9.2.2)
|
14
14
|
rspec (2.11.0)
|
15
15
|
rspec-core (~> 2.11.0)
|
data/lib/testrbl/version.rb
CHANGED
data/lib/testrbl.rb
CHANGED
@@ -3,19 +3,11 @@ require 'testrbl/version'
|
|
3
3
|
module Testrbl
|
4
4
|
PATTERNS = [
|
5
5
|
/^(\s+)(should|test|it)\s+['"](.*)['"]\s+do\s*(?:#.*)?$/,
|
6
|
-
/^(\s+)(context)\s+['"]?(.*?)['"]?\s+do\s*(?:#.*)?$/,
|
6
|
+
/^(\s+)(context|describe)\s+['"]?(.*?)['"]?\s+do\s*(?:#.*)?$/,
|
7
7
|
/^(\s+)def\s+(test_)([a-z_\d]+)\s*(?:#.*)?$/
|
8
8
|
]
|
9
9
|
|
10
10
|
OPTION_WITH_ARGUMENT = ["-I", "-r", "-n", "-e"]
|
11
|
-
|
12
|
-
# copied from minitest
|
13
|
-
MINITEST_NAME_RE = if RUBY_VERSION >= "1.9"
|
14
|
-
Regexp.new("[^[[:word:]]]+")
|
15
|
-
else
|
16
|
-
/\W+/u
|
17
|
-
end
|
18
|
-
|
19
11
|
INTERPOLATION = /\\\#\\\{.*?\\\}/
|
20
12
|
|
21
13
|
def self.run_from_cli(argv)
|
@@ -128,16 +120,21 @@ module Testrbl
|
|
128
120
|
def self.test_pattern_from_match(method, test_name)
|
129
121
|
regex = Regexp.escape(test_name).gsub("\\ "," ").gsub(INTERPOLATION, ".*")
|
130
122
|
|
131
|
-
|
123
|
+
regex = case method
|
124
|
+
when "should"
|
132
125
|
optional_test_name = "(?:\(.*\))?"
|
133
|
-
|
134
|
-
|
126
|
+
"#{method} #{regex}\. #{optional_test_name}$"
|
127
|
+
when "describe"
|
128
|
+
"#{test_name}(::)?"
|
129
|
+
when "test"
|
135
130
|
# test "xxx -_ yyy"
|
136
131
|
# test-unit: "test: xxx -_ yyy"
|
137
132
|
# activesupport: "test_xxx_-__yyy"
|
138
|
-
|
139
|
-
|
140
|
-
|
133
|
+
"^test(: |_)#{regex.gsub(" ", ".")}$"
|
134
|
+
when "it"
|
135
|
+
"#test_\\d+_#{test_name}$"
|
136
|
+
else
|
137
|
+
regex
|
141
138
|
end
|
142
139
|
|
143
140
|
regex.gsub("'", ".")
|
data/spec/testrbl_spec.rb
CHANGED
@@ -296,20 +296,51 @@ describe Testrbl do
|
|
296
296
|
|
297
297
|
describe "a-a" do
|
298
298
|
it "b./_-b" do
|
299
|
-
puts "ABC"
|
299
|
+
puts "-ABC-"
|
300
300
|
end
|
301
301
|
|
302
302
|
it "c-c" do
|
303
|
-
puts "BCD"
|
303
|
+
puts "-BCD-"
|
304
|
+
end
|
305
|
+
|
306
|
+
describe "a-b" do
|
307
|
+
it "d-d" do
|
308
|
+
puts "-CDE-"
|
309
|
+
end
|
310
|
+
|
311
|
+
it "d-e" do
|
312
|
+
puts "-DEF-"
|
313
|
+
end
|
314
|
+
end
|
315
|
+
end
|
316
|
+
|
317
|
+
describe "a-c" do
|
318
|
+
it "b./_-d" do
|
319
|
+
puts "-EFG-"
|
304
320
|
end
|
305
321
|
end
|
306
322
|
RUBY
|
307
323
|
end
|
308
324
|
|
325
|
+
def run_line(number)
|
326
|
+
result = testrbl "a_test.rb:#{number}"
|
327
|
+
result.scan(/-[A-Z]{3}-/).map { |s| s.gsub("-", "") }.sort
|
328
|
+
end
|
329
|
+
|
309
330
|
it "runs" do
|
310
|
-
|
311
|
-
|
312
|
-
|
331
|
+
run_line("4").should == ["ABC"]
|
332
|
+
end
|
333
|
+
|
334
|
+
it "runs describes" do
|
335
|
+
run_line("3").should == ["ABC", "BCD", "CDE", "DEF"]
|
336
|
+
end
|
337
|
+
|
338
|
+
it "runs nested describes" do
|
339
|
+
run_line("12").should == ["CDE", "DEF"]
|
340
|
+
end
|
341
|
+
|
342
|
+
it "runs nested it" do
|
343
|
+
run_line("13").should == ["CDE"]
|
313
344
|
end
|
314
345
|
end
|
315
346
|
|
@@ -488,15 +519,15 @@ describe Testrbl do
|
|
488
519
|
end
|
489
520
|
|
490
521
|
it "finds minitest it do calls" do
|
491
|
-
call(" it \"xx xx\" do\n").should == [" ", "
|
522
|
+
call(" it \"xx xx\" do\n").should == [" ", "#test_\\d+_xx xx$"]
|
492
523
|
end
|
493
524
|
|
494
525
|
it "finds complex minitest it do calls" do
|
495
|
-
call(" it \"xX ._-.. ___ Xx\" do\n").should == [" ", "
|
526
|
+
call(" it \"xX ._-.. ___ Xx\" do\n").should == [" ", "#test_\\d+_xX ._-.. ___ Xx$"]
|
496
527
|
end
|
497
528
|
|
498
|
-
it "
|
499
|
-
call(" describe Foobar do\n").should ==
|
529
|
+
it "finds minitest describe do calls" do
|
530
|
+
call(" describe Foobar do\n").should == [" ", "Foobar(::)?"]
|
500
531
|
end
|
501
532
|
|
502
533
|
it "escapes regex chars" do
|
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.
|
4
|
+
version: 0.3.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-
|
12
|
+
date: 2013-06-07 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: -4240182073636530469
|
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: -4240182073636530469
|
57
57
|
requirements: []
|
58
58
|
rubyforge_project:
|
59
59
|
rubygems_version: 1.8.25
|