respec 0.6.0 → 0.7.0

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b8e7b7909c9c2f972ba87f26dc8442075b448c19
4
- data.tar.gz: 8bf9c7ccb004cdbb8428ef45795aa2ba66299af2
3
+ metadata.gz: d53d945527eec47f8756eb05b37d6d4728b79814
4
+ data.tar.gz: 20d763a3e804d9d1562b3dfa7589cda2eb0238ea
5
5
  SHA512:
6
- metadata.gz: 611e4c52b16c9e203b3be7eb89baf0e35fdb73378a4236c9b3e9c52b1fbdaaa967c9d11955154879923c40ff52a4929d830e541b8895366ab8d036b5ac506330
7
- data.tar.gz: 4fd3271dde886c2fd84324a472fc3cded2c9a1da5c6b4c0cc572cc77f26982c837e3562cad9f6fba9ddfaec16addbad48dfce9291d218f4bce21b3502ed86df6
6
+ metadata.gz: c10f7f2a4e072f67d0e692183c4f39678182cab17f97b823320335a70b58b64ccab93399d836a91abfe362d11332cc358c271c836f792e74d1bd4503064c5091
7
+ data.tar.gz: d5faf4f588bf784f1aad11cce08a743f7d8a1cadb77b0cb121bcaec5239be5a04e3bfc001c878e06b127dc8f5933e9b4298e0c5f364646e03757305e25169806
data/CHANGELOG CHANGED
@@ -1,3 +1,7 @@
1
+ == 0.7.0 2014-04-16
2
+
3
+ * Allow setting failure file via argument. Useful under CI with parallel_tests.
4
+
1
5
  == 0.6.0 2014-04-09
2
6
 
3
7
  * Exit with status 0 if there are no failures left to retry. Useful under CI.
@@ -52,6 +52,17 @@ It'll even `bundle exec` for you automatically.
52
52
 
53
53
  There are a few other shortcuts. `respec --help` to see them all.
54
54
 
55
+ If you're using this on CI, you may want to control where the failure file is
56
+ written. You can do this in one of 2 ways:
57
+
58
+ Either pass a FAILURES argument:
59
+
60
+ respec FAILURES=/path/to/file ...
61
+
62
+ Or use the `RESPEC_FAILURES` environment variable.
63
+
64
+ RESPEC_FAILURES=/path/to/file respec ...
65
+
55
66
  ## Contributing
56
67
 
