respec 0.8.3 → 0.9.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 +12 -4
- data/bin/respec +3 -0
- data/lib/respec/app.rb +24 -1
- data/lib/respec/version.rb +1 -1
- data/spec/respec/app_spec.rb +111 -0
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 396cc6c0d51083e279d493000adb0adb7fc79cca
|
4
|
+
data.tar.gz: c426e519c224bbd542f3889332e597726c3542b2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: baaa1afe7a1c8d61d079450347e5168ae95b6c2f22f9676d9237d27d1d38674f30c066a5889ddd9925c558a8719083a63eabe631dcd25de8df6f7a8f9dd11e52
|
7
|
+
data.tar.gz: 570fe25028bd088b82e5d5f2a7c5f62c9bdca953c33e91689233fe69c8c3478092dab9af3d25626844e2b7bee0f1af15ec93a827f8193f153a61e1f400fa3978
|
data/CHANGELOG
CHANGED
data/README.markdown
CHANGED
@@ -13,7 +13,7 @@ Run your specs:
|
|
13
13
|
|
14
14
|
respec f
|
15
15
|
|
16
|
-
Need to debug failure #1? Pop a `debugger` in your code, and rerun it
|
16
|
+
Need to debug failure #1? Pop a `debugger` (or `pry`) in your code, and rerun it
|
17
17
|
like this:
|
18
18
|
|
19
19
|
respec 1
|
@@ -50,12 +50,18 @@ example name.
|
|
50
50
|
|
51
51
|
It'll even `bundle exec` for you automatically, or use a binstub if present.
|
52
52
|
|
53
|
+
If you use git, run all specs modified since the last commit with:
|
54
|
+
|
55
|
+
respec d
|
56
|
+
|
57
|
+
(**d** for "git **d**iff", which this uses.)
|
58
|
+
|
53
59
|
There are a few other shortcuts. `respec --help` to see them all.
|
54
60
|
|
55
|
-
If you're using this on CI
|
56
|
-
written. You can do this in one of 2 ways:
|
61
|
+
If you're using this on CI to [rerun your failures][junit-merge], you may want
|
62
|
+
to control where the failure file is written. You can do this in one of 2 ways:
|
57
63
|
|
58
|
-
Either pass a FAILURES argument:
|
64
|
+
Either pass a `FAILURES=...` argument:
|
59
65
|
|
60
66
|
respec FAILURES=/path/to/file ...
|
61
67
|
|
@@ -63,6 +69,8 @@ Or use the `RESPEC_FAILURES` environment variable.
|
|
63
69
|
|
64
70
|
RESPEC_FAILURES=/path/to/file respec ...
|
65
71
|
|
72
|
+
[junit-merge]: https://github.com/oggy/junit_merge
|
73
|
+
|
66
74
|
## Contributing
|
67
75
|
|
68
76
|
* [Bug reports](https://github.com/oggy/respec/issues)
|
data/bin/respec
CHANGED
data/lib/respec/app.rb
CHANGED
@@ -12,11 +12,17 @@ module Respec
|
|
12
12
|
end
|
13
13
|
@failures_path = self.class.default_failures_path
|
14
14
|
@update_failures = true
|
15
|
+
@error = nil
|
15
16
|
process_args
|
16
17
|
end
|
17
18
|
|
18
19
|
attr_accessor :failures_path
|
19
20
|
|
21
|
+
def error
|
22
|
+
command
|
23
|
+
@error
|
24
|
+
end
|
25
|
+
|
20
26
|
def command
|
21
27
|
@command ||= program_args + generated_args + raw_args + formatter_args
|
22
28
|
end
|
@@ -58,6 +64,7 @@ module Respec
|
|
58
64
|
|
|
59
65
|
|RESPEC-ARGS may consist of:
|
60
66
|
|
|
67
|
+
| d Run all spec files changed since the last git commit
|
61
68
|
| f Rerun all failed examples
|
62
69
|
| <N> Rerun only the N-th failure
|
63
70
|
| <file name> Run all specs in this file
|
@@ -79,6 +86,7 @@ module Respec
|
|
79
86
|
files = []
|
80
87
|
pass_next_arg = false
|
81
88
|
using_filters = false
|
89
|
+
changed_only = false
|
82
90
|
@args.each do |arg|
|
83
91
|
if pass_next_arg
|
84
92
|
args << arg
|
@@ -94,6 +102,8 @@ module Respec
|
|
94
102
|
args << arg
|
95
103
|
elsif arg =~ /\AFAILURES=(.*)\z/
|
96
104
|
self.failures_path = $1
|
105
|
+
elsif arg == 'd'
|
106
|
+
changed_only = true
|
97
107
|
elsif arg == 'f'
|
98
108
|
# failures_path could still be overridden -- delay evaluation of this.
|
99
109
|
args << lambda do
|
@@ -117,7 +127,7 @@ module Respec
|
|
117
127
|
@update_failures = false
|
118
128
|
using_filters = true
|
119
129
|
else
|
120
|
-
|
130
|
+
@error = "invalid failure: #{i} for (1..#{failures.size})"
|
121
131
|
end
|
122
132
|
else
|
123
133
|
args << '-e' << arg.gsub(/[$]/, '\\\\\\0')
|
@@ -143,12 +153,25 @@ module Respec
|
|
143
153
|
# using 'spec' by default. Add it explicitly here.
|
144
154
|
files << 'spec' if files.empty?
|
145
155
|
|
156
|
+
# Filter files only to those changed if 'd' is present.
|
157
|
+
if changed_only
|
158
|
+
files = changed_paths(files)
|
159
|
+
end
|
160
|
+
|
146
161
|
# If we selected individual failures to rerun, don't give the files to
|
147
162
|
# rspec, as those files will be run in their entirety.
|
148
163
|
@generated_args = expanded
|
149
164
|
@generated_args.concat(files)
|
150
165
|
end
|
151
166
|
|
167
|
+
def changed_paths(paths)
|
168
|
+
changes = `git status --short --untracked-files=all #{paths.shelljoin}`
|
169
|
+
changes.lines.map do |line|
|
170
|
+
path = line[3..-1].chomp
|
171
|
+
path if File.exist?(path) && path =~ /\.rb\z/i
|
172
|
+
end.compact.uniq
|
173
|
+
end
|
174
|
+
|
152
175
|
def failures
|
153
176
|
@failures ||=
|
154
177
|
if File.exist?(failures_path)
|
data/lib/respec/version.rb
CHANGED
data/spec/respec/app_spec.rb
CHANGED
@@ -89,6 +89,47 @@ describe Respec::App do
|
|
89
89
|
end
|
90
90
|
|
91
91
|
describe "#generated_args" do
|
92
|
+
def in_git_repo
|
93
|
+
dir = "#{tmp}/repo"
|
94
|
+
FileUtils.mkdir_p dir
|
95
|
+
Dir.chdir(dir) do
|
96
|
+
system 'git init --quiet .'
|
97
|
+
yield
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
def make_git_file(path, index_status, status)
|
102
|
+
FileUtils.mkdir_p File.dirname(path)
|
103
|
+
|
104
|
+
unless index_status == nil || index_status == :new
|
105
|
+
open(path, 'w') { |f| f.print 1 }
|
106
|
+
system "git add #{path.shellescape}"
|
107
|
+
system "git commit --quiet --message . #{path.shellescape}"
|
108
|
+
end
|
109
|
+
|
110
|
+
case index_status
|
111
|
+
when :new, :updated
|
112
|
+
open(path, 'w') { |f| f.print 2 }
|
113
|
+
when :up_to_date, nil
|
114
|
+
when :removed
|
115
|
+
File.delete path
|
116
|
+
else
|
117
|
+
raise ArgumentError, "invalid index_status: #{index_status}"
|
118
|
+
end
|
119
|
+
|
120
|
+
system "git add -- #{path.shellescape}" unless index_status.nil?
|
121
|
+
|
122
|
+
case status
|
123
|
+
when :new, :updated
|
124
|
+
open(path, 'w') { |f| f.print 3 }
|
125
|
+
when :up_to_date
|
126
|
+
when :removed
|
127
|
+
File.delete path
|
128
|
+
else
|
129
|
+
raise ArgumentError, "invalid status: #{status}"
|
130
|
+
end
|
131
|
+
end
|
132
|
+
|
92
133
|
it "should pass all arguments that start with '-' to rspec" do
|
93
134
|
FileUtils.touch "#{tmp}/file"
|
94
135
|
app = Respec::App.new('-a', '-b', '-c', "#{tmp}/file")
|
@@ -106,6 +147,62 @@ describe Respec::App do
|
|
106
147
|
expect(app.generated_args).to eq ['-e', 'a', '-e', 'b', 'spec']
|
107
148
|
end
|
108
149
|
|
150
|
+
it "should run all new and updated files if 'd' is given" do
|
151
|
+
in_git_repo do
|
152
|
+
make_git_file 'a/01.rb', nil, :new
|
153
|
+
|
154
|
+
make_git_file 'a/02.rb', :new, :up_to_date
|
155
|
+
make_git_file 'a/03.rb', :new, :updated
|
156
|
+
make_git_file 'a/04.rb', :new, :removed
|
157
|
+
|
158
|
+
make_git_file 'a/05.rb', :up_to_date, :up_to_date
|
159
|
+
make_git_file 'a/06.rb', :up_to_date, :updated
|
160
|
+
make_git_file 'a/07.rb', :up_to_date, :removed
|
161
|
+
|
162
|
+
make_git_file 'a/08.rb', :updated, :up_to_date
|
163
|
+
make_git_file 'a/09.rb', :updated, :updated
|
164
|
+
make_git_file 'a/10.rb', :updated, :removed
|
165
|
+
|
166
|
+
make_git_file 'a/11.rb', :removed, :up_to_date
|
167
|
+
make_git_file 'a/12.rb', :removed, :new
|
168
|
+
|
169
|
+
app = Respec::App.new('d', 'a')
|
170
|
+
expect(app.generated_args).to \
|
171
|
+
contain_exactly(*[1, 2, 3, 6, 8, 9, 12].map { |i| 'a/%02d.rb' % i})
|
172
|
+
end
|
173
|
+
end
|
174
|
+
|
175
|
+
it "should only include .rb files for 'd'" do
|
176
|
+
in_git_repo do
|
177
|
+
make_git_file 'a/1.rb', :new, :up_to_date
|
178
|
+
make_git_file 'a/1.br', :new, :up_to_date
|
179
|
+
|
180
|
+
app = Respec::App.new('d', 'a')
|
181
|
+
expect(app.generated_args).to eq %w[a/1.rb]
|
182
|
+
end
|
183
|
+
end
|
184
|
+
|
185
|
+
it "should not include files outside the given spec directories for 'd'" do
|
186
|
+
in_git_repo do
|
187
|
+
make_git_file 'a/1.rb', :new, :up_to_date
|
188
|
+
make_git_file 'b/1.rb', :new, :up_to_date
|
189
|
+
make_git_file 'c/1.rb', :new, :up_to_date
|
190
|
+
|
191
|
+
app = Respec::App.new('d', 'a', 'b')
|
192
|
+
expect(app.generated_args).to eq %w[a/1.rb b/1.rb]
|
193
|
+
end
|
194
|
+
end
|
195
|
+
|
196
|
+
it "should filter files from the default spec directory for 'd'" do
|
197
|
+
in_git_repo do
|
198
|
+
make_git_file 'spec/1.rb', :new, :up_to_date
|
199
|
+
make_git_file 'other/1.rb', :new, :up_to_date
|
200
|
+
|
201
|
+
app = Respec::App.new('d')
|
202
|
+
expect(app.generated_args).to eq %w[spec/1.rb]
|
203
|
+
end
|
204
|
+
end
|
205
|
+
|
109
206
|
it "should pass failures with spaces in them as a single argument" do
|
110
207
|
make_failures_file 'a a'
|
111
208
|
app = Respec::App.new('f')
|
@@ -209,4 +306,18 @@ describe Respec::App do
|
|
209
306
|
end
|
210
307
|
end
|
211
308
|
end
|
309
|
+
|
310
|
+
describe "#error" do
|
311
|
+
it "should not be set if the arguments are valid" do
|
312
|
+
make_failures_file 'a'
|
313
|
+
app = Respec::App.new('1')
|
314
|
+
expect(app.error).to be_nil
|
315
|
+
end
|
316
|
+
|
317
|
+
it "should be set if an invalid failure is given" do
|
318
|
+
make_failures_file 'a', 'b'
|
319
|
+
app = Respec::App.new('3')
|
320
|
+
expect(app.error).to include 'invalid failure: 3 for (1..2)'
|
321
|
+
end
|
322
|
+
end
|
212
323
|
end
|
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.9.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: 2015-
|
11
|
+
date: 2015-10-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|
@@ -69,7 +69,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
69
69
|
version: '0'
|
70
70
|
requirements: []
|
71
71
|
rubyforge_project:
|
72
|
-
rubygems_version: 2.4.
|
72
|
+
rubygems_version: 2.4.8
|
73
73
|
signing_key:
|
74
74
|
specification_version: 4
|
75
75
|
summary: Rerun failing RSpec examples easily.
|