respec 0.3.0 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +4 -0
- data/lib/respec/app.rb +4 -24
- data/lib/respec/formatter.rb +8 -0
- data/lib/respec/version.rb +1 -1
- data/spec/respec/app_spec.rb +3 -67
- metadata +3 -3
data/CHANGELOG
CHANGED
data/lib/respec/app.rb
CHANGED
@@ -16,7 +16,7 @@ module Respec
|
|
16
16
|
end
|
17
17
|
|
18
18
|
def command
|
19
|
-
@command ||= bundler_args + ['rspec'] +
|
19
|
+
@command ||= bundler_args + ['rspec'] + generated_args + raw_args + formatter_args
|
20
20
|
end
|
21
21
|
|
22
22
|
def bundler_args
|
@@ -27,34 +27,20 @@ module Respec
|
|
27
27
|
end
|
28
28
|
end
|
29
29
|
|
30
|
+
attr_reader :generated_args, :raw_args
|
31
|
+
|
30
32
|
def formatter_args
|
31
33
|
if @update_failures
|
32
|
-
|
33
|
-
['--require', formatter_path, '--format', 'Respec::Formatter', '--out', failures_path]
|
34
|
+
[File.expand_path('formatter.rb', File.dirname(__FILE__))]
|
34
35
|
else
|
35
36
|
[]
|
36
37
|
end
|
37
38
|
end
|
38
39
|
|
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
|
-
|
48
|
-
attr_reader :generated_args, :raw_args
|
49
|
-
|
50
40
|
class << self
|
51
41
|
attr_accessor :failures_path
|
52
|
-
attr_accessor :local_rspec_config_path
|
53
|
-
attr_accessor :global_rspec_config_path
|
54
42
|
end
|
55
43
|
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')
|
58
44
|
|
59
45
|
def help_only?
|
60
46
|
@help_only
|
@@ -133,12 +119,6 @@ module Respec
|
|
133
119
|
@generated_args.concat(files) unless @selected_failures
|
134
120
|
end
|
135
121
|
|
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
|
-
|
142
122
|
def failures_path
|
143
123
|
self.class.failures_path
|
144
124
|
end
|
data/lib/respec/formatter.rb
CHANGED
@@ -9,3 +9,11 @@ module Respec
|
|
9
9
|
end
|
10
10
|
end
|
11
11
|
end
|
12
|
+
|
13
|
+
# We inject this here rather than on the command line, as the logic to assemble
|
14
|
+
# the list of formatters is complex, and easily broken by adding a --format
|
15
|
+
# option.
|
16
|
+
RSpec.configure do |config|
|
17
|
+
config.add_formatter 'progress' if config.formatters.empty?
|
18
|
+
config.add_formatter Respec::Formatter, ENV['RESPEC_FAILURES'] || File.expand_path(".respec_failures")
|
19
|
+
end
|
data/lib/respec/version.rb
CHANGED
data/spec/respec/app_spec.rb
CHANGED
@@ -8,8 +8,6 @@ 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
11
|
|
14
12
|
def write_file(path, content)
|
15
13
|
open(path, 'w') { |f| f.print content }
|
@@ -53,20 +51,15 @@ describe Respec::App do
|
|
53
51
|
end
|
54
52
|
|
55
53
|
describe "#formatter_args" do
|
56
|
-
it "should include the respec formatters" do
|
57
|
-
app = Respec::App.new
|
58
|
-
app.formatter_args.should == ['--require', FORMATTER_PATH, '--format', 'Respec::Formatter', '--out', FAIL_PATH]
|
59
|
-
end
|
60
|
-
|
61
54
|
it "should update the stored failures if no args are given" do
|
62
55
|
app = Respec::App.new
|
63
|
-
app.formatter_args.should == [
|
56
|
+
app.formatter_args.should == [FORMATTER_PATH]
|
64
57
|
end
|
65
58
|
|
66
59
|
it "should update the stored failures if 'f' is used" do
|
67
60
|
make_failures_file 'a.rb:1'
|
68
61
|
app = Respec::App.new('f')
|
69
|
-
app.formatter_args.should == [
|
62
|
+
app.formatter_args.should == [FORMATTER_PATH]
|
70
63
|
end
|
71
64
|
|
72
65
|
it "should not update the stored failures if a numeric argument is given" do
|
@@ -76,63 +69,6 @@ describe Respec::App do
|
|
76
69
|
end
|
77
70
|
end
|
78
71
|
|
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
|
-
|
136
72
|
describe "#generated_args" do
|
137
73
|
it "should treat all arguments that start with '-' to rspec" do
|
138
74
|
app = Respec::App.new('-a', '-b', '-c')
|
@@ -200,7 +136,7 @@ describe Respec::App do
|
|
200
136
|
Dir.chdir tmp do
|
201
137
|
FileUtils.touch 'Gemfile'
|
202
138
|
app = Respec::App.new('--', '-t', 'TAG')
|
203
|
-
app.command.should == ['bundle', 'exec', 'rspec', '
|
139
|
+
app.command.should == ['bundle', 'exec', 'rspec', '-t', 'TAG', FORMATTER_PATH]
|
204
140
|
end
|
205
141
|
end
|
206
142
|
end
|
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.4.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -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: 2310279171202373770
|
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: 2310279171202373770
|
111
111
|
requirements: []
|
112
112
|
rubyforge_project:
|
113
113
|
rubygems_version: 1.8.24
|