57
68
  * [Bug reports](https://github.com/oggy/respec/issues)
@@ -10,11 +10,14 @@ module Respec
10
10
  @args = args
11
11
  @raw_args = []
12
12
  end
13
+ @failures_path = self.class.default_failures_path
13
14
  @selected_failures = false
14
15
  @update_failures = true
15
16
  process_args
16
17
  end
17
18
 
19
+ attr_accessor :failures_path
20
+
18
21
  def command
19
22
  @command ||= bundler_args + ['rspec'] + generated_args + raw_args + formatter_args
20
23
  end
@@ -38,9 +41,9 @@ module Respec
38
41
  end
39
42
 
40
43
  class << self
41
- attr_accessor :failures_path
44
+ attr_accessor :default_failures_path
42
45
  end
43
- self.failures_path = ENV['RESPEC_FAILURES'] || File.expand_path(".respec_failures")
46
+ self.default_failures_path = ENV['RESPEC_FAILURES'] || File.expand_path(".respec_failures")
44
47
 
45
48
  def help_only?
46
49
  @help_only
@@ -87,18 +90,23 @@ module Respec
87
90
  @help_only = true
88
91
  elsif arg =~ /\A-/
89
92
  args << arg
93
+ elsif arg =~ /\AFAILURES=(.*)\z/
94
+ self.failures_path = $1
90
95
  elsif arg == 'f'
91
- if File.exist?(failures_path)
92
- if failures.empty?
93
- STDERR.puts "No specs failed!"
94
- else
95
- failures.each do |line|
96
- args << line.strip
96
+ # failures_path could still be overridden -- delay evaluation of this.
97
+ args << lambda do
98
+ if File.exist?(failures_path)
99
+ if failures.empty?
100
+ STDERR.puts "No specs failed!"
101
+ []
102
+ else
103
+ @selected_failures = true
104
+ failures
97
105
  end
98
- @selected_failures = true
106
+ else
107
+ warn "no fail file - ignoring 'f' argument"
108
+ []
99
109
  end
100
- else
101
- warn "no fail file - ignoring 'f' argument"
102
110
  end
103
111
  elsif arg =~ /\A\d+\z/
104
112
  i = Integer(arg)
@@ -114,20 +122,25 @@ module Respec
114
122
  end
115
123
  end
116
124
 
125
+ expanded = []
126
+ args.each do |arg|
127
+ if arg.respond_to?(:call)
128
+ expanded.concat(arg.call)
129
+ else
130
+ expanded << arg
131
+ end
132
+ end
133
+
117
134
  # Since we append our formatter as a file to run, rspec won't fall back to
118
135
  # using 'spec' by default. Add it explicitly here.
119
136
  files << 'spec' if files.empty?
120
137
 
121
138
  # If we selected individual failures to rerun, don't give the files to
122
139
  # rspec, as those files will be run in their entirety.
123
- @generated_args = args
140
+ @generated_args = expanded
124
141
  @generated_args.concat(files) unless @selected_failures
125
142
  end
126
143
 
127
- def failures_path
128
- self.class.failures_path
129
- end
130
-
131
144
  def failures
132
145
  @failures ||=
133
146
  if File.exist?(failures_path)
@@ -1,5 +1,5 @@
1
1
  module Respec
2
- VERSION = [0, 6, 0]
2
+ VERSION = [0, 7, 0]
3
3
 
4
4
  class << VERSION
5
5
  include Comparable
@@ -7,20 +7,34 @@ describe Respec::App do
7
7
  FORMATTER_PATH = File.expand_path("#{ROOT}/lib/respec/formatter.rb", File.dirname(__FILE__))
8
8
  FAIL_PATH = "#{TMP}/failures.txt"
9
9
 
10
- Respec::App.failures_path = FAIL_PATH
10
+ Respec::App.default_failures_path = FAIL_PATH
11
11
 
12
12
  def write_file(path, content)
13
13
  open(path, 'w') { |f| f.print content }
14
14
  end
15
15
 
16
16
  def make_failures_file(*examples)
17
- open Respec::App.failures_path, 'w' do |file|
17
+ options = examples.last.is_a?(Hash) ? examples.pop : {}
18
+ path = options[:path] || Respec::App.default_failures_path
19
+ open path, 'w' do |file|
18
20
  examples.each do |example|
19
21
  file.puts example
20
22
  end
21
23
  end
22
24
  end
23
25
 
26
+ describe "#failures_path" do
27
+ it "defaults to the global default" do
28
+ app = Respec::App.new
29
+ expect(app.failures_path).to eq FAIL_PATH
30
+ end
31
+
32
+ it "can be overridden with a FAILURES= argument" do
33
+ app = Respec::App.new('FAILURES=overridden.txt')
34
+ expect(app.failures_path).to eq 'overridden.txt'
35
+ end
36
+ end
37
+
24
38
  describe "#bundler_args" do
25
39
  it "should run through bundler if a Gemfile is present" do
26
40
  FileUtils.touch "#{tmp}/Gemfile"
@@ -87,6 +101,12 @@ describe Respec::App do
87
101
  expect(app.generated_args).to eq ['a.rb:1', 'b.rb:2']
88
102
  end
89
103
 
104
+ it "should find the right failures if the failures file is overridden after the 'f'" do
105
+ make_failures_file 'a.rb:1', 'b.rb:2', path: "#{FAIL_PATH}-overridden"
106
+ app = Respec::App.new('f', "FAILURES=#{FAIL_PATH}-overridden")
107
+ expect(app.generated_args).to eq ['a.rb:1', 'b.rb:2']
108
+ end
109
+
90
110
  it "should run the n-th failure if a numeric argument 'n' is given" do
91
111
  make_failures_file 'a.rb:1', 'b.rb:2'
92
112
  app = Respec::App.new('2')
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: respec
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - George Ogata
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-04-09 00:00:00.000000000 Z
11
+ date: 2014-04-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec