testrbl 0.1.12 → 0.1.13

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,29 +1,29 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- testrbl (0.1.12)
4
+ testrbl (0.1.13)
5
5
 
6
6
  GEM
7
7
  remote: http://rubygems.org/
8
8
  specs:
9
9
  activesupport (2.3.14)
10
10
  diff-lcs (1.1.3)
11
- minitest (3.0.1)
12
- rake (0.9.2)
13
- rspec (2.6.0)
14
- rspec-core (~> 2.6.0)
15
- rspec-expectations (~> 2.6.0)
16
- rspec-mocks (~> 2.6.0)
17
- rspec-core (2.6.4)
18
- rspec-expectations (2.6.0)
19
- diff-lcs (~> 1.1.2)
20
- rspec-mocks (2.6.0)
11
+ minitest (3.4.0)
12
+ rake (0.9.2.2)
13
+ rspec (2.11.0)
14
+ rspec-core (~> 2.11.0)
15
+ rspec-expectations (~> 2.11.0)
16
+ rspec-mocks (~> 2.11.0)
17
+ rspec-core (2.11.1)
18
+ rspec-expectations (2.11.3)
19
+ diff-lcs (~> 1.1.3)
20
+ rspec-mocks (2.11.2)
21
21
  shoulda (3.0.1)
22
22
  shoulda-context (~> 1.0.0)
23
23
  shoulda-matchers (~> 1.0.0)
24
24
  shoulda-context (1.0.0)
25
25
  shoulda-matchers (1.0.0)
26
- test-unit (2.4.8)
26
+ test-unit (2.5.2)
27
27
 
28
28
  PLATFORMS
29
29
  ruby
data/Rakefile CHANGED
@@ -1,6 +1,9 @@
1
1
  require 'bundler/gem_tasks'
2
2
 
3
3
  task :default do
4
+ # tests do not run with test-unit 1 since it defines testrb and overshadows 1.9s native testrb
5
+ raise "yes | gem uninstall -a test-unit && bundle" if `gem list test-unit | grep 'test-unit '` =~ /[\( ]1\./
6
+
4
7
  sh "rspec spec/"
5
8
  end
6
9
 
data/Readme.md CHANGED
@@ -18,6 +18,7 @@ Tips
18
18
 
19
19
  TODO
20
20
  ====
21
+ - fix tests on ree/1.9.2
21
22
  - alternate minitest syntax: test_0017_should not link already linked URLs
22
23
 
23
24
  Author
@@ -17,13 +17,12 @@ module Testrbl
17
17
  INTERPOLATION = /\\\#\\\{.*?\\\}/
18
18
 
19
19
  def self.run_from_cli(argv)
20
- command = argv.join(" ")
21
- if command =~ /^\S+:\d+$/
22
- file, line = argv.first.split(':')
20
+ i_test, file, line = detect_usable(argv)
21
+ if file and line
23
22
  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.readlines(file), line)}/'"
25
- elsif File.file?(command)
26
- run "#{bundle_exec}ruby #{command}"
23
+ run "#{bundle_exec}ruby #{i_test}#{file} -n '/#{pattern_from_file(File.readlines(file), line)}/'"
24
+ elsif file
25
+ run "#{bundle_exec}ruby #{i_test}#{file}"
27
26
  else # pass though
28
27
  # no bundle exec: projects with mini and unit-test do not run well via bundle exec testrb
29
28
  run "testrb #{argv.map{|a| a.include?(' ') ? "'#{a}'" : a }.join(' ')}"
@@ -56,12 +55,26 @@ module Testrbl
56
55
 
57
56
  private
58
57
 
58
+ def self.detect_usable(argv)
59
+ argv = argv.dup # do not mess up args
60
+ i_test = "-Itest " if ((argv.delete("-I") and argv.delete("test")) or argv.delete("-Itest"))
61
+
62
+ return unless argv.size == 1
63
+
64
+ if argv.first =~ /^(\S+):(\d+)$/
65
+ [i_test, $1, $2]
66
+ elsif File.file?(argv.first)
67
+ [i_test, argv.first, false]
68
+ end
69
+ end
70
+
59
71
  def self.bundle_exec
60
72
  "bundle exec " if File.file?("Gemfile")
61
73
  end
62
74
 
63
75
  def self.run(command)
64
76
  puts command
77
+ STDOUT.flush # if exec fails horribly we at least see some output
65
78
  exec command
66
79
  end
67
80
 
@@ -80,7 +93,7 @@ module Testrbl
80
93
  # activesupport: "test_xxx_-__yyy"
81
94
  regex = "^test(: |_)#{regex.gsub(" ", ".")}$"
