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 CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- testrbl (0.2.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 (3.4.0)
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)
@@ -1,3 +1,3 @@
1
1
  module Testrbl
2
- VERSION = '0.2.0'
2
+ VERSION = '0.3.0'
3
3
  end
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
- if method == "should"
123
+ regex = case method
124
+ when "should"
132
125
  optional_test_name = "(?:\(.*\))?"
133
- regex = "#{method} #{regex}\. #{optional_test_name}$"
134
- elsif method == "test"
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
- regex = "^test(: |_)#{regex.gsub(" ", ".")}$"
139
- elsif method == "it"
140
- regex = "^test_\\d+_#{test_name}$"
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
- result = testrbl "a_test.rb:4"
311
- result.should include "ABC\n"
312
- result.should_not include "BCD"
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 == [" ", "^test_\\d+_xx xx$"]
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 == [" ", "^test_\\d+_xX ._-.. ___ Xx$"]
526
+ call(" it \"xX ._-.. ___ Xx\" do\n").should == [" ", "#test_\\d+_xX ._-.. ___ Xx$"]
496
527
  end
497
528
 
498
- it "does not find minitest describe do calls since we cannot run them" do
499
- call(" describe Foobar do\n").should == nil
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.2.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-03-09 00:00:00.000000000 Z
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: -866997392072142941
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: -866997392072142941
56
+ hash: -4240182073636530469
57
57
  requirements: []
58
58
  rubyforge_project:
59
59
  rubygems_version: 1.8.25