testrbl 0.3.1 → 0.3.2

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.3.1)
4
+ testrbl (0.3.2)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
data/Readme.md CHANGED
@@ -11,6 +11,7 @@ Usage
11
11
  testrbl test/unit/xxx_test.rb:123 # test by line number
12
12
  testrbl test/unit # everything _test.rb in a folder (on 1.8 this would be test/unit/*)
13
13
  testrbl xxx_test.rb yyy_test.rb # multiple files
14
+ testrbl --changed # run changed tests
14
15
 
15
16
  Tips
16
17
  ====
@@ -1,3 +1,3 @@
1
1
  module Testrbl
2
- VERSION = '0.3.1'
2
+ VERSION = '0.3.2'
3
3
  end
data/lib/testrbl.rb CHANGED
@@ -12,6 +12,7 @@ module Testrbl
12
12
 
13
13
  def self.run_from_cli(argv)
14
14
  files, options = partition_argv(argv)
15
+ files.concat(changed_files) if options.delete("--changed")
15
16
  files = files.map { |f| localize(f) }
16
17
  load_options, options = partition_options(options)
17
18
 
@@ -96,6 +97,12 @@ module Testrbl
96
97
  end
97
98
  end
98
99
 
100
+ def self.changed_files
101
+ changed_files = `git status -s`.split("\n").map { |l| l.strip.split(/\s+/, 2)[1] }
102
+ raise "Failed: #{changed_files}" unless $?.success?
103
+ changed_files.select { |f| f =~ /_(test|spec)\.rb$/ && File.exist?(f) }
104
+ end
105
+
99
106
  def self.ruby
100
107
  if File.file?("Gemfile")
101
108
  ["ruby", "-rbundler/setup"] # faster then bundle exec ruby
data/spec/testrbl_spec.rb CHANGED
@@ -440,6 +440,55 @@ describe Testrbl do
440
440
  end
441
441
  end
442
442
 
443
+ context "--changed" do
444
+ before do
445
+ write "test/a_test.rb", "puts 'ABC'"
446
+ write "test/b_test.rb", "puts 'BCD'"
447
+ write "foo.rb", "raise 'BCD'"
448
+ run %{git init && git add -A && git commit -am 'initial'}
449
+ end
450
+
451
+ it "can run with other stuff" do
452
+ write "bar.rb", "puts 'CDE'"
453
+ result = testrbl("bar.rb --changed")
454
+ result.should include "CDE"
455
+ result.should_not include "ABC"
456
+ end
457
+
458
+ it "runs new files" do
459
+ write "test/b_test.rb", "puts 'CDE'"
460
+ write "test/c_test.rb", "puts 'DEF'"
461
+ result = testrbl("--changed")
462
+ result.should include "CDE"
463
+ result.should include "DEF"
464
+ result.should_not include "ABC"
465
+ result.should_not include "BCD"
466
+ end
467
+
468
+ it "runs changed files" do
469
+ write "test/b_test.rb", "puts 'BCD' # changed"
470
+ result = testrbl("--changed")
471
+ result.should include "BCD"
472
+ result.should_not include "ABC"
473
+ end
474
+
475
+ it "runs staged files" do
476
+ write "test/b_test.rb", "puts 'BCD' # changed"
477
+ run "git add test/b_test.rb"
478
+ result = testrbl("--changed")
479
+ result.should include "BCD"
480
+ result.should_not include "ABC"
481
+ end
482
+
483
+ it "does not run removed files" do
484
+ run "rm test/b_test.rb"
485
+ write "test/c_test.rb", "puts 'DEF'"
486
+ result = testrbl("--changed")
487
+ result.should include "DEF"
488
+ result.should_not include "ABC"
489
+ end
490
+ end
491
+
443
492
  describe ".test_pattern_from_file" do
444
493
  def call(content, line)
445
494
  lines = content.split("\n").map{|l| l + "\n" }
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.3.1
4
+ version: 0.3.2
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-06-23 00:00:00.000000000 Z
12
+ date: 2013-06-30 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: 1847987881023274849
47
+ hash: -3635273838218329948
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: 1847987881023274849
56
+ hash: -3635273838218329948
57
57
  requirements: []
58
58
  rubyforge_project:
59
59
  rubygems_version: 1.8.25