respec 0.6.0 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG +4 -0
- data/README.markdown +11 -0
- data/lib/respec/app.rb +29 -16
- data/lib/respec/version.rb +1 -1
- data/spec/respec/app_spec.rb +22 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d53d945527eec47f8756eb05b37d6d4728b79814
|
4
|
+
data.tar.gz: 20d763a3e804d9d1562b3dfa7589cda2eb0238ea
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c10f7f2a4e072f67d0e692183c4f39678182cab17f97b823320335a70b58b64ccab93399d836a91abfe362d11332cc358c271c836f792e74d1bd4503064c5091
|
7
|
+
data.tar.gz: d5faf4f588bf784f1aad11cce08a743f7d8a1cadb77b0cb121bcaec5239be5a04e3bfc001c878e06b127dc8f5933e9b4298e0c5f364646e03757305e25169806
|
data/CHANGELOG
CHANGED
data/README.markdown
CHANGED
@@ -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)
|
data/lib/respec/app.rb
CHANGED
@@ -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 :
|
44
|
+
attr_accessor :default_failures_path
|
42
45
|
end
|
43
|
-
self.
|
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
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
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
|
-
|
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 =
|
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)
|
data/lib/respec/version.rb
CHANGED
data/spec/respec/app_spec.rb
CHANGED
@@ -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.
|
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
|
-
|
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.
|
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-
|
11
|
+
date: 2014-04-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|