respec 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG CHANGED
@@ -1,3 +1,8 @@
1
+ == 0.0.2 2012-05-23
2
+
3
+ * Run through bundler if Gemfile is present.
4
+ * Don't run whole files specified when rerunning failures.
5
+
1
6
  == 0.0.1 2012-05-17
2
7
 
3
8
  * Hi.
data/lib/respec/app.rb CHANGED
@@ -9,16 +9,25 @@ module Respec
9
9
  @raw_args = []
10
10
  end
11
11
  @formatter = 'progress'
12
- @output_failures = true
12
+ @selected_failures = false
13
+ @update_failures = true
13
14
  process_args
14
15
  end
15
16
 
16
17
  def command
17
- @command ||= ['rspec'] + formatter_args + generated_args + raw_args
18
+ @command ||= bundler_args + ['rspec'] + formatter_args + generated_args + raw_args
19
+ end
20
+
21
+ def bundler_args
22
+ if File.exist?(ENV['BUNDLE_GEMFILE'] || 'Gemfile')
23
+ ['bundle', 'exec']
24
+ else
25
+ []
26
+ end
18
27
  end
19
28
 
20
29
  def formatter_args
21
- if @output_failures
30
+ if @update_failures
22
31
  formatter_path = File.expand_path('formatter.rb', File.dirname(__FILE__))
23
32
  ['--require', formatter_path, '--format', 'Respec::Formatter', '--out', failures_path, '--format', @formatter]
24
33
  else
@@ -78,6 +87,7 @@ module Respec
78
87
  failures.each do |line|
79
88
  args << line.strip
80
89
  end
90
+ @selected_failures = true
81
91
  end
82
92
  else
83
93
  warn "no fail file - ignoring 'f' argument"
@@ -90,7 +100,8 @@ module Respec
90
100
  i = Integer(arg)
91
101
  if (failure = failures[i - 1])
92
102
  args << failure
93
- @output_failures = false
103
+ @selected_failures = true
104
+ @update_failures = false
94
105
  else
95
106
  warn "invalid failure: #{i} for (1..#{failures.size})"
96
107
  end
@@ -98,7 +109,10 @@ module Respec
98
109
  args << '--example' << arg.gsub(/[$]/, '\\\\\\0')
99
110
  end
100
111
  end
101
- @generated_args = args + files
112
+ # If we selected individual failures to rerun, don't give the
113
+ # files to rspec, as those files will be run in entirety.
114
+ @generated_args = args
115
+ @generated_args.concat(files) unless @selected_failures
102
116
  end
103
117
 
104
118
  def failures_path
@@ -1,5 +1,5 @@
1
1
  module Respec
2
- VERSION = [0, 0, 1]
2
+ VERSION = [0, 0, 2]
3
3
 
4
4
  class << VERSION
5
5
  include Comparable
data/respec.gemspec CHANGED
@@ -13,5 +13,7 @@ Gem::Specification.new do |gem|
13
13
  gem.files = `git ls-files`.split("\n")
14
14
  gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
15
15
 
16
+ gem.add_runtime_dependency 'rspec', '>= 2.0.0'
16
17
  gem.add_development_dependency 'ritual', '~> 0.4.0'
18
+ gem.add_development_dependency 'temporaries', '~> 0.0.3'
17
19
  end
@@ -2,6 +2,8 @@ require_relative 'spec_helper'
2
2
  require 'rbconfig'
3
3
 
4
4
  describe Respec do
5
+ use_temporary_directory TMP
6
+
5
7
  CONFIG = (Object.const_defined?(:RbConfig) ? RbConfig : Config)::CONFIG
6
8
  def respec(args)
7
9
  ruby = File.join(CONFIG['bindir'], CONFIG['ruby_install_name'])
@@ -31,19 +33,21 @@ describe Respec do
31
33
  end
32
34
 
33
35
  it "should let you rerun failing specs until they all pass" do
34
- make_spec(num_failures: 2)
35
- status, output = respec(spec_path)
36
- status.should_not be_success
37
- output.should include('2 examples, 2 failures')
38
-
39
- make_spec(num_failures: 1)
40
- status, output = respec("#{spec_path} f")
41
- status.should_not be_success
42
- output.should include('2 examples, 1 failure')
43
-
44
- make_spec(num_failures: 0)
45
- status, output = respec("#{spec_path} f")
46
- status.should be_success
47
- output.should include('1 example, 0 failures')
36
+ Dir.chdir tmp do
37
+ make_spec(num_failures: 2)
38
+ status, output = respec(spec_path)
39
+ status.should_not be_success
40
+ output.should include('2 examples, 2 failures')
41
+
42
+ make_spec(num_failures: 1)
43
+ status, output = respec("#{spec_path} f")
44
+ status.should_not be_success
45
+ output.should include('2 examples, 1 failure')
46
+
47
+ make_spec(num_failures: 0)
48
+ status, output = respec("#{spec_path} f")
49
+ status.should be_success
50
+ output.should include('1 example, 0 failures')
51
+ end
48
52
  end