82
95
  elsif method == "it"
83
- regex = "\\d+_#{test_name.gsub(MINITEST_NAME_RE, '_').downcase}$"
96
+ regex = "^test_\\d+_#{test_name}$"
84
97
  end
85
98
 
86
99
  return [
@@ -1,3 +1,3 @@
1
1
  module Testrbl
2
- VERSION = '0.1.12'
2
+ VERSION = '0.1.13'
3
3
  end
@@ -6,7 +6,7 @@ describe Testrbl do
6
6
  Dir.chdir "tmp" do
7
7
  example.call
8
8
  end
9
- run "rm -rf tmp"
9
+ #run "rm -rf tmp"
10
10
  end
11
11
 
12
12
  def run(cmd, options={})
@@ -33,6 +33,45 @@ describe Testrbl do
33
33
  Testrbl::VERSION.should =~ /^[\.\da-z]+$/
34
34
  end
35
35
 
36
+ context "-Itest" do
37
+ before do
38
+ write "a_test.rb", <<-RUBY
39
+ require 'test/unit'
40
+ require 'xxx'
41
+
42
+ class Xxx < Test::Unit::TestCase
43
+ def test_xxx
44
+ puts 'ABC'
45
+ end
46
+
47
+ def test_yyy
48
+ puts 'BCD'
49
+ end
50
+ end
51
+ RUBY
52
+ write("test/xxx.rb", "puts 'XXX LOADED'")
53
+ end
54
+
55
+ it "does not include test by default" do
56
+ result = testrbl "a_test.rb:6", :fail => true
57
+ result.should_not include "ABC\n"
58
+ end
59
+
60
+ it "can use -Itest for line execution" do
61
+ result = testrbl "-Itest a_test.rb:6"
62
+ result.should include "ABC\n"
63
+ result.should include "XXX LOADED\n"
64
+ result.should_not include "BCD"
65
+ end
66
+
67
+ it "can use -I test for line execution" do
68
+ result = testrbl "-I test a_test.rb:6"
69
+ result.should include "ABC\n"
70
+ result.should include "XXX LOADED\n"
71
+ result.should_not include "BCD"
72
+ end
73
+ end
74
+
36
75
  context "def test_" do
37
76
  before do
38
77
  write "a_test.rb", <<-RUBY
@@ -75,11 +114,11 @@ describe Testrbl do
75
114
  end
76
115
 
77
116
  it "runs with options" do
78
- pending "works in real console..." do
79
- result = testrbl "a_test.rb -n '/xxx/'"
80
- result.should include "ABC"
81
- result.should_not include "BCD"
82
- end
117
+ # TODO does not work with files in root folder ... WTF (only happens with a script that runs testrb)
118
+ write("foo/a_test.rb", read("a_test.rb"))
119
+ result = testrbl "foo/a_test.rb -n '/xxx/'"
120
+ result.should include "ABC"
121
+ result.should_not include "BCD"
83
122
  end
84
123
  end
85
124
 
@@ -245,12 +284,12 @@ describe Testrbl do
245
284
  write "a_test.rb", <<-RUBY
246
285
  require 'minitest/autorun'
247
286
 
248
- describe "a" do
249
- it "b" do
287
+ describe "a-a" do
288
+ it "b./_-b" do
250
289
  puts "ABC"
251
290
  end
252
291
 
253
- it "c" do
292
+ it "c-c" do
254
293
  puts "BCD"
255
294
  end
256
295
  end
@@ -406,11 +445,11 @@ describe Testrbl do
406
445
  end
407
446
 
408
447
  it "finds minitest it do calls" do
409
- call(" it \"xx xx\" do\n").should == [" ", "\\d+_xx_xx$"]
448
+ call(" it \"xx xx\" do\n").should == [" ", "^test_\\d+_xx xx$"]
410
449
  end
411
450
 
412
451
  it "finds complex minitest it do calls" do
413
- call(" it \"xx ._-.. ___ xx\" do\n").should == [" ", "\\d+_xx_______xx$"]
452
+ call(" it \"xX ._-.. ___ Xx\" do\n").should == [" ", "^test_\\d+_xX ._-.. ___ Xx$"]
414
453
  end
415
454
 
416
455
  it "does not find minitest describe do calls since we cannot run them" 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.1.12
4
+ version: 0.1.13
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-08-10 00:00:00.000000000 Z
12
+ date: 2012-09-16 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: 2301740719579311166
47
+ hash: 1427861218457478477
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: 2301740719579311166
56
+ hash: 1427861218457478477
57
57
  requirements: []
58
58
  rubyforge_project:
59
59
  rubygems_version: 1.8.24