testrbl 0.1.15 → 0.1.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- testrbl (0.1.15)
4
+ testrbl (0.1.16)
5
5
 
6
6
  GEM
7
7
  remote: http://rubygems.org/
data/Rakefile CHANGED
@@ -2,9 +2,9 @@ require 'bundler/setup'
2
2
  require 'bundler/gem_tasks'
3
3
 
4
4
  task :default do
5
- # tests do not run with test-unit 1.x.x since it defines testrb and overshadows 1.9s native testrb
5
+ # tests do not run with test-unit 1.x.x or <=2.3 since it defines testrb and overshadows 1.9s native testrb
6
6
  if `which testrb`.include?("/gems/")
7
- raise "tests do not run with test-unit 1.x.x installed\nyes | gem uninstall -a test-unit && bundle"
7
+ raise "tests do not run with test-unit testrb installed\nyes | gem uninstall -a test-unit && bundle"
8
8
  end
9
9
 
10
10
  sh "rspec spec/"
@@ -1,3 +1,3 @@
1
1
  module Testrbl
2
- VERSION = '0.1.15'
2
+ VERSION = '0.1.16'
3
3
  end
data/lib/testrbl.rb CHANGED
@@ -19,13 +19,15 @@ module Testrbl
19
19
  def self.run_from_cli(argv)
20
20
  i_test, file, line = detect_usable(argv)
21
21
  if file and line
22
- file = "./#{file}" if file =~ /^[a-z]/ # fix 1.9 not being able to load local files
22
+ file = localize(file)
23
23
  run "#{ruby} #{i_test}#{file} -n '/#{pattern_from_file(File.readlines(file), line)}/'"
24
24
  elsif file
25
25
  run "#{ruby} #{i_test}#{file}"
26
+ elsif argv.all?{|f| File.file?(f) }
27
+ run "#{ruby} #{argv.map{|f| "-r #{localize(f)}" }.join(" ")} -e ''"
26
28
  else # pass though
27
29
  # no bundle exec: projects with mini and unit-test do not run well via bundle exec testrb
28
- run "testrb #{argv.map{|a| a.include?(' ') ? "'#{a}'" : a }.join(' ')}"
30
+ run ["testrb"] + argv
29
31
  end
30
32
  end
31
33
 
@@ -55,6 +57,11 @@ module Testrbl
55
57
 
56
58
  private
57
59
 
60
+ # fix 1.9 not being able to load local files
61
+ def self.localize(file)
62
+ file =~ /^[-a-z\d_]/ ? "./#{file}" : file
63
+ end
64
+
58
65
  def self.detect_usable(argv)
59
66
  argv = argv.dup # do not mess up args
60
67
  i_test = "-Itest " if ((argv.delete("-I") and argv.delete("test")) or argv.delete("-Itest"))
@@ -77,9 +84,10 @@ module Testrbl
77
84
  end
78
85
 
79
86
  def self.run(command)
80
- puts command
87
+ command = [*command]
88
+ puts command.join(" ")
81
89
  STDOUT.flush # if exec fails horribly we at least see some output
82
- exec command
90
+ Kernel.exec *command
83
91
  end
84
92
 
85
93
  def self.pattern_from_line(line)
data/spec/testrbl_spec.rb CHANGED
@@ -368,6 +368,26 @@ describe Testrbl do
368
368
  result.should include "CDE\n"
369
369
  result.should include "DEF\n"
370
370
  end
371
+
372
+ context "avoiding testrb" do
373
+ before do
374
+ write "backtrace_test.rb", <<-RUBY
375
+ puts caller
376
+ RUBY
377
+ end
378
+
379
+ it "does not run via testrb if possible" do
380
+ result = testrbl "a/b/c_test.rb backtrace_test.rb"
381
+ result.should include("CDE")
382
+ result.should_not include("bin/testrb:")
383
+ end
384
+
385
+ it "runs via testrb if not possible via ruby" do
386
+ result = testrbl "a/b/c_test.rb backtrace_test.rb -v"
387
+ result.should include("CDE")
388
+ result.should include("bin/testrb:")
389
+ end
390
+ end
371
391
  end
372
392
 
373
393
  describe ".pattern_from_file" 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.15
4
+ version: 0.1.16
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-10-06 00:00:00.000000000 Z
12
+ date: 2012-10-23 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: 3074574819033279983
47
+ hash: 3813406408488973454
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: 3074574819033279983
56
+ hash: 3813406408488973454
57
57
  requirements: []
58
58
  rubyforge_project:
59
59
  rubygems_version: 1.8.24