49
53
  end
@@ -3,6 +3,8 @@ require_relative '../spec_helper'
3
3
  require 'fileutils'
4
4
 
5
5
  describe Respec::App do
6
+ use_temporary_directory TMP
7
+
6
8
  FORMATTER_PATH = File.expand_path("#{ROOT}/lib/respec/formatter.rb", File.dirname(__FILE__))
7
9
  FAIL_PATH = "#{TMP}/failures.txt"
8
10
 
@@ -16,34 +18,34 @@ describe Respec::App do
16
18
  end
17
19
  end
18
20
 
19
- describe "#generated_args" do
20
- it "should run with --context if 'c' is given" do
21
- app = Respec::App.new('c')
22
- app.generated_args.should == ['--diff', 'context']
23
- end
24
-
25
- it "should run all failures if 'f' is given" do
26
- make_failures_file 'a.rb:1', 'b.rb:2'
27
- app = Respec::App.new('f')
28
- app.generated_args.should == ['a.rb:1', 'b.rb:2']
29
- end
30
-
31
- it "should run the n-th failure if a numeric argument 'n' is given" do
32
- make_failures_file 'a.rb:1', 'b.rb:2'
33
- app = Respec::App.new('2')
34
- app.generated_args.should == ['b.rb:2']
21
+ describe "#bundler_args" do
22
+ it "should run through bundler if a Gemfile is present" do
23
+ FileUtils.touch "#{tmp}/Gemfile"
24
+ Dir.chdir tmp do
25
+ app = Respec::App.new
26
+ app.bundler_args.should == ['bundle', 'exec']
27
+ end
35
28
  end
36
29
 
37
- it "should interpret existing file names as file name arguments" do
38
- FileUtils.touch "#{TMP}/existing.rb"
39
- app = Respec::App.new("#{TMP}/existing.rb")
40
- app.generated_args.should == ["#{TMP}/existing.rb"]
30
+ it "should check the BUNDLE_GEMFILE environment variable if set" do
31
+ original_bundle_gemfile = ENV['BUNDLE_GEMFILE']
32
+ ENV['BUNDLE_GEMFILE'] = "#{tmp}/custom_gemfile"
33
+ begin
34
+ FileUtils.touch "#{tmp}/custom_gemfile"
35
+ Dir.chdir tmp do
36
+ app = Respec::App.new
37
+ app.bundler_args.should == ['bundle', 'exec']
38
+ end
39
+ ensure
40
+ ENV['BUNDLE_GEMFILE'] = original_bundle_gemfile
41
+ end
41
42
  end
42
43
 
43
- it "should treat other arguments as example names" do
44
- FileUtils.touch "#{TMP}/FILE"
45
- app = Respec::App.new("#{TMP}/FILE")
46
- app.generated_args.should == ["#{TMP}/FILE"]
44
+ it "should not run through bundler if no Gemfile is present" do
45
+ Dir.chdir tmp do
46
+ app = Respec::App.new
47
+ app.bundler_args.should == []
48
+ end
47
49
  end
48
50
  end
49
51
 
@@ -64,16 +66,63 @@ describe Respec::App do
64
66
  end
65
67
 
66
68
  it "should update the stored failures if 'f' is used" do
69
+ make_failures_file 'a.rb:1'
67
70
  app = Respec::App.new('f')
68
71
  app.formatter_args.should == ['--require', FORMATTER_PATH, '--format', 'Respec::Formatter', '--out', FAIL_PATH, '--format', 'progress']
69
72
  end
70
73
 
71
74
  it "should not update the stored failures if a numeric argument is given" do
75
+ make_failures_file 'a.rb:1'
72
76
  app = Respec::App.new('1')
73
77
  app.formatter_args.should == []
74
78
  end
75
79
  end
76
80
 
