rspec-core 3.0.0.beta1 → 3.0.0.beta2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data.tar.gz.sig +0 -0
- data/Changelog.md +137 -0
- data/README.md +2 -2
- data/exe/rspec +2 -23
- data/features/README.md +1 -5
- data/features/command_line/README.md +7 -10
- data/features/command_line/exit_status.feature +1 -1
- data/features/command_line/format_option.feature +1 -1
- data/features/command_line/init.feature +40 -1
- data/features/command_line/line_number_option.feature +2 -2
- data/features/command_line/ruby.feature +5 -4
- data/features/configuration/enable_global_dsl.feature +54 -0
- data/features/example_groups/aliasing.feature +48 -0
- data/features/example_groups/basic_structure.feature +1 -1
- data/features/expectation_framework_integration/configure_expectation_framework.feature +1 -1
- data/features/filtering/if_and_unless.feature +0 -30
- data/features/formatters/custom_formatter.feature +32 -0
- data/features/formatters/regression_tests.feature +95 -0
- data/features/hooks/around_hooks.feature +1 -0
- data/features/hooks/before_and_after_hooks.feature +2 -2
- data/features/mock_framework_integration/use_flexmock.feature +11 -13
- data/features/mock_framework_integration/use_mocha.feature +11 -13
- data/features/mock_framework_integration/use_rr.feature +11 -13
- data/features/mock_framework_integration/use_rspec.feature +11 -13
- data/features/pending_and_skipped_examples/README.md +3 -0
- data/features/pending_and_skipped_examples/pending_examples.feature +118 -0
- data/features/pending_and_skipped_examples/skipped_examples.feature +106 -0
- data/features/step_definitions/additional_cli_steps.rb +34 -0
- data/features/subject/explicit_subject.feature +1 -1
- data/features/subject/one_liner_syntax.feature +71 -0
- data/lib/rspec/core.rb +6 -14
- data/lib/rspec/core/backtrace_formatter.rb +16 -4
- data/lib/rspec/core/command_line.rb +2 -3
- data/lib/rspec/core/configuration.rb +114 -125
- data/lib/rspec/core/configuration_options.rb +32 -18
- data/lib/rspec/core/dsl.rb +80 -18
- data/lib/rspec/core/example.rb +84 -33
- data/lib/rspec/core/example_group.rb +95 -43
- data/lib/rspec/core/filter_manager.rb +31 -40
- data/lib/rspec/core/formatters.rb +137 -0
- data/lib/rspec/core/formatters/base_formatter.rb +28 -41
- data/lib/rspec/core/formatters/base_text_formatter.rb +26 -37
- data/lib/rspec/core/formatters/deprecation_formatter.rb +48 -27
- data/lib/rspec/core/formatters/documentation_formatter.rb +27 -22
- data/lib/rspec/core/formatters/html_formatter.rb +48 -56
- data/lib/rspec/core/formatters/html_printer.rb +11 -18
- data/lib/rspec/core/formatters/json_formatter.rb +18 -22
- data/lib/rspec/core/formatters/legacy_formatter.rb +227 -0
- data/lib/rspec/core/formatters/progress_formatter.rb +7 -10
- data/lib/rspec/core/hooks.rb +250 -217
- data/lib/rspec/core/memoized_helpers.rb +43 -9
- data/lib/rspec/core/mocking_adapters/flexmock.rb +29 -0
- data/lib/rspec/core/{mocking/with_mocha.rb → mocking_adapters/mocha.rb} +19 -16
- data/lib/rspec/core/mocking_adapters/null.rb +12 -0
- data/lib/rspec/core/mocking_adapters/rr.rb +28 -0
- data/lib/rspec/core/mocking_adapters/rspec.rb +30 -0
- data/lib/rspec/core/notifications.rb +100 -0
- data/lib/rspec/core/option_parser.rb +11 -18
- data/lib/rspec/core/pending.rb +78 -47
- data/lib/rspec/core/project_initializer.rb +2 -49
- data/lib/rspec/core/project_initializer/dot_rspec +3 -0
- data/lib/rspec/core/project_initializer/spec_helper.rb +82 -0
- data/lib/rspec/core/rake_task.rb +5 -14
- data/lib/rspec/core/reporter.rb +24 -32
- data/lib/rspec/core/ruby_project.rb +1 -1
- data/lib/rspec/core/runner.rb +14 -4
- data/lib/rspec/core/shared_example_group.rb +40 -13
- data/lib/rspec/core/version.rb +1 -1
- data/spec/command_line/order_spec.rb +15 -15
- data/spec/rspec/core/backtrace_formatter_spec.rb +15 -1
- data/spec/rspec/core/command_line_spec.rb +18 -17
- data/spec/rspec/core/configuration_options_spec.rb +57 -34
- data/spec/rspec/core/configuration_spec.rb +162 -184
- data/spec/rspec/core/drb_command_line_spec.rb +5 -7
- data/spec/rspec/core/drb_options_spec.rb +2 -2
- data/spec/rspec/core/dsl_spec.rb +79 -15
- data/spec/rspec/core/example_group_spec.rb +253 -39
- data/spec/rspec/core/example_spec.rb +149 -33
- data/spec/rspec/core/filter_manager_spec.rb +9 -26
- data/spec/rspec/core/formatters/base_formatter_spec.rb +2 -5
- data/spec/rspec/core/formatters/base_text_formatter_spec.rb +42 -145
- data/spec/rspec/core/formatters/deprecation_formatter_spec.rb +64 -34
- data/spec/rspec/core/formatters/documentation_formatter_spec.rb +15 -28
- data/spec/rspec/core/formatters/helpers_spec.rb +2 -2
- data/spec/rspec/core/formatters/{html_formatted-1.8.7.html → html_formatted-2.1.0.html} +22 -44
- data/spec/rspec/core/formatters/{html_formatted-1.8.7-jruby.html → html_formatted.html} +30 -49
- data/spec/rspec/core/formatters/html_formatter_spec.rb +35 -19
- data/spec/rspec/core/formatters/json_formatter_spec.rb +42 -40
- data/spec/rspec/core/formatters/legacy_formatter_spec.rb +137 -0
- data/spec/rspec/core/formatters/progress_formatter_spec.rb +38 -25
- data/spec/rspec/core/formatters/snippet_extractor_spec.rb +1 -1
- data/spec/rspec/core/formatters_spec.rb +120 -0
- data/spec/rspec/core/hooks_filtering_spec.rb +1 -1
- data/spec/rspec/core/hooks_spec.rb +13 -2
- data/spec/rspec/core/memoized_helpers_spec.rb +17 -8
- data/spec/rspec/core/metadata_spec.rb +3 -3
- data/spec/rspec/core/option_parser_spec.rb +53 -46
- data/spec/rspec/core/ordering_spec.rb +4 -4
- data/spec/rspec/core/pending_example_spec.rb +23 -126
- data/spec/rspec/core/pending_spec.rb +8 -0
- data/spec/rspec/core/project_initializer_spec.rb +8 -41
- data/spec/rspec/core/rake_task_spec.rb +15 -4
- data/spec/rspec/core/random_spec.rb +1 -1
- data/spec/rspec/core/reporter_spec.rb +50 -37
- data/spec/rspec/core/resources/formatter_specs.rb +9 -11
- data/spec/rspec/core/rspec_matchers_spec.rb +1 -1
- data/spec/rspec/core/ruby_project_spec.rb +3 -3
- data/spec/rspec/core/runner_spec.rb +65 -23
- data/spec/rspec/core/shared_context_spec.rb +4 -4
- data/spec/rspec/core/shared_example_group/collection_spec.rb +1 -1
- data/spec/rspec/core/shared_example_group_spec.rb +20 -11
- data/spec/rspec/core/warnings_spec.rb +1 -1
- data/spec/rspec/core/world_spec.rb +10 -10
- data/spec/rspec/core_spec.rb +2 -2
- data/spec/spec_helper.rb +12 -24
- data/spec/support/config_options_helper.rb +1 -3
- data/spec/support/formatter_support.rb +83 -0
- data/spec/support/isolate_load_path_mutation.rb +1 -2
- data/spec/support/isolated_directory.rb +1 -1
- data/spec/support/isolated_home_directory.rb +1 -1
- data/spec/support/legacy_formatter_using_sub_classing_example.rb +87 -0
- data/spec/support/matchers.rb +20 -0
- data/spec/support/mathn_integration_support.rb +2 -2
- data/spec/support/old_style_formatter_example.rb +69 -0
- data/spec/support/shared_example_groups.rb +1 -1
- data/spec/support/spec_files.rb +3 -3
- metadata +192 -69
- metadata.gz.sig +3 -1
- checksums.yaml +0 -15
- checksums.yaml.gz.sig +0 -2
- data/features/configuration/show_failures_in_pending_blocks.feature +0 -61
- data/features/pending/pending_examples.feature +0 -229
- data/features/subject/implicit_receiver.feature +0 -29
- data/lib/rspec/core/mocking/with_absolutely_nothing.rb +0 -11
- data/lib/rspec/core/mocking/with_flexmock.rb +0 -27
- data/lib/rspec/core/mocking/with_rr.rb +0 -27
- data/lib/rspec/core/mocking/with_rspec.rb +0 -27
- data/spec/rspec/core/formatters/html_formatted-1.8.7-rbx.html +0 -477
- data/spec/rspec/core/formatters/html_formatted-1.9.2.html +0 -425
- data/spec/rspec/core/formatters/html_formatted-1.9.3-jruby.html +0 -416
- data/spec/rspec/core/formatters/html_formatted-1.9.3-rbx.html +0 -477
- data/spec/rspec/core/formatters/html_formatted-1.9.3.html +0 -419
- data/spec/rspec/core/formatters/html_formatted-2.0.0.html +0 -425
- data/spec/support/in_sub_process.rb +0 -37
- data/spec/support/sandboxed_mock_space.rb +0 -100
|
@@ -6,20 +6,11 @@ require 'nokogiri'
|
|
|
6
6
|
module RSpec
|
|
7
7
|
module Core
|
|
8
8
|
module Formatters
|
|
9
|
-
describe HtmlFormatter
|
|
10
|
-
let(:suffix) {
|
|
11
|
-
if ::RUBY_PLATFORM == 'java'
|
|
12
|
-
"-jruby"
|
|
13
|
-
elsif defined?(Rubinius)
|
|
14
|
-
"-rbx"
|
|
15
|
-
else
|
|
16
|
-
""
|
|
17
|
-
end
|
|
18
|
-
}
|
|
9
|
+
RSpec.describe HtmlFormatter do
|
|
19
10
|
|
|
20
11
|
let(:root) { File.expand_path("#{File.dirname(__FILE__)}/../../../..") }
|
|
21
12
|
let(:expected_file) do
|
|
22
|
-
"#{File.dirname(__FILE__)}/html_formatted
|
|
13
|
+
"#{File.dirname(__FILE__)}/html_formatted.html"
|
|
23
14
|
end
|
|
24
15
|
|
|
25
16
|
let(:generated_html) do
|
|
@@ -31,14 +22,28 @@ module RSpec
|
|
|
31
22
|
command_line = RSpec::Core::CommandLine.new(options)
|
|
32
23
|
command_line.instance_variable_get("@configuration").backtrace_formatter.inclusion_patterns = []
|
|
33
24
|
command_line.run(err, out)
|
|
34
|
-
out.string.gsub(/\d+\.\d+(s| seconds)/, "n.nnnn\\1")
|
|
25
|
+
html = out.string.gsub(/\d+\.\d+(s| seconds)/, "n.nnnn\\1")
|
|
26
|
+
|
|
27
|
+
actual_doc = Nokogiri::HTML(html)
|
|
28
|
+
actual_doc.css("div.backtrace pre").each do |elem|
|
|
29
|
+
# This is to minimize churn on backtrace lines that we do not
|
|
30
|
+
# assert on anyway.
|
|
31
|
+
backtrace = elem.inner_html.lines.
|
|
32
|
+
select {|e| e =~ /formatter_specs\.rb/ }.
|
|
33
|
+
map {|x| x.chomp.split(":")[0..1].join(':') }.
|
|
34
|
+
join("\n")
|
|
35
|
+
|
|
36
|
+
elem.inner_html = backtrace
|
|
37
|
+
end
|
|
38
|
+
actual_doc.inner_html
|
|
35
39
|
end
|
|
36
40
|
|
|
37
41
|
let(:expected_html) do
|
|
38
|
-
|
|
39
|
-
|
|
42
|
+
if File.file?(expected_file)
|
|
43
|
+
File.read(expected_file)
|
|
44
|
+
else
|
|
45
|
+
pending "There is no HTML file with expected content for this platform: #{expected_file}"
|
|
40
46
|
end
|
|
41
|
-
File.read(expected_file)
|
|
42
47
|
end
|
|
43
48
|
|
|
44
49
|
before do
|
|
@@ -64,7 +69,18 @@ module RSpec
|
|
|
64
69
|
select {|e| e =~ /formatter_specs\.rb/}
|
|
65
70
|
end
|
|
66
71
|
|
|
67
|
-
describe 'produced HTML' do
|
|
72
|
+
describe 'produced HTML', :if => RUBY_VERSION <= '2.0.0' do
|
|
73
|
+
# Rubies before 2 are a wild west of different outputs, and it's not
|
|
74
|
+
# worth the effort to maintain accurate fixtures for all of them.
|
|
75
|
+
# Since we are verifying fixtures on other rubies, if this code at
|
|
76
|
+
# least runs we can be reasonably confident the output is right since
|
|
77
|
+
# behaviour variances that we care about across versions is neglible.
|
|
78
|
+
it 'is present' do
|
|
79
|
+
expect(generated_html).to be
|
|
80
|
+
end
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
describe 'produced HTML', :slow, :if => RUBY_VERSION >= '2.0.0' do
|
|
68
84
|
def build_and_verify_formatter_output
|
|
69
85
|
Dir.chdir(root) do
|
|
70
86
|
actual_doc = Nokogiri::HTML(generated_html)
|
|
@@ -88,15 +104,15 @@ module RSpec
|
|
|
88
104
|
end
|
|
89
105
|
end
|
|
90
106
|
|
|
91
|
-
it "
|
|
107
|
+
it "is identical to the one we designed manually" do
|
|
92
108
|
build_and_verify_formatter_output
|
|
93
109
|
end
|
|
94
110
|
|
|
95
111
|
context 'with mathn loaded' do
|
|
96
112
|
include MathnIntegrationSupport
|
|
97
113
|
|
|
98
|
-
it "
|
|
99
|
-
with_mathn_loaded{ build_and_verify_formatter_output }
|
|
114
|
+
it "is identical to the one we designed manually", :slow do
|
|
115
|
+
with_mathn_loaded { build_and_verify_formatter_output }
|
|
100
116
|
end
|
|
101
117
|
end
|
|
102
118
|
end
|
|
@@ -11,30 +11,28 @@ require 'rspec/core/reporter'
|
|
|
11
11
|
# it "shows the pending message if one was given"
|
|
12
12
|
# it "shows the seed if run was randomized"
|
|
13
13
|
# it "lists pending specs that were fixed"
|
|
14
|
-
describe RSpec::Core::Formatters::JsonFormatter do
|
|
15
|
-
|
|
16
|
-
let(:formatter) { RSpec::Core::Formatters::JsonFormatter.new(output) }
|
|
17
|
-
let(:config) { RSpec::Core::Configuration.new }
|
|
18
|
-
let(:reporter) { RSpec::Core::Reporter.new(config, formatter) }
|
|
14
|
+
RSpec.describe RSpec::Core::Formatters::JsonFormatter do
|
|
15
|
+
include FormatterSupport
|
|
19
16
|
|
|
20
17
|
it "outputs json (brittle high level functional test)" do
|
|
21
18
|
group = RSpec::Core::ExampleGroup.describe("one apiece") do
|
|
22
19
|
it("succeeds") { expect(1).to eq 1 }
|
|
23
20
|
it("fails") { fail "eek" }
|
|
24
|
-
it("pends") { pending "world peace" }
|
|
21
|
+
it("pends") { pending "world peace"; fail "eek" }
|
|
25
22
|
end
|
|
26
23
|
succeeding_line = __LINE__ - 4
|
|
27
24
|
failing_line = __LINE__ - 4
|
|
28
25
|
pending_line = __LINE__ - 4
|
|
29
26
|
|
|
30
27
|
now = Time.now
|
|
31
|
-
Time.
|
|
28
|
+
allow(Time).to receive(:now).and_return(now)
|
|
32
29
|
reporter.report(2) do |r|
|
|
33
30
|
group.run(r)
|
|
34
31
|
end
|
|
35
32
|
|
|
36
33
|
# grab the actual backtrace -- kind of a cheat
|
|
37
|
-
|
|
34
|
+
examples = formatter.output_hash[:examples]
|
|
35
|
+
failing_backtrace = examples[1][:exception][:backtrace]
|
|
38
36
|
this_file = relative_path(__FILE__)
|
|
39
37
|
|
|
40
38
|
expected = {
|
|
@@ -45,6 +43,7 @@ describe RSpec::Core::Formatters::JsonFormatter do
|
|
|
45
43
|
:status => "passed",
|
|
46
44
|
:file_path => this_file,
|
|
47
45
|
:line_number => succeeding_line,
|
|
46
|
+
:run_time => formatter.output_hash[:examples][0][:run_time]
|
|
48
47
|
},
|
|
49
48
|
{
|
|
50
49
|
:description => "fails",
|
|
@@ -52,7 +51,12 @@ describe RSpec::Core::Formatters::JsonFormatter do
|
|
|
52
51
|
:status => "failed",
|
|
53
52
|
:file_path => this_file,
|
|
54
53
|
:line_number => failing_line,
|
|
55
|
-
:
|
|
54
|
+
:run_time => formatter.output_hash[:examples][1][:run_time],
|
|
55
|
+
:exception => {
|
|
56
|
+
:class => "RuntimeError",
|
|
57
|
+
:message => "eek",
|
|
58
|
+
:backtrace => failing_backtrace
|
|
59
|
+
}
|
|
56
60
|
},
|
|
57
61
|
{
|
|
58
62
|
:description => "pends",
|
|
@@ -60,6 +64,7 @@ describe RSpec::Core::Formatters::JsonFormatter do
|
|
|
60
64
|
:status => "pending",
|
|
61
65
|
:file_path => this_file,
|
|
62
66
|
:line_number => pending_line,
|
|
67
|
+
:run_time => formatter.output_hash[:examples][2][:run_time]
|
|
63
68
|
},
|
|
64
69
|
],
|
|
65
70
|
:summary => {
|
|
@@ -76,7 +81,7 @@ describe RSpec::Core::Formatters::JsonFormatter do
|
|
|
76
81
|
|
|
77
82
|
describe "#stop" do
|
|
78
83
|
it "adds all examples to the output hash" do
|
|
79
|
-
|
|
84
|
+
send_notification :stop, null_notification
|
|
80
85
|
expect(formatter.output_hash[:examples]).not_to be_nil
|
|
81
86
|
end
|
|
82
87
|
end
|
|
@@ -84,43 +89,40 @@ describe RSpec::Core::Formatters::JsonFormatter do
|
|
|
84
89
|
describe "#close" do
|
|
85
90
|
it "outputs the results as a JSON string" do
|
|
86
91
|
expect(output.string).to eq ""
|
|
87
|
-
|
|
88
|
-
expect(output.string).to eq({}
|
|
92
|
+
send_notification :close, null_notification
|
|
93
|
+
expect(output.string).to eq("{}")
|
|
89
94
|
end
|
|
90
95
|
end
|
|
91
96
|
|
|
92
97
|
describe "#message" do
|
|
93
98
|
it "adds a message to the messages list" do
|
|
94
|
-
|
|
99
|
+
send_notification :message, message_notification("good job")
|
|
95
100
|
expect(formatter.output_hash[:messages]).to eq ["good job"]
|
|
96
101
|
end
|
|
97
102
|
end
|
|
98
103
|
|
|
99
104
|
describe "#dump_summary" do
|
|
100
105
|
it "adds summary info to the output hash" do
|
|
101
|
-
|
|
102
|
-
formatter.
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
end
|
|
106
|
+
send_notification :dump_summary, summary_notification(1.0, 10, 3, 4)
|
|
107
|
+
expect(formatter.output_hash[:summary]).to include(
|
|
108
|
+
:duration => 1.0, :example_count => 10, :failure_count => 3,
|
|
109
|
+
:pending_count => 4
|
|
110
|
+
)
|
|
107
111
|
summary_line = formatter.output_hash[:summary_line]
|
|
108
|
-
expect(summary_line).to eq "
|
|
112
|
+
expect(summary_line).to eq "10 examples, 3 failures, 4 pending"
|
|
109
113
|
end
|
|
110
114
|
end
|
|
111
115
|
|
|
112
|
-
describe "#dump_profile_slowest_examples" do
|
|
116
|
+
describe "#dump_profile_slowest_examples", :slow do
|
|
113
117
|
|
|
114
118
|
before do
|
|
115
119
|
group = RSpec::Core::ExampleGroup.describe("group") do
|
|
116
|
-
|
|
117
|
-
# the reported percent is 100%, not 0%.
|
|
118
|
-
example("example") { sleep 0.001 }
|
|
120
|
+
example("example") { }
|
|
119
121
|
end
|
|
120
|
-
group.run(
|
|
122
|
+
group.run(reporter)
|
|
121
123
|
|
|
122
|
-
formatter.
|
|
123
|
-
RSpec.configuration.
|
|
124
|
+
allow(formatter).to receive(:examples) { group.examples }
|
|
125
|
+
allow(RSpec.configuration).to receive(:profile_examples) { 10 }
|
|
124
126
|
end
|
|
125
127
|
|
|
126
128
|
it "names the example" do
|
|
@@ -139,23 +141,23 @@ describe RSpec::Core::Formatters::JsonFormatter do
|
|
|
139
141
|
end
|
|
140
142
|
end
|
|
141
143
|
|
|
142
|
-
describe "#dump_profile_slowest_example_groups" do
|
|
144
|
+
describe "#dump_profile_slowest_example_groups", :slow do
|
|
143
145
|
let(:group) do
|
|
144
146
|
RSpec::Core::ExampleGroup.describe("slow group") do
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
147
|
+
example("example") do |example|
|
|
148
|
+
# make it look slow without actually taking up precious time
|
|
149
|
+
example.clock = class_double(RSpec::Core::Time, :now => RSpec::Core::Time.now + 0.5)
|
|
150
|
+
end
|
|
148
151
|
end
|
|
149
152
|
end
|
|
150
|
-
let(:rpt) { double('reporter').as_null_object }
|
|
151
153
|
|
|
152
154
|
before do
|
|
153
|
-
RSpec.configuration.
|
|
154
|
-
group.run(
|
|
155
|
+
allow(RSpec.configuration).to receive(:profile_examples) { 10 }
|
|
156
|
+
group.run(reporter)
|
|
155
157
|
end
|
|
156
158
|
|
|
157
159
|
context "with one example group" do
|
|
158
|
-
before { formatter.
|
|
160
|
+
before { allow(formatter).to receive(:examples) { group.examples } }
|
|
159
161
|
|
|
160
162
|
it "doesn't profile a single example group" do
|
|
161
163
|
formatter.dump_profile_slowest_example_groups
|
|
@@ -163,15 +165,15 @@ describe RSpec::Core::Formatters::JsonFormatter do
|
|
|
163
165
|
end
|
|
164
166
|
end
|
|
165
167
|
|
|
166
|
-
context "with multiple example groups" do
|
|
168
|
+
context "with multiple example groups", :slow do
|
|
167
169
|
before do
|
|
168
170
|
group2 = RSpec::Core::ExampleGroup.describe("fast group") do
|
|
169
|
-
example("example 1") {
|
|
170
|
-
example("example 2") {
|
|
171
|
+
example("example 1") { }
|
|
172
|
+
example("example 2") { }
|
|
171
173
|
end
|
|
172
|
-
group2.run(
|
|
174
|
+
group2.run(reporter)
|
|
173
175
|
|
|
174
|
-
formatter.
|
|
176
|
+
allow(formatter).to receive(:examples) { group.examples + group2.examples }
|
|
175
177
|
end
|
|
176
178
|
|
|
177
179
|
it "provides the slowest example groups" do
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
require 'rspec/core/formatters/legacy_formatter'
|
|
3
|
+
require 'support/old_style_formatter_example'
|
|
4
|
+
require 'support/legacy_formatter_using_sub_classing_example'
|
|
5
|
+
|
|
6
|
+
RSpec.describe RSpec::Core::Formatters::LegacyFormatter do
|
|
7
|
+
include FormatterSupport
|
|
8
|
+
|
|
9
|
+
it 'can access attributes provided by base class accessors in #initialize' do
|
|
10
|
+
klass = Class.new(LegacyFormatterUsingSubClassing) do
|
|
11
|
+
def initialize(*args)
|
|
12
|
+
example_count
|
|
13
|
+
super
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
config.add_formatter klass
|
|
18
|
+
expect(config.formatters.first).to be_a(RSpec::Core::Formatters::LegacyFormatter)
|
|
19
|
+
expect(config.formatters.first.formatter).to be_a(klass)
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
[OldStyleFormatterExample, LegacyFormatterUsingSubClassing].each do |klass|
|
|
23
|
+
|
|
24
|
+
describe "#{klass}" do
|
|
25
|
+
let(:described_class) { klass }
|
|
26
|
+
|
|
27
|
+
describe "#start" do
|
|
28
|
+
it "notifies formatter of start" do
|
|
29
|
+
send_notification :start, count_notification(5)
|
|
30
|
+
expect(output.string).to include "Started 5 examples"
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
describe "#example_group_started" do
|
|
35
|
+
it "notifies formatter of example_group_started" do
|
|
36
|
+
send_notification :example_group_started, group_notification
|
|
37
|
+
expect(output.string).to include "Started Group"
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
describe "#example_group_finished" do
|
|
42
|
+
it "notifies formatter of example_group_finished" do
|
|
43
|
+
send_notification :example_group_finished, group_notification
|
|
44
|
+
expect(output.string).to include "Finished Group"
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
describe "#example_started" do
|
|
49
|
+
it "notifies formatter of example_started" do
|
|
50
|
+
send_notification :example_started, example_notification
|
|
51
|
+
expect(output.string).to include "Started Example"
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
describe "#example_passed" do
|
|
56
|
+
it "notifies formatter of example_passed" do
|
|
57
|
+
send_notification :example_passed, example_notification
|
|
58
|
+
expect(output.string).to include "."
|
|
59
|
+
end
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
describe "#example_pending" do
|
|
63
|
+
it "notifies formatter of example_pending" do
|
|
64
|
+
send_notification :example_pending, example_notification
|
|
65
|
+
expect(output.string).to include "P"
|
|
66
|
+
end
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
describe "#example_failed" do
|
|
70
|
+
it "notifies formatter of example_failed" do
|
|
71
|
+
send_notification :example_failed, example_notification
|
|
72
|
+
expect(output.string).to include "F"
|
|
73
|
+
end
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
describe "#message" do
|
|
77
|
+
it "notifies formatter of message" do
|
|
78
|
+
send_notification :message, message_notification("A Message")
|
|
79
|
+
expect(output.string).to include "A Message"
|
|
80
|
+
end
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
describe "#stop" do
|
|
84
|
+
it "notifies formatter of stop" do
|
|
85
|
+
send_notification :stop, null_notification
|
|
86
|
+
expect(output.string).to include "Stopped"
|
|
87
|
+
end
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
describe "#start_dump" do
|
|
91
|
+
it "notifies formatter of start_dump" do
|
|
92
|
+
send_notification :start_dump, null_notification
|
|
93
|
+
expect(output.string).to include "Dumping!"
|
|
94
|
+
end
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
describe "#dump_failures" do
|
|
98
|
+
it "notifies formatter of dump_failures" do
|
|
99
|
+
send_notification :dump_failures, null_notification
|
|
100
|
+
expect(output.string).to include "Failures:"
|
|
101
|
+
end
|
|
102
|
+
end
|
|
103
|
+
|
|
104
|
+
describe "#dump_summary" do
|
|
105
|
+
it "notifies formatter of dump_summary" do
|
|
106
|
+
duration, count, failures, pending = 3.5, 10, 3, 2
|
|
107
|
+
send_notification :dump_summary, summary_notification(duration, count, failures, pending)
|
|
108
|
+
expect(output.string).to(
|
|
109
|
+
match("Finished in 3.5").
|
|
110
|
+
and match("3/10 failed.").
|
|
111
|
+
and match("2 pending.")
|
|
112
|
+
)
|
|
113
|
+
end
|
|
114
|
+
end
|
|
115
|
+
|
|
116
|
+
describe "#dump_pending" do
|
|
117
|
+
it "notifies formatter of dump_pending" do
|
|
118
|
+
send_notification :dump_pending, null_notification
|
|
119
|
+
expect(output.string).to match "Pending:"
|
|
120
|
+
end
|
|
121
|
+
end
|
|
122
|
+
|
|
123
|
+
describe "#seed" do
|
|
124
|
+
it "notifies formatter of seed" do
|
|
125
|
+
send_notification :seed, seed_notification(17)
|
|
126
|
+
expect(output.string).to match "Randomized with seed 17"
|
|
127
|
+
end
|
|
128
|
+
end
|
|
129
|
+
|
|
130
|
+
describe "#close" do
|
|
131
|
+
it "notifies formatter of close" do
|
|
132
|
+
send_notification :close, null_notification
|
|
133
|
+
end
|
|
134
|
+
end
|
|
135
|
+
end
|
|
136
|
+
end
|
|
137
|
+
end
|
|
@@ -1,30 +1,43 @@
|
|
|
1
1
|
require 'spec_helper'
|
|
2
2
|
require 'rspec/core/formatters/progress_formatter'
|
|
3
3
|
|
|
4
|
-
describe RSpec::Core::Formatters::ProgressFormatter do
|
|
5
|
-
|
|
6
|
-
before do
|
|
7
|
-
@output = StringIO.new
|
|
8
|
-
@formatter = RSpec::Core::Formatters::ProgressFormatter.new(@output)
|
|
9
|
-
@formatter.start(2)
|
|
10
|
-
@formatter.stub(:color_enabled?).and_return(false)
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
it "produces line break on start dump" do
|
|
14
|
-
@formatter.start_dump
|
|
15
|
-
expect(@output.string).to eq("\n")
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
it "produces standard summary without pending when pending has a 0 count" do
|
|
19
|
-
@formatter.start_dump
|
|
20
|
-
@formatter.dump_summary(0.00001, 2, 0, 0)
|
|
21
|
-
expect(@output.string).to match(/2 examples, 0 failures/i)
|
|
22
|
-
expect(@output.string).not_to match(/0 pending/i)
|
|
23
|
-
end
|
|
24
|
-
|
|
25
|
-
it "pushes nothing on start" do
|
|
26
|
-
@formatter.start(4)
|
|
27
|
-
expect(@output.string).to eq("")
|
|
28
|
-
end
|
|
4
|
+
RSpec.describe RSpec::Core::Formatters::ProgressFormatter do
|
|
5
|
+
include FormatterSupport
|
|
29
6
|
|
|
7
|
+
before do
|
|
8
|
+
send_notification :start, count_notification(2)
|
|
9
|
+
allow(formatter).to receive(:color_enabled?).and_return(false)
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
it 'prints a . on example_passed' do
|
|
13
|
+
send_notification :example_passed, example_notification
|
|
14
|
+
expect(output.string).to eq(".")
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
it 'prints a * on example_pending' do
|
|
18
|
+
send_notification :example_pending, example_notification
|
|
19
|
+
expect(output.string).to eq("*")
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
it 'prints a F on example_failed' do
|
|
23
|
+
send_notification :example_failed, example_notification
|
|
24
|
+
expect(output.string).to eq("F")
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
it "produces standard summary without pending when pending has a 0 count" do
|
|
28
|
+
send_notification :dump_summary, summary_notification(0.00001, 2, 0, 0)
|
|
29
|
+
expect(output.string).to match(/^\n/)
|
|
30
|
+
expect(output.string).to match(/2 examples, 0 failures/i)
|
|
31
|
+
expect(output.string).not_to match(/0 pending/i)
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
it "pushes nothing on start" do
|
|
35
|
+
#start already sent
|
|
36
|
+
expect(output.string).to eq("")
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
it "pushes nothing on start dump" do
|
|
40
|
+
send_notification :start_dump, null_notification
|
|
41
|
+
expect(output.string).to eq("\n")
|
|
42
|
+
end
|
|
30
43
|
end
|