rspec-core 2.0.0.beta.15 → 2.0.0.beta.16
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +2 -0
- data/VERSION +1 -1
- data/features/README.markdown +12 -0
- data/features/command_line/example_name_option.feature +9 -9
- data/features/command_line/line_number_appended_to_path.feature +44 -44
- data/features/command_line/line_number_option.feature +4 -4
- data/features/configuration/custom_settings.feature +3 -3
- data/features/configuration/options_file.feature +3 -3
- data/features/example_groups/describe_aliases.feature +1 -1
- data/features/example_groups/nested_groups.feature +7 -7
- data/features/filtering/inclusion_filters.feature +10 -10
- data/features/formatters/custom_formatter.feature +1 -1
- data/features/hooks/around_hooks.feature +13 -13
- data/features/hooks/before_and_after_hooks.feature +38 -16
- data/features/hooks/described_class.feature +1 -1
- data/features/hooks/halt.feature +1 -1
- data/features/mock_framework_integration/use_flexmock.feature +1 -1
- data/features/mock_framework_integration/use_mocha.feature +1 -1
- data/features/mock_framework_integration/use_rr.feature +1 -1
- data/features/mock_framework_integration/use_rspec.feature +1 -1
- data/features/pending/pending_examples.feature +13 -13
- data/features/subject/explicit_subject.feature +4 -4
- data/features/subject/implicit_subject.feature +2 -2
- data/lib/rspec/core/backward_compatibility.rb +0 -6
- data/lib/rspec/core/command_line.rb +16 -27
- data/lib/rspec/core/configuration.rb +13 -4
- data/lib/rspec/core/example.rb +3 -2
- data/lib/rspec/core/formatters.rb +2 -11
- data/lib/rspec/core/formatters/base_formatter.rb +7 -3
- data/lib/rspec/core/formatters/base_text_formatter.rb +4 -0
- data/lib/rspec/core/formatters/html_formatter.rb +350 -0
- data/lib/rspec/core/formatters/snippet_extractor.rb +52 -0
- data/lib/rspec/core/formatters/text_mate_formatter.rb +18 -0
- data/lib/rspec/core/mocking/with_rspec.rb +6 -6
- data/lib/rspec/core/option_parser.rb +2 -0
- data/lib/rspec/core/runner.rb +11 -11
- data/lib/rspec/core/world.rb +10 -13
- data/rspec-core.gemspec +26 -10
- data/spec/rspec/core/command_line_spec.rb +1 -9
- data/spec/rspec/core/configuration_spec.rb +31 -15
- data/spec/rspec/core/drb_command_line_spec.rb +42 -34
- data/spec/rspec/core/formatters/html_formatted-1.8.7.html +280 -0
- data/spec/rspec/core/formatters/html_formatted-1.9.1.html +260 -0
- data/spec/rspec/core/formatters/html_formatted-1.9.2.html +260 -0
- data/spec/rspec/core/formatters/html_formatter_spec.rb +71 -0
- data/spec/rspec/core/formatters/snippet_extractor_spec.rb +18 -0
- data/spec/rspec/core/formatters/text_mate_formatted-1.8.7.html +280 -0
- data/spec/rspec/core/formatters/text_mate_formatter_spec.rb +67 -0
- data/spec/rspec/core/resources/formatter_specs.rb +36 -0
- data/spec/rspec/core/shared_example_group_spec.rb +12 -12
- data/spec/spec_helper.rb +26 -21
- metadata +28 -12
@@ -0,0 +1,52 @@
|
|
1
|
+
module RSpec
|
2
|
+
module Core
|
3
|
+
module Formatters
|
4
|
+
# This class extracts code snippets by looking at the backtrace of the passed error
|
5
|
+
class SnippetExtractor #:nodoc:
|
6
|
+
class NullConverter; def convert(code, pre); code; end; end #:nodoc:
|
7
|
+
begin; require 'syntax/convertors/html'; @@converter = Syntax::Convertors::HTML.for_syntax "ruby"; rescue LoadError => e; @@converter = NullConverter.new; end
|
8
|
+
|
9
|
+
def snippet(error)
|
10
|
+
raw_code, line = snippet_for(error.backtrace[0])
|
11
|
+
highlighted = @@converter.convert(raw_code, false)
|
12
|
+
highlighted << "\n<span class=\"comment\"># gem install syntax to get syntax highlighting</span>" if @@converter.is_a?(NullConverter)
|
13
|
+
post_process(highlighted, line)
|
14
|
+
end
|
15
|
+
|
16
|
+
def snippet_for(error_line)
|
17
|
+
if error_line =~ /(.*):(\d+)/
|
18
|
+
file = $1
|
19
|
+
line = $2.to_i
|
20
|
+
[lines_around(file, line), line]
|
21
|
+
else
|
22
|
+
["# Couldn't get snippet for #{error_line}", 1]
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def lines_around(file, line)
|
27
|
+
if File.file?(file)
|
28
|
+
lines = File.open(file).read.split("\n")
|
29
|
+
min = [0, line-3].max
|
30
|
+
max = [line+1, lines.length-1].min
|
31
|
+
selected_lines = []
|
32
|
+
selected_lines.join("\n")
|
33
|
+
lines[min..max].join("\n")
|
34
|
+
else
|
35
|
+
"# Couldn't get snippet for #{file}"
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
def post_process(highlighted, offending_line)
|
40
|
+
new_lines = []
|
41
|
+
highlighted.split("\n").each_with_index do |line, i|
|
42
|
+
new_line = "<span class=\"linenum\">#{offending_line+i-2}</span>#{line}"
|
43
|
+
new_line = "<span class=\"offending\">#{new_line}</span>" if i == 2
|
44
|
+
new_lines << new_line
|
45
|
+
end
|
46
|
+
new_lines.join("\n")
|
47
|
+
end
|
48
|
+
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'rspec/core/formatters/html_formatter'
|
2
|
+
|
3
|
+
module RSpec
|
4
|
+
module Core
|
5
|
+
module Formatters
|
6
|
+
# Formats backtraces so they're clickable by TextMate
|
7
|
+
class TextMateFormatter < HtmlFormatter
|
8
|
+
def backtrace_line(line)
|
9
|
+
if line = super(line)
|
10
|
+
line.sub!(/([^:]*\.rb):(\d*)/) do
|
11
|
+
"<a href=\"txmt://open?url=file://#{File.expand_path($1)}&line=#{$2}\">#{$1}:#{$2}</a> "
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -1,19 +1,19 @@
|
|
1
|
-
require 'rspec/mocks
|
2
|
-
require 'rspec/mocks/extensions'
|
1
|
+
require 'rspec/mocks'
|
3
2
|
|
4
3
|
module RSpec
|
5
4
|
module Core
|
6
5
|
module MockFrameworkAdapter
|
7
6
|
|
8
|
-
include RSpec::Mocks::ExampleMethods
|
9
7
|
def _setup_mocks
|
10
|
-
|
8
|
+
RSpec::Mocks::setup(self)
|
11
9
|
end
|
10
|
+
|
12
11
|
def _verify_mocks
|
13
|
-
|
12
|
+
RSpec::Mocks::verify
|
14
13
|
end
|
14
|
+
|
15
15
|
def _teardown_mocks
|
16
|
-
|
16
|
+
RSpec::Mocks::teardown
|
17
17
|
end
|
18
18
|
|
19
19
|
end
|
@@ -44,6 +44,8 @@ module RSpec::Core
|
|
44
44
|
parser.on('-f', '--format FORMATTER', 'Choose a formatter',
|
45
45
|
' [p]rogress (default - dots)',
|
46
46
|
' [d]ocumentation (group and example names)',
|
47
|
+
' [h]tml',
|
48
|
+
' [t]extmate',
|
47
49
|
' custom formatter class name') do |o|
|
48
50
|
options[:formatter] = o
|
49
51
|
end
|
data/lib/rspec/core/runner.rb
CHANGED
@@ -4,22 +4,22 @@ module RSpec
|
|
4
4
|
module Core
|
5
5
|
class Runner
|
6
6
|
|
7
|
-
def self.
|
8
|
-
|
7
|
+
def self.autorun
|
8
|
+
return if autorun_disabled? || installed_at_exit? || running_in_drb?
|
9
|
+
@installed_at_exit = true
|
10
|
+
at_exit { run(ARGV, $stderr, $stdout) ? exit(0) : exit(1) }
|
9
11
|
end
|
10
12
|
|
11
|
-
def self.
|
12
|
-
@
|
13
|
+
def self.autorun_disabled?
|
14
|
+
@autorun_disabled ||= false
|
13
15
|
end
|
14
16
|
|
15
|
-
def self.
|
16
|
-
@
|
17
|
+
def self.disable_autorun!
|
18
|
+
@autorun_disabled = true
|
17
19
|
end
|
18
20
|
|
19
|
-
def self.
|
20
|
-
|
21
|
-
@installed_at_exit = true
|
22
|
-
at_exit { run(ARGV, $stderr, $stdout) ? exit(0) : exit(1) }
|
21
|
+
def self.installed_at_exit?
|
22
|
+
@installed_at_exit ||= false
|
23
23
|
end
|
24
24
|
|
25
25
|
def self.running_in_drb?
|
@@ -43,7 +43,7 @@ module RSpec
|
|
43
43
|
end
|
44
44
|
|
45
45
|
def self.run_in_process(options, err, out)
|
46
|
-
CommandLine.new(options).run(err, out)
|
46
|
+
CommandLine.new(options, RSpec::configuration, RSpec::world).run(err, out)
|
47
47
|
end
|
48
48
|
|
49
49
|
end
|
data/lib/rspec/core/world.rb
CHANGED
@@ -4,7 +4,8 @@ module RSpec
|
|
4
4
|
|
5
5
|
attr_reader :example_groups, :filtered_examples
|
6
6
|
|
7
|
-
def initialize
|
7
|
+
def initialize(configuration=RSpec.configuration)
|
8
|
+
@configuration = configuration
|
8
9
|
@example_groups = []
|
9
10
|
@filtered_examples = Hash.new { |hash,group|
|
10
11
|
hash[group] = begin
|
@@ -16,20 +17,16 @@ module RSpec
|
|
16
17
|
}
|
17
18
|
end
|
18
19
|
|
19
|
-
def configuration
|
20
|
-
RSpec.configuration
|
21
|
-
end
|
22
|
-
|
23
20
|
def inclusion_filter
|
24
|
-
configuration.filter
|
21
|
+
@configuration.filter
|
25
22
|
end
|
26
23
|
|
27
24
|
def exclusion_filter
|
28
|
-
configuration.exclusion_filter
|
25
|
+
@configuration.exclusion_filter
|
29
26
|
end
|
30
27
|
|
31
28
|
def find_modules(group)
|
32
|
-
configuration.find_modules(group)
|
29
|
+
@configuration.find_modules(group)
|
33
30
|
end
|
34
31
|
|
35
32
|
def shared_example_groups
|
@@ -58,12 +55,12 @@ module RSpec
|
|
58
55
|
|
59
56
|
def announce_inclusion_filter
|
60
57
|
if inclusion_filter
|
61
|
-
if
|
62
|
-
|
63
|
-
|
58
|
+
if @configuration.run_all_when_everything_filtered? && RSpec.world.example_count == 0
|
59
|
+
@configuration.reporter.message "No examples were matched by #{inclusion_filter.inspect}, running all"
|
60
|
+
@configuration.clear_inclusion_filter
|
64
61
|
filtered_examples.clear
|
65
62
|
else
|
66
|
-
|
63
|
+
@configuration.reporter.message "Run filtered using #{inclusion_filter.inspect}"
|
67
64
|
end
|
68
65
|
end
|
69
66
|
end
|
@@ -71,7 +68,7 @@ module RSpec
|
|
71
68
|
include RSpec::Core::Hooks
|
72
69
|
|
73
70
|
def find_hook(hook, scope, group)
|
74
|
-
|
71
|
+
@configuration.find_hook(hook, scope, group)
|
75
72
|
end
|
76
73
|
|
77
74
|
private
|
data/rspec-core.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{rspec-core}
|
8
|
-
s.version = "2.0.0.beta.
|
8
|
+
s.version = "2.0.0.beta.16"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new("> 1.3.1") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Chad Humphries", "David Chelimsky"]
|
12
|
-
s.date = %q{2010-06
|
12
|
+
s.date = %q{2010-07-06}
|
13
13
|
s.default_executable = %q{rspec}
|
14
14
|
s.description = %q{RSpec runner and example groups}
|
15
15
|
s.email = %q{dchelimsky@gmail.com;chad.humphries@gmail.com}
|
@@ -31,6 +31,7 @@ Gem::Specification.new do |s|
|
|
31
31
|
"autotest/discover.rb",
|
32
32
|
"bin/rspec",
|
33
33
|
"cucumber.yml",
|
34
|
+
"features/README.markdown",
|
34
35
|
"features/command_line/example_name_option.feature",
|
35
36
|
"features/command_line/exit_status.feature",
|
36
37
|
"features/command_line/line_number_appended_to_path.feature",
|
@@ -71,7 +72,10 @@ Gem::Specification.new do |s|
|
|
71
72
|
"lib/rspec/core/formatters/base_text_formatter.rb",
|
72
73
|
"lib/rspec/core/formatters/documentation_formatter.rb",
|
73
74
|
"lib/rspec/core/formatters/helpers.rb",
|
75
|
+
"lib/rspec/core/formatters/html_formatter.rb",
|
74
76
|
"lib/rspec/core/formatters/progress_formatter.rb",
|
77
|
+
"lib/rspec/core/formatters/snippet_extractor.rb",
|
78
|
+
"lib/rspec/core/formatters/text_mate_formatter.rb",
|
75
79
|
"lib/rspec/core/hooks.rb",
|
76
80
|
"lib/rspec/core/kernel_extensions.rb",
|
77
81
|
"lib/rspec/core/let.rb",
|
@@ -110,7 +114,14 @@ Gem::Specification.new do |s|
|
|
110
114
|
"spec/rspec/core/formatters/base_text_formatter_spec.rb",
|
111
115
|
"spec/rspec/core/formatters/documentation_formatter_spec.rb",
|
112
116
|
"spec/rspec/core/formatters/helpers_spec.rb",
|
117
|
+
"spec/rspec/core/formatters/html_formatted-1.8.7.html",
|
118
|
+
"spec/rspec/core/formatters/html_formatted-1.9.1.html",
|
119
|
+
"spec/rspec/core/formatters/html_formatted-1.9.2.html",
|
120
|
+
"spec/rspec/core/formatters/html_formatter_spec.rb",
|
113
121
|
"spec/rspec/core/formatters/progress_formatter_spec.rb",
|
122
|
+
"spec/rspec/core/formatters/snippet_extractor_spec.rb",
|
123
|
+
"spec/rspec/core/formatters/text_mate_formatted-1.8.7.html",
|
124
|
+
"spec/rspec/core/formatters/text_mate_formatter_spec.rb",
|
114
125
|
"spec/rspec/core/hooks_spec.rb",
|
115
126
|
"spec/rspec/core/kernel_extensions_spec.rb",
|
116
127
|
"spec/rspec/core/let_spec.rb",
|
@@ -121,6 +132,7 @@ Gem::Specification.new do |s|
|
|
121
132
|
"spec/rspec/core/resources/a_foo.rb",
|
122
133
|
"spec/rspec/core/resources/a_spec.rb",
|
123
134
|
"spec/rspec/core/resources/custom_example_group_runner.rb",
|
135
|
+
"spec/rspec/core/resources/formatter_specs.rb",
|
124
136
|
"spec/rspec/core/resources/utf8_encoded.rb",
|
125
137
|
"spec/rspec/core/ruby_project_spec.rb",
|
126
138
|
"spec/rspec/core/runner_spec.rb",
|
@@ -135,7 +147,7 @@ Gem::Specification.new do |s|
|
|
135
147
|
s.homepage = %q{http://github.com/rspec/rspec-core}
|
136
148
|
s.post_install_message = %q{**************************************************
|
137
149
|
|
138
|
-
Thank you for installing rspec-core-2.0.0.beta.
|
150
|
+
Thank you for installing rspec-core-2.0.0.beta.16
|
139
151
|
|
140
152
|
**************************************************
|
141
153
|
}
|
@@ -143,7 +155,7 @@ Gem::Specification.new do |s|
|
|
143
155
|
s.require_paths = ["lib"]
|
144
156
|
s.rubyforge_project = %q{rspec}
|
145
157
|
s.rubygems_version = %q{1.3.7}
|
146
|
-
s.summary = %q{rspec-core-2.0.0.beta.
|
158
|
+
s.summary = %q{rspec-core-2.0.0.beta.16}
|
147
159
|
s.test_files = [
|
148
160
|
"spec/autotest/failed_results_re_spec.rb",
|
149
161
|
"spec/autotest/rspec_spec.rb",
|
@@ -159,7 +171,10 @@ Gem::Specification.new do |s|
|
|
159
171
|
"spec/rspec/core/formatters/base_text_formatter_spec.rb",
|
160
172
|
"spec/rspec/core/formatters/documentation_formatter_spec.rb",
|
161
173
|
"spec/rspec/core/formatters/helpers_spec.rb",
|
174
|
+
"spec/rspec/core/formatters/html_formatter_spec.rb",
|
162
175
|
"spec/rspec/core/formatters/progress_formatter_spec.rb",
|
176
|
+
"spec/rspec/core/formatters/snippet_extractor_spec.rb",
|
177
|
+
"spec/rspec/core/formatters/text_mate_formatter_spec.rb",
|
163
178
|
"spec/rspec/core/hooks_spec.rb",
|
164
179
|
"spec/rspec/core/kernel_extensions_spec.rb",
|
165
180
|
"spec/rspec/core/let_spec.rb",
|
@@ -170,6 +185,7 @@ Gem::Specification.new do |s|
|
|
170
185
|
"spec/rspec/core/resources/a_foo.rb",
|
171
186
|
"spec/rspec/core/resources/a_spec.rb",
|
172
187
|
"spec/rspec/core/resources/custom_example_group_runner.rb",
|
188
|
+
"spec/rspec/core/resources/formatter_specs.rb",
|
173
189
|
"spec/rspec/core/resources/utf8_encoded.rb",
|
174
190
|
"spec/rspec/core/ruby_project_spec.rb",
|
175
191
|
"spec/rspec/core/runner_spec.rb",
|
@@ -186,19 +202,19 @@ Gem::Specification.new do |s|
|
|
186
202
|
s.specification_version = 3
|
187
203
|
|
188
204
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
189
|
-
s.add_development_dependency(%q<rspec-expectations>, [">= 2.0.0.beta.
|
190
|
-
s.add_development_dependency(%q<rspec-mocks>, [">= 2.0.0.beta.
|
205
|
+
s.add_development_dependency(%q<rspec-expectations>, [">= 2.0.0.beta.16"])
|
206
|
+
s.add_development_dependency(%q<rspec-mocks>, [">= 2.0.0.beta.16"])
|
191
207
|
s.add_development_dependency(%q<cucumber>, [">= 0.5.3"])
|
192
208
|
s.add_development_dependency(%q<autotest>, [">= 4.2.9"])
|
193
209
|
else
|
194
|
-
s.add_dependency(%q<rspec-expectations>, [">= 2.0.0.beta.
|
195
|
-
s.add_dependency(%q<rspec-mocks>, [">= 2.0.0.beta.
|
210
|
+
s.add_dependency(%q<rspec-expectations>, [">= 2.0.0.beta.16"])
|
211
|
+
s.add_dependency(%q<rspec-mocks>, [">= 2.0.0.beta.16"])
|
196
212
|
s.add_dependency(%q<cucumber>, [">= 0.5.3"])
|
197
213
|
s.add_dependency(%q<autotest>, [">= 4.2.9"])
|
198
214
|
end
|
199
215
|
else
|
200
|
-
s.add_dependency(%q<rspec-expectations>, [">= 2.0.0.beta.
|
201
|
-
s.add_dependency(%q<rspec-mocks>, [">= 2.0.0.beta.
|
216
|
+
s.add_dependency(%q<rspec-expectations>, [">= 2.0.0.beta.16"])
|
217
|
+
s.add_dependency(%q<rspec-mocks>, [">= 2.0.0.beta.16"])
|
202
218
|
s.add_dependency(%q<cucumber>, [">= 0.5.3"])
|
203
219
|
s.add_dependency(%q<autotest>, [">= 4.2.9"])
|
204
220
|
end
|
@@ -3,13 +3,6 @@ require "stringio"
|
|
3
3
|
|
4
4
|
module RSpec::Core
|
5
5
|
describe CommandLine do
|
6
|
-
context "given an array" do
|
7
|
-
it "converts the contents to a ConfigurationOptions object" do
|
8
|
-
command_line = CommandLine.new(%w[--color])
|
9
|
-
command_line.instance_eval { @options }.should be_a(ConfigurationOptions)
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
6
|
context "given a ConfigurationOptions object" do
|
14
7
|
it "assigns it to @options" do
|
15
8
|
config_options = ConfigurationOptions.new(%w[--color])
|
@@ -27,7 +20,7 @@ module RSpec::Core
|
|
27
20
|
end
|
28
21
|
|
29
22
|
let(:command_line) do
|
30
|
-
CommandLine.new(config_options)
|
23
|
+
CommandLine.new(config_options, config)
|
31
24
|
end
|
32
25
|
|
33
26
|
let(:config) do
|
@@ -37,7 +30,6 @@ module RSpec::Core
|
|
37
30
|
let(:out) { ::StringIO.new }
|
38
31
|
|
39
32
|
before do
|
40
|
-
command_line.stub(:configuration) { config }
|
41
33
|
config.stub(:run_hook)
|
42
34
|
end
|
43
35
|
|
@@ -140,19 +140,22 @@ module RSpec::Core
|
|
140
140
|
|
141
141
|
context "with no filter" do
|
142
142
|
it "includes the given module into each example group" do
|
143
|
-
|
144
|
-
|
143
|
+
RSpec.configure do |c|
|
144
|
+
c.include(InstanceLevelMethods)
|
145
|
+
end
|
146
|
+
|
145
147
|
group = ExampleGroup.describe('does like, stuff and junk', :magic_key => :include) { }
|
146
148
|
group.should_not respond_to(:you_call_this_a_blt?)
|
147
149
|
group.new.you_call_this_a_blt?.should == "egad man, where's the mayo?!?!?"
|
148
150
|
end
|
149
|
-
|
150
151
|
end
|
151
152
|
|
152
153
|
context "with a filter" do
|
153
154
|
it "includes the given module into each matching example group" do
|
154
|
-
|
155
|
-
|
155
|
+
RSpec.configure do |c|
|
156
|
+
c.include(InstanceLevelMethods, :magic_key => :include)
|
157
|
+
end
|
158
|
+
|
156
159
|
group = ExampleGroup.describe('does like, stuff and junk', :magic_key => :include) { }
|
157
160
|
group.should_not respond_to(:you_call_this_a_blt?)
|
158
161
|
group.new.you_call_this_a_blt?.should == "egad man, where's the mayo?!?!?"
|
@@ -169,7 +172,10 @@ module RSpec::Core
|
|
169
172
|
end
|
170
173
|
|
171
174
|
it "should extend the given module into each matching example group" do
|
172
|
-
|
175
|
+
RSpec.configure do |c|
|
176
|
+
c.extend(ThatThingISentYou, :magic_key => :extend)
|
177
|
+
end
|
178
|
+
|
173
179
|
group = ExampleGroup.describe(ThatThingISentYou, :magic_key => :extend) { }
|
174
180
|
group.should respond_to(:that_thing)
|
175
181
|
end
|
@@ -304,18 +310,18 @@ module RSpec::Core
|
|
304
310
|
end
|
305
311
|
|
306
312
|
describe "full_backtrace=" do
|
307
|
-
before do
|
308
|
-
@backtrace_clean_patterns = config.backtrace_clean_patterns
|
309
|
-
end
|
310
|
-
|
311
|
-
after do
|
312
|
-
config.backtrace_clean_patterns = @backtrace_clean_patterns
|
313
|
-
end
|
314
|
-
|
315
313
|
it "clears the backtrace clean patterns" do
|
316
314
|
config.full_backtrace = true
|
317
315
|
config.backtrace_clean_patterns.should == []
|
318
316
|
end
|
317
|
+
|
318
|
+
it "doesn't impact other instances of config" do
|
319
|
+
config_1 = Configuration.new
|
320
|
+
config_2 = Configuration.new
|
321
|
+
|
322
|
+
config_1.full_backtrace = true
|
323
|
+
config_2.backtrace_clean_patterns.should_not be_empty
|
324
|
+
end
|
319
325
|
end
|
320
326
|
|
321
327
|
describe "debug=true" do
|
@@ -384,10 +390,20 @@ module RSpec::Core
|
|
384
390
|
config.custom_option?.should be_true
|
385
391
|
end
|
386
392
|
|
387
|
-
it "can be overridden" do
|
393
|
+
it "can be overridden with a truthy value" do
|
388
394
|
config.custom_option = "a new value"
|
389
395
|
config.custom_option.should eq("a new value")
|
390
396
|
end
|
397
|
+
|
398
|
+
it "can be overridden with nil" do
|
399
|
+
config.custom_option = nil
|
400
|
+
config.custom_option.should eq(nil)
|
401
|
+
end
|
402
|
+
|
403
|
+
it "can be overridden with false" do
|
404
|
+
config.custom_option = false
|
405
|
+
config.custom_option.should eq(false)
|
406
|
+
end
|
391
407
|
end
|
392
408
|
end
|
393
409
|
|
@@ -1,31 +1,39 @@
|
|
1
1
|
require "spec_helper"
|
2
2
|
|
3
3
|
describe "::DRbCommandLine", :ruby => "!jruby" do
|
4
|
-
|
5
|
-
|
4
|
+
let(:config) { RSpec::Core::Configuration.new }
|
5
|
+
let(:out) { StringIO.new }
|
6
|
+
let(:err) { StringIO.new }
|
7
|
+
|
8
|
+
def config_options(argv=[])
|
9
|
+
options = RSpec::Core::ConfigurationOptions.new(argv)
|
10
|
+
options.parse_options
|
11
|
+
options
|
12
|
+
end
|
13
|
+
|
14
|
+
def drb_command_line(args)
|
15
|
+
RSpec::Core::DRbCommandLine.new(config_options(args))
|
16
|
+
end
|
17
|
+
|
18
|
+
def run_with(args)
|
19
|
+
drb_command_line(args).run(err, out)
|
6
20
|
end
|
7
21
|
|
8
22
|
context "without server running" do
|
9
23
|
it "prints error" do
|
10
|
-
|
11
|
-
RSpec::Core::DRbCommandLine.new([]).run(err, out)
|
24
|
+
run_with []
|
12
25
|
|
13
26
|
err.rewind
|
14
27
|
err.read.should =~ /No DRb server is running/
|
15
28
|
end
|
16
29
|
|
17
30
|
it "returns false" do
|
18
|
-
|
19
|
-
result = RSpec::Core::DRbCommandLine.new([]).run(err, out)
|
31
|
+
result = run_with []
|
20
32
|
result.should be_false
|
21
33
|
end
|
22
34
|
end
|
23
35
|
|
24
36
|
describe "--drb-port" do
|
25
|
-
def config_options_object(*args)
|
26
|
-
RSpec::Core::DRbCommandLine.new(args)
|
27
|
-
end
|
28
|
-
|
29
37
|
def with_RSPEC_DRB_set_to(val)
|
30
38
|
original = ENV['RSPEC_DRB']
|
31
39
|
ENV['RSPEC_DRB'] = val
|
@@ -39,14 +47,14 @@ describe "::DRbCommandLine", :ruby => "!jruby" do
|
|
39
47
|
context "without RSPEC_DRB environment variable set" do
|
40
48
|
it "defaults to 8989" do
|
41
49
|
with_RSPEC_DRB_set_to(nil) do
|
42
|
-
|
50
|
+
drb_command_line([]).drb_port.should == 8989
|
43
51
|
end
|
44
52
|
end
|
45
53
|
|
46
54
|
it "sets the DRb port" do
|
47
55
|
with_RSPEC_DRB_set_to(nil) do
|
48
|
-
|
49
|
-
|
56
|
+
drb_command_line(["--drb-port", "1234"]).drb_port.should == 1234
|
57
|
+
drb_command_line(["--drb-port", "5678"]).drb_port.should == 5678
|
50
58
|
end
|
51
59
|
end
|
52
60
|
end
|
@@ -56,7 +64,7 @@ describe "::DRbCommandLine", :ruby => "!jruby" do
|
|
56
64
|
context "without config variable set" do
|
57
65
|
it "uses RSPEC_DRB value" do
|
58
66
|
with_RSPEC_DRB_set_to('9000') do
|
59
|
-
|
67
|
+
drb_command_line([]).drb_port.should == "9000"
|
60
68
|
end
|
61
69
|
end
|
62
70
|
end
|
@@ -64,7 +72,7 @@ describe "::DRbCommandLine", :ruby => "!jruby" do
|
|
64
72
|
context "and config variable set" do
|
65
73
|
it "uses configured value" do
|
66
74
|
with_RSPEC_DRB_set_to('9000') do
|
67
|
-
|
75
|
+
drb_command_line(%w[--drb-port 5678]).drb_port.should == 5678
|
68
76
|
end
|
69
77
|
end
|
70
78
|
end
|
@@ -74,7 +82,9 @@ describe "::DRbCommandLine", :ruby => "!jruby" do
|
|
74
82
|
context "with server running" do
|
75
83
|
class ::FakeDrbSpecServer
|
76
84
|
def self.run(argv, err, out)
|
77
|
-
RSpec::Core::
|
85
|
+
options = RSpec::Core::ConfigurationOptions.new(argv)
|
86
|
+
options.parse_options
|
87
|
+
RSpec::Core::CommandLine.new(options, RSpec::Core::Configuration.new).run(err, out)
|
78
88
|
end
|
79
89
|
end
|
80
90
|
|
@@ -117,34 +127,32 @@ describe "::DRbCommandLine", :ruby => "!jruby" do
|
|
117
127
|
end
|
118
128
|
end
|
119
129
|
|
120
|
-
|
130
|
+
it "returns true" do
|
121
131
|
err, out = StringIO.new, StringIO.new
|
122
|
-
|
123
|
-
|
124
|
-
out.read
|
132
|
+
result = drb_command_line(["--drb-port", @drb_port.to_s]).run(err, out)
|
133
|
+
result.should be_true
|
125
134
|
end
|
126
|
-
|
127
|
-
it "
|
135
|
+
|
136
|
+
it "integrates via Runner.new.run" do
|
128
137
|
err, out = StringIO.new, StringIO.new
|
129
|
-
result = RSpec::Core::
|
138
|
+
result = RSpec::Core::Runner.run(%W[ --drb --drb-port #{@drb_port} #{dummy_spec_filename}], err, out)
|
130
139
|
result.should be_true
|
131
140
|
end
|
141
|
+
|
142
|
+
def run_spec_via_druby
|
143
|
+
run_with([dummy_spec_filename, "--colour", "--drb-port", @drb_port.to_s])
|
144
|
+
out.rewind
|
145
|
+
out.read
|
146
|
+
end
|
132
147
|
|
133
148
|
it "should output green colorized text when running with --colour option" do
|
134
|
-
out
|
135
|
-
|
149
|
+
pending "figure out a way to properly sandbox this"
|
150
|
+
run_spec_via_druby.should =~ /\e\[32m/m
|
136
151
|
end
|
137
152
|
|
138
153
|
it "should output red colorized text when running with -c option" do
|
139
|
-
pending
|
140
|
-
|
141
|
-
out.should =~ /\e\[31m/m
|
142
|
-
end
|
143
|
-
|
144
|
-
it "integrates via Runner.new.run" do
|
145
|
-
err, out = StringIO.new, StringIO.new
|
146
|
-
result = RSpec::Core::Runner.run(%W[ --drb --drb-port #{@drb_port} #{dummy_spec_filename}], err, out)
|
147
|
-
result.should be_true
|
154
|
+
pending "figure out a way to properly sandbox this"
|
155
|
+
run_spec_via_druby.should =~ /\e\[31m/m
|
148
156
|
end
|
149
157
|
end
|
150
158
|
|