respec 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +6 -0
- data/lib/respec/app.rb +33 -17
- data/lib/respec/version.rb +1 -1
- data/spec/respec/app_spec.rb +67 -9
- metadata +4 -4
data/CHANGELOG
CHANGED
@@ -1,3 +1,9 @@
|
|
1
|
+
== 0.3.0 2012-11-11
|
2
|
+
|
3
|
+
* Don't add progress formatter when user has selected something else.
|
4
|
+
* Remove 's' option. Use "-f s" instead, or an .rspec file instead.
|
5
|
+
* Pass argument to deprecated --formatter option to rspec.
|
6
|
+
|
1
7
|
== 0.2.0 2012-10-31
|
2
8
|
|
3
9
|
* Support rspec options that require an argument.
|
data/lib/respec/app.rb
CHANGED
@@ -10,14 +10,13 @@ module Respec
|
|
10
10
|
@args = args
|
11
11
|
@raw_args = []
|
12
12
|
end
|
13
|
-
@formatter = 'progress'
|
14
13
|
@selected_failures = false
|
15
14
|
@update_failures = true
|
16
15
|
process_args
|
17
16
|
end
|
18
17
|
|
19
18
|
def command
|
20
|
-
@command ||= bundler_args + ['rspec'] + formatter_args + generated_args + raw_args
|
19
|
+
@command ||= bundler_args + ['rspec'] + formatter_args + default_formatter_args + generated_args + raw_args
|
21
20
|
end
|
22
21
|
|
23
22
|
def bundler_args
|
@@ -31,18 +30,31 @@ module Respec
|
|
31
30
|
def formatter_args
|
32
31
|
if @update_failures
|
33
32
|
formatter_path = File.expand_path('formatter.rb', File.dirname(__FILE__))
|
34
|
-
['--require', formatter_path, '--format', 'Respec::Formatter', '--out', failures_path
|
33
|
+
['--require', formatter_path, '--format', 'Respec::Formatter', '--out', failures_path]
|
35
34
|
else
|
36
35
|
[]
|
37
36
|
end
|
38
37
|
end
|
39
38
|
|
39
|
+
def default_formatter_args
|
40
|
+
args = @generated_args + @raw_args + dotfile_args
|
41
|
+
if args.include?('-f') || args.include?('--format') || args.include?('--formatter')
|
42
|
+
[]
|
43
|
+
else
|
44
|
+
['--format', 'progress']
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
40
48
|
attr_reader :generated_args, :raw_args
|
41
49
|
|
42
50
|
class << self
|
43
51
|
attr_accessor :failures_path
|
52
|
+
attr_accessor :local_rspec_config_path
|
53
|
+
attr_accessor :global_rspec_config_path
|
44
54
|
end
|
45
55
|
self.failures_path = ENV['RESPEC_FAILURES'] || File.expand_path(".respec_failures")
|
56
|
+
self.local_rspec_config_path = '.rspec'
|
57
|
+
self.global_rspec_config_path = File.expand_path('~/.rspec')
|
46
58
|
|
47
59
|
def help_only?
|
48
60
|
@help_only
|
@@ -52,19 +64,19 @@ module Respec
|
|
52
64
|
<<-EOS.gsub(/^ *\|/, '')
|
53
65
|
|USAGE: respec RESPEC-ARGS ... [ -- RSPEC-ARGS ... ]
|
54
66
|
|
|
55
|
-
|Run rspec recording failed examples for easy rerunning later.
|
67
|
+
|Run rspec, recording failed examples for easy rerunning later.
|
56
68
|
|
|
57
69
|
|RESPEC-ARGS may consist of:
|
58
70
|
|
|
59
|
-
| f
|
60
|
-
| <
|
61
|
-
| <file name>
|
62
|
-
| <
|
63
|
-
|
|
64
|
-
| -<anything>
|
71
|
+
| f Rerun all failed examples
|
72
|
+
| <N> Rerun only the N-th failure
|
73
|
+
| <file name> Run all specs in this file
|
74
|
+
| <file name:N> Run specs at line N in this file
|
75
|
+
| <other> Run only examples matching this pattern
|
76
|
+
| -<anything> Passed directly to rspec.
|
77
|
+
| --help This! (Also 'help'.)
|
65
78
|
|
|
66
|
-
|
|
67
|
-
|directly to rspec.
|
79
|
+
|Any arguments following a '--' argument are passed directly to rspec.
|
68
80
|
|
|
69
81
|
|More info: http://github.com/oggy/respec
|
70
82
|
EOS
|
@@ -102,8 +114,6 @@ module Respec
|
|
102
114
|
else
|
103
115
|
warn "no fail file - ignoring 'f' argument"
|
104
116
|
end
|
105
|
-
elsif arg == 's'
|
106
|
-
@formatter = 'specdoc'
|
107
117
|
elsif arg =~ /\A\d+\z/
|
108
118
|
i = Integer(arg)
|
109
119
|
if (failure = failures[i - 1])
|
@@ -117,12 +127,18 @@ module Respec
|
|
117
127
|
args << '--example' << arg.gsub(/[$]/, '\\\\\\0')
|
118
128
|
end
|
119
129
|
end
|
120
|
-
# If we selected individual failures to rerun, don't give the
|
121
|
-
#
|
130
|
+
# If we selected individual failures to rerun, don't give the files to
|
131
|
+
# rspec, as those files will be run in their entirety.
|
122
132
|
@generated_args = args
|
123
133
|
@generated_args.concat(files) unless @selected_failures
|
124
134
|
end
|
125
135
|
|
136
|
+
def dotfile_args
|
137
|
+
[self.class.local_rspec_config_path, self.class.global_rspec_config_path].map do |path|
|
138
|
+
File.exist?(path) ? File.read(path) : ''
|
139
|
+
end.join(' ').split
|
140
|
+
end
|
141
|
+
|
126
142
|
def failures_path
|
127
143
|
self.class.failures_path
|
128
144
|
end
|
@@ -148,7 +164,7 @@ module Respec
|
|
148
164
|
--seed
|
149
165
|
--failure-exit-code
|
150
166
|
--drb-port
|
151
|
-
-f --format
|
167
|
+
-f --format --formatter
|
152
168
|
-o --out
|
153
169
|
-P --pattern
|
154
170
|
-e --example
|
data/lib/respec/version.rb
CHANGED
data/spec/respec/app_spec.rb
CHANGED
@@ -8,6 +8,12 @@ describe Respec::App do
|
|
8
8
|
FAIL_PATH = "#{TMP}/failures.txt"
|
9
9
|
|
10
10
|
Respec::App.failures_path = FAIL_PATH
|
11
|
+
Respec::App.local_rspec_config_path = "#{TMP}/local.rspec"
|
12
|
+
Respec::App.global_rspec_config_path = "#{TMP}/global.rspec"
|
13
|
+
|
14
|
+
def write_file(path, content)
|
15
|
+
open(path, 'w') { |f| f.print content }
|
16
|
+
end
|
11
17
|
|
12
18
|
def make_failures_file(*examples)
|
13
19
|
open Respec::App.failures_path, 'w' do |file|
|
@@ -47,25 +53,20 @@ describe Respec::App do
|
|
47
53
|
end
|
48
54
|
|
49
55
|
describe "#formatter_args" do
|
50
|
-
it "should include the respec
|
56
|
+
it "should include the respec formatters" do
|
51
57
|
app = Respec::App.new
|
52
|
-
app.formatter_args.should == ['--require', FORMATTER_PATH, '--format', 'Respec::Formatter', '--out', FAIL_PATH
|
53
|
-
end
|
54
|
-
|
55
|
-
it "should include '--format specdoc' if an 's' argument is given" do
|
56
|
-
app = Respec::App.new('s')
|
57
|
-
app.formatter_args.should == ['--require', FORMATTER_PATH, '--format', 'Respec::Formatter', '--out', FAIL_PATH, '--format', 'specdoc']
|
58
|
+
app.formatter_args.should == ['--require', FORMATTER_PATH, '--format', 'Respec::Formatter', '--out', FAIL_PATH]
|
58
59
|
end
|
59
60
|
|
60
61
|
it "should update the stored failures if no args are given" do
|
61
62
|
app = Respec::App.new
|
62
|
-
app.formatter_args.should == ['--require', FORMATTER_PATH, '--format', 'Respec::Formatter', '--out', FAIL_PATH
|
63
|
+
app.formatter_args.should == ['--require', FORMATTER_PATH, '--format', 'Respec::Formatter', '--out', FAIL_PATH]
|
63
64
|
end
|
64
65
|
|
65
66
|
it "should update the stored failures if 'f' is used" do
|
66
67
|
make_failures_file 'a.rb:1'
|
67
68
|
app = Respec::App.new('f')
|
68
|
-
app.formatter_args.should == ['--require', FORMATTER_PATH, '--format', 'Respec::Formatter', '--out', FAIL_PATH
|
69
|
+
app.formatter_args.should == ['--require', FORMATTER_PATH, '--format', 'Respec::Formatter', '--out', FAIL_PATH]
|
69
70
|
end
|
70
71
|
|
71
72
|
it "should not update the stored failures if a numeric argument is given" do
|
@@ -75,6 +76,63 @@ describe Respec::App do
|
|
75
76
|
end
|
76
77
|
end
|
77
78
|
|
79
|
+
describe "#default_formatter_args" do
|
80
|
+
it "should be empty if a formatter arg was given in the respec args" do
|
81
|
+
app = Respec::App.new('-f', 'specdoc')
|
82
|
+
app.default_formatter_args.should == []
|
83
|
+
|
84
|
+
app = Respec::App.new('--format', 'specdoc')
|
85
|
+
app.default_formatter_args.should == []
|
86
|
+
|
87
|
+
app = Respec::App.new('--formatter', 'specdoc')
|
88
|
+
app.default_formatter_args.should == []
|
89
|
+
end
|
90
|
+
|
91
|
+
it "should be empty if a formatter arg was given in the raw args" do
|
92
|
+
app = Respec::App.new('--', '-f', 'specdoc')
|
93
|
+
app.default_formatter_args.should == []
|
94
|
+
|
95
|
+
app = Respec::App.new('--', '--format', 'specdoc')
|
96
|
+
app.default_formatter_args.should == []
|
97
|
+
|
98
|
+
app = Respec::App.new('--', '--formatter', 'specdoc')
|
99
|
+
app.default_formatter_args.should == []
|
100
|
+
end
|
101
|
+
|
102
|
+
it "should be empty if a formatter arg is in the local .rspec" do
|
103
|
+
write_file "#{TMP}/local.rspec", '-f specdoc'
|
104
|
+
app = Respec::App.new
|
105
|
+
app.default_formatter_args.should == []
|
106
|
+
|
107
|
+
write_file "#{TMP}/local.rspec", '--format specdoc'
|
108
|
+
app = Respec::App.new
|
109
|
+
app.default_formatter_args.should == []
|
110
|
+
|
111
|
+
write_file "#{TMP}/local.rspec", '--formatter specdoc'
|
112
|
+
app = Respec::App.new
|
113
|
+
app.default_formatter_args.should == []
|
114
|
+
end
|
115
|
+
|
116
|
+
it "should be empty if a formatter arg is in the global .rspec" do
|
117
|
+
write_file "#{TMP}/global.rspec", '-f specdoc'
|
118
|
+
app = Respec::App.new
|
119
|
+
app.default_formatter_args.should == []
|
120
|
+
|
121
|
+
write_file "#{TMP}/gloabl.rspec", '--format specdoc'
|
122
|
+
app = Respec::App.new
|
123
|
+
app.default_formatter_args.should == []
|
124
|
+
|
125
|
+
write_file "#{TMP}/gloabl.rspec", '--formatter specdoc'
|
126
|
+
app = Respec::App.new
|
127
|
+
app.default_formatter_args.should == []
|
128
|
+
end
|
129
|
+
|
130
|
+
it "should return the args for the progress formatter otherwise" do
|
131
|
+
app = Respec::App.new
|
132
|
+
app.default_formatter_args.should == ['--format', 'progress']
|
133
|
+
end
|
134
|
+
end
|
135
|
+
|
78
136
|
describe "#generated_args" do
|
79
137
|
it "should treat all arguments that start with '-' to rspec" do
|
80
138
|
app = Respec::App.new('-a', '-b', '-c')
|
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.
|
4
|
+
version: 0.3.0
|
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: 2012-
|
12
|
+
date: 2012-11-11 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|
@@ -98,7 +98,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
98
98
|
version: '0'
|
99
99
|
segments:
|
100
100
|
- 0
|
101
|
-
hash:
|
101
|
+
hash: 667712185772310074
|
102
102
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
103
103
|
none: false
|
104
104
|
requirements:
|
@@ -107,7 +107,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
107
107
|
version: '0'
|
108
108
|
segments:
|
109
109
|
- 0
|
110
|
-
hash:
|
110
|
+
hash: 667712185772310074
|
111
111
|
requirements: []
|
112
112
|
rubyforge_project:
|
113
113
|
rubygems_version: 1.8.24
|