81
+ describe "#generated_args" do
82
+ it "should run with --context if 'c' is given" do
83
+ app = Respec::App.new('c')
84
+ app.generated_args.should == ['--diff', 'context']
85
+ end
86
+
87
+ it "should run all failures if 'f' is given" do
88
+ make_failures_file 'a.rb:1', 'b.rb:2'
89
+ app = Respec::App.new('f')
90
+ app.generated_args.should == ['a.rb:1', 'b.rb:2']
91
+ end
92
+
93
+ it "should run the n-th failure if a numeric argument 'n' is given" do
94
+ make_failures_file 'a.rb:1', 'b.rb:2'
95
+ app = Respec::App.new('2')
96
+ app.generated_args.should == ['b.rb:2']
97
+ end
98
+
99
+ it "should interpret existing file names as file name arguments" do
100
+ FileUtils.touch "#{tmp}/existing.rb"
101
+ app = Respec::App.new("#{tmp}/existing.rb")
102
+ app.generated_args.should == ["#{tmp}/existing.rb"]
103
+ end
104
+
105
+ it "should treat other arguments as example names" do
106
+ FileUtils.touch "#{tmp}/FILE"
107
+ app = Respec::App.new("#{tmp}/FILE")
108
+ app.generated_args.should == ["#{tmp}/FILE"]
109
+ end
110
+
111
+ it "should not include named files if a numeric argument is given" do
112
+ FileUtils.touch "#{tmp}/FILE"
113
+ make_failures_file 'a.rb:1'
114
+ app = Respec::App.new("#{tmp}/FILE", '1')
115
+ app.generated_args.should == ['a.rb:1']
116
+ end
117
+
118
+ it "should not include named files if an 'f' argument is given" do
119
+ FileUtils.touch "#{tmp}/FILE"
120
+ make_failures_file 'a.rb:1'
121
+ app = Respec::App.new("#{tmp}/FILE", 'f')
122
+ app.generated_args.should == ['a.rb:1']
123
+ end
124
+ end
125
+
77
126
  describe "#raw_args" do
78
127
  it "should pass arguments after '--' directly to rspec" do
79
128
  app = Respec::App.new('--', '--blah')
@@ -83,9 +132,11 @@ describe Respec::App do
83
132
 
84
133
  describe "#command" do
85
134
  it "should combine all the args" do
86
- make_failures_file 'a.rb:1'
87
- app = Respec::App.new('f', '--', '-t', 'TAG')
88
- app.command.should == ['rspec', '--require', FORMATTER_PATH, '--format', 'Respec::Formatter', '--out', FAIL_PATH, '--format', 'progress', 'a.rb:1', '-t', 'TAG']
135
+ Dir.chdir tmp do
136
+ FileUtils.touch 'Gemfile'
137
+ app = Respec::App.new('c', '--', '-t', 'TAG')
138
+ app.command.should == ['bundle', 'exec', 'rspec', '--require', FORMATTER_PATH, '--format', 'Respec::Formatter', '--out', FAIL_PATH, '--format', 'progress', '--diff', 'context', '-t', 'TAG']
139
+ end
89
140
  end
90
141
  end
91
142
  end
data/spec/spec_helper.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  $:.unshift File.expand_path('../lib', File.dirname(__FILE__))
2
2
  require 'respec'
3
- require 'tmpdir'
3
+ require 'temporaries'
4
4
 
5
5
  ROOT = File.expand_path('..', File.dirname(__FILE__))
6
- TMP = Dir.tmpdir
6
+ TMP = "#{ROOT}/spec/tmp"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: respec
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,19 +9,56 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-05-17 00:00:00.000000000 Z
12
+ date: 2012-05-23 00:00:00.000000000 Z
13
13
  dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: rspec
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: 2.0.0
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: 2.0.0
14
30
  - !ruby/object:Gem::Dependency
15
31
  name: ritual
16
- requirement: &70131397136780 !ruby/object:Gem::Requirement
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ~>
36
+ - !ruby/object:Gem::Version
37
+ version: 0.4.0
38
+ type: :development
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
17
41
  none: false
18
42
  requirements:
19
43
  - - ~>
20
44
  - !ruby/object:Gem::Version
21
45
  version: 0.4.0
46
+ - !ruby/object:Gem::Dependency
47
+ name: temporaries
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ~>
52
+ - !ruby/object:Gem::Version
53
+ version: 0.0.3
22
54
  type: :development
23
55
  prerelease: false
24
- version_requirements: *70131397136780
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: 0.0.3
25
62
  description:
26
63
  email:
27
64
  - george.ogata@gmail.com
@@ -57,15 +94,21 @@ required_ruby_version: !ruby/object:Gem::Requirement
57
94
  - - ! '>='
58
95
  - !ruby/object:Gem::Version
59
96
  version: '0'
97
+ segments:
98
+ - 0
99
+ hash: -3838848027574177683
60
100
  required_rubygems_version: !ruby/object:Gem::Requirement
61
101
  none: false
62
102
  requirements:
63
103
  - - ! '>='
64
104
  - !ruby/object:Gem::Version
65
105
  version: '0'
106
+ segments:
107
+ - 0
108
+ hash: -3838848027574177683
66
109
  requirements: []
67
110
  rubyforge_project:
68
- rubygems_version: 1.8.10
111
+ rubygems_version: 1.8.24
69
112
  signing_key:
70
113
  specification_version: 3
71
114
  summary: Rerun failing RSpec examples easily.
@@ -73,4 +116,3 @@ test_files:
73
116
  - spec/integration_spec.rb
74
117
  - spec/respec/app_spec.rb
75
118
  - spec/spec_helper.rb
76
- has_rdoc: