testrbl 0.1.10 → 0.1.11
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile.lock +1 -1
- data/Readme.md +2 -1
- data/lib/testrbl/version.rb +1 -1
- data/lib/testrbl.rb +14 -6
- data/spec/testrbl_spec.rb +25 -0
- metadata +4 -4
data/Gemfile.lock
CHANGED
data/Readme.md
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
Run ruby Test::Unit/Shoulda/Minitest tests by line-number / folder / the dozen.<br/>
|
2
|
-
(everything not matching "file:line" is simply passed to testrb)
|
2
|
+
(everything not matching "file:line" is simply passed to testrb)<br/>
|
3
|
+
Instant execution, 0 wait-time!
|
3
4
|
|
4
5
|
Install
|
5
6
|
=======
|
data/lib/testrbl/version.rb
CHANGED
data/lib/testrbl.rb
CHANGED
@@ -21,7 +21,7 @@ module Testrbl
|
|
21
21
|
if command =~ /^\S+:\d+$/
|
22
22
|
file, line = argv.first.split(':')
|
23
23
|
file = "./#{file}" if file =~ /^[a-z]/ # fix 1.9 not being able to load local files
|
24
|
-
run "#{bundle_exec}ruby #{file} -n '/#{pattern_from_file(file, line)}/'"
|
24
|
+
run "#{bundle_exec}ruby #{file} -n '/#{pattern_from_file(File.readlines(file), line)}/'"
|
25
25
|
elsif File.file?(command)
|
26
26
|
run "#{bundle_exec}ruby #{command}"
|
27
27
|
else # pass though
|
@@ -41,17 +41,25 @@ module Testrbl
|
|
41
41
|
exec command
|
42
42
|
end
|
43
43
|
|
44
|
-
def self.pattern_from_file(
|
45
|
-
|
46
|
-
search = content[0..(line.to_i-1)].reverse
|
44
|
+
def self.pattern_from_file(lines, line)
|
45
|
+
search = lines[0..(line.to_i-1)].reverse
|
47
46
|
|
48
47
|
last_spaces = " " * 100
|
49
48
|
found = search.map{|line| pattern_from_line(line) }.compact
|
50
|
-
|
49
|
+
patterns = found.select do |spaces, name|
|
51
50
|
last_spaces = spaces if spaces.size < last_spaces.size
|
51
|
+
end.map(&:last)
|
52
|
+
|
53
|
+
use = []
|
54
|
+
found_final = false
|
55
|
+
patterns.each do |pattern|
|
56
|
+
is_final = pattern.end_with?("$")
|
57
|
+
next if is_final && found_final
|
58
|
+
found_final = is_final
|
59
|
+
use << pattern
|
52
60
|
end
|
53
61
|
|
54
|
-
return
|
62
|
+
return use.reverse.join(".*") if found.size > 0
|
55
63
|
|
56
64
|
raise "no test found before line #{line}"
|
57
65
|
end
|
data/spec/testrbl_spec.rb
CHANGED
@@ -331,6 +331,31 @@ describe Testrbl do
|
|
331
331
|
end
|
332
332
|
end
|
333
333
|
|
334
|
+
describe ".pattern_from_file" do
|
335
|
+
def call(content, line)
|
336
|
+
lines = content.split("\n").map{|l| l + "\n" }
|
337
|
+
Testrbl.pattern_from_file(lines, line)
|
338
|
+
end
|
339
|
+
|
340
|
+
after do
|
341
|
+
@result.should include("xxx")
|
342
|
+
@result.should_not include("yyy")
|
343
|
+
@result.should include("zzz")
|
344
|
+
end
|
345
|
+
|
346
|
+
it "does not find nested should calls" do
|
347
|
+
@result = call(" context \"xxx\" do\n test \"yyy\" do\n if true do\n test \"zzz\" do\n", 4)
|
348
|
+
end
|
349
|
+
|
350
|
+
it "does not find nested test calls" do
|
351
|
+
@result = call(" context \"xxx\" do\n test \"yyy\" do\n if true do\n test \"zzz\" do\n", 4)
|
352
|
+
end
|
353
|
+
|
354
|
+
it "does not find nested it calls" do
|
355
|
+
@result = call(" context \"xxx\" do\n it \"yyy\" do\n if true do\n it \"zzz\" do\n", 4)
|
356
|
+
end
|
357
|
+
end
|
358
|
+
|
334
359
|
describe ".pattern_from_line" do
|
335
360
|
def call(line)
|
336
361
|
Testrbl.pattern_from_line(line)
|
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.11
|
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-
|
12
|
+
date: 2012-07-14 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: -4483421695493014766
|
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: -4483421695493014766
|
57
57
|
requirements: []
|
58
58
|
rubyforge_project:
|
59
59
|
rubygems_version: 1.8.24
|