rspec-core 3.0.0.beta2 → 3.0.0.rc1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/.yardopts +1 -0
- data/Changelog.md +297 -57
- data/README.md +16 -13
- data/lib/rspec/core.rb +55 -84
- data/lib/rspec/core/backport_random.rb +35 -3
- data/lib/rspec/core/backtrace_formatter.rb +4 -13
- data/lib/rspec/core/configuration.rb +330 -114
- data/lib/rspec/core/configuration_options.rb +38 -22
- data/lib/rspec/core/drb.rb +111 -0
- data/lib/rspec/core/dsl.rb +8 -2
- data/lib/rspec/core/example.rb +203 -94
- data/lib/rspec/core/example_group.rb +344 -316
- data/lib/rspec/core/filter_manager.rb +135 -90
- data/lib/rspec/core/flat_map.rb +1 -0
- data/lib/rspec/core/formatters.rb +50 -14
- data/lib/rspec/core/formatters/base_formatter.rb +32 -138
- data/lib/rspec/core/formatters/base_text_formatter.rb +32 -253
- data/lib/rspec/core/formatters/console_codes.rb +65 -0
- data/lib/rspec/core/formatters/deprecation_formatter.rb +24 -15
- data/lib/rspec/core/formatters/documentation_formatter.rb +7 -10
- data/lib/rspec/core/formatters/helpers.rb +15 -9
- data/lib/rspec/core/formatters/html_formatter.rb +17 -16
- data/lib/rspec/core/formatters/html_printer.rb +1 -0
- data/lib/rspec/core/formatters/json_formatter.rb +18 -20
- data/lib/rspec/core/formatters/profile_formatter.rb +67 -0
- data/lib/rspec/core/formatters/progress_formatter.rb +6 -7
- data/lib/rspec/core/formatters/snippet_extractor.rb +8 -6
- data/lib/rspec/core/hooks.rb +131 -125
- data/lib/rspec/core/memoized_helpers.rb +31 -26
- data/lib/rspec/core/metadata.rb +277 -184
- data/lib/rspec/core/metadata_filter.rb +86 -0
- data/lib/rspec/core/minitest_assertions_adapter.rb +28 -0
- data/lib/rspec/core/mocking_adapters/flexmock.rb +1 -1
- data/lib/rspec/core/mocking_adapters/mocha.rb +1 -1
- data/lib/rspec/core/mocking_adapters/null.rb +1 -1
- data/lib/rspec/core/mocking_adapters/rr.rb +2 -1
- data/lib/rspec/core/mocking_adapters/rspec.rb +1 -1
- data/lib/rspec/core/notifications.rb +435 -24
- data/lib/rspec/core/option_parser.rb +16 -25
- data/lib/rspec/core/ordering.rb +3 -1
- data/lib/rspec/core/pending.rb +57 -33
- data/lib/rspec/core/project_initializer.rb +2 -0
- data/lib/rspec/core/project_initializer/spec_helper.rb +5 -4
- data/lib/rspec/core/rake_task.rb +45 -20
- data/lib/rspec/core/reporter.rb +50 -22
- data/lib/rspec/core/ruby_project.rb +1 -0
- data/lib/rspec/core/runner.rb +93 -39
- data/lib/rspec/core/shared_context.rb +7 -5
- data/lib/rspec/core/shared_example_group.rb +85 -77
- data/lib/rspec/core/test_unit_assertions_adapter.rb +30 -0
- data/lib/rspec/core/version.rb +3 -1
- data/lib/rspec/core/warnings.rb +35 -17
- data/lib/rspec/core/world.rb +57 -5
- metadata +56 -369
- metadata.gz.sig +3 -3
- data/features/README.md +0 -13
- data/features/Upgrade.md +0 -352
- data/features/command_line/README.md +0 -25
- data/features/command_line/dry_run.feature +0 -29
- data/features/command_line/example_name_option.feature +0 -97
- data/features/command_line/exit_status.feature +0 -82
- data/features/command_line/fail_fast.feature +0 -26
- data/features/command_line/format_option.feature +0 -75
- data/features/command_line/init.feature +0 -57
- data/features/command_line/line_number_appended_to_path.feature +0 -140
- data/features/command_line/line_number_option.feature +0 -58
- data/features/command_line/order.feature +0 -25
- data/features/command_line/pattern_option.feature +0 -49
- data/features/command_line/rake_task.feature +0 -122
- data/features/command_line/randomization.feature +0 -63
- data/features/command_line/require_option.feature +0 -43
- data/features/command_line/ruby.feature +0 -23
- data/features/command_line/tag.feature +0 -98
- data/features/command_line/warnings_option.feature +0 -29
- data/features/configuration/alias_example_to.feature +0 -39
- data/features/configuration/backtrace_exclusion_patterns.feature +0 -105
- data/features/configuration/custom_settings.feature +0 -84
- data/features/configuration/default_path.feature +0 -38
- data/features/configuration/deprecation_stream.feature +0 -58
- data/features/configuration/enable_global_dsl.feature +0 -54
- data/features/configuration/fail_fast.feature +0 -77
- data/features/configuration/failure_exit_code.feature +0 -36
- data/features/configuration/order_and_seed.feature +0 -3
- data/features/configuration/output_stream.feature +0 -24
- data/features/configuration/overriding_global_ordering.feature +0 -93
- data/features/configuration/pattern.feature +0 -38
- data/features/configuration/profile.feature +0 -220
- data/features/configuration/read_options_from_file.feature +0 -90
- data/features/configuration/run_all_when_everything_filtered.feature +0 -76
- data/features/example_groups/aliasing.feature +0 -48
- data/features/example_groups/basic_structure.feature +0 -55
- data/features/example_groups/shared_context.feature +0 -74
- data/features/example_groups/shared_examples.feature +0 -286
- data/features/expectation_framework_integration/configure_expectation_framework.feature +0 -102
- data/features/filtering/exclusion_filters.feature +0 -135
- data/features/filtering/if_and_unless.feature +0 -138
- data/features/filtering/inclusion_filters.feature +0 -101
- data/features/formatters/configurable_colors.feature +0 -31
- data/features/formatters/custom_formatter.feature +0 -68
- data/features/formatters/json_formatter.feature +0 -30
- data/features/formatters/regression_tests.feature +0 -95
- data/features/formatters/text_formatter.feature +0 -46
- data/features/helper_methods/arbitrary_methods.feature +0 -40
- data/features/helper_methods/let.feature +0 -50
- data/features/helper_methods/modules.feature +0 -146
- data/features/hooks/around_hooks.feature +0 -344
- data/features/hooks/before_and_after_hooks.feature +0 -427
- data/features/hooks/filtering.feature +0 -232
- data/features/metadata/current_example.feature +0 -56
- data/features/metadata/described_class.feature +0 -17
- data/features/metadata/user_defined.feature +0 -100
- data/features/mock_framework_integration/use_any_framework.feature +0 -106
- data/features/mock_framework_integration/use_flexmock.feature +0 -94
- data/features/mock_framework_integration/use_mocha.feature +0 -95
- data/features/mock_framework_integration/use_rr.feature +0 -96
- data/features/mock_framework_integration/use_rspec.feature +0 -95
- data/features/pending_and_skipped_examples/README.md +0 -3
- data/features/pending_and_skipped_examples/pending_examples.feature +0 -118
- data/features/pending_and_skipped_examples/skipped_examples.feature +0 -106
- data/features/spec_files/arbitrary_file_suffix.feature +0 -13
- data/features/step_definitions/additional_cli_steps.rb +0 -83
- data/features/subject/explicit_subject.feature +0 -101
- data/features/subject/implicit_subject.feature +0 -63
- data/features/subject/one_liner_syntax.feature +0 -71
- data/features/support/env.rb +0 -21
- data/features/support/require_expect_syntax_in_aruba_specs.rb +0 -16
- data/features/support/rubinius.rb +0 -6
- data/lib/rspec/core/command_line.rb +0 -35
- data/lib/rspec/core/drb_command_line.rb +0 -26
- data/lib/rspec/core/drb_options.rb +0 -87
- data/lib/rspec/core/formatters/legacy_formatter.rb +0 -227
- data/lib/rspec/core/shared_example_group/collection.rb +0 -27
- data/spec/command_line/order_spec.rb +0 -211
- data/spec/rspec/core/backtrace_formatter_spec.rb +0 -230
- data/spec/rspec/core/command_line_spec.rb +0 -112
- data/spec/rspec/core/command_line_spec_output.txt +0 -0
- data/spec/rspec/core/configuration_options_spec.rb +0 -409
- data/spec/rspec/core/configuration_spec.rb +0 -1479
- data/spec/rspec/core/drb_command_line_spec.rb +0 -102
- data/spec/rspec/core/drb_options_spec.rb +0 -193
- data/spec/rspec/core/dsl_spec.rb +0 -88
- data/spec/rspec/core/example_group_spec.rb +0 -1533
- data/spec/rspec/core/example_spec.rb +0 -642
- data/spec/rspec/core/filter_manager_spec.rb +0 -229
- data/spec/rspec/core/formatters/base_formatter_spec.rb +0 -64
- data/spec/rspec/core/formatters/base_text_formatter_spec.rb +0 -303
- data/spec/rspec/core/formatters/deprecation_formatter_spec.rb +0 -208
- data/spec/rspec/core/formatters/documentation_formatter_spec.rb +0 -75
- data/spec/rspec/core/formatters/helpers_spec.rb +0 -104
- data/spec/rspec/core/formatters/html_formatted-2.1.0.html +0 -392
- data/spec/rspec/core/formatters/html_formatted.html +0 -397
- data/spec/rspec/core/formatters/html_formatter_spec.rb +0 -122
- data/spec/rspec/core/formatters/json_formatter_spec.rb +0 -206
- data/spec/rspec/core/formatters/legacy_formatter_spec.rb +0 -137
- data/spec/rspec/core/formatters/progress_formatter_spec.rb +0 -43
- data/spec/rspec/core/formatters/snippet_extractor_spec.rb +0 -26
- data/spec/rspec/core/formatters_spec.rb +0 -120
- data/spec/rspec/core/hooks_filtering_spec.rb +0 -227
- data/spec/rspec/core/hooks_spec.rb +0 -294
- data/spec/rspec/core/memoized_helpers_spec.rb +0 -495
- data/spec/rspec/core/metadata_spec.rb +0 -491
- data/spec/rspec/core/option_parser_spec.rb +0 -262
- data/spec/rspec/core/ordering_spec.rb +0 -102
- data/spec/rspec/core/pending_example_spec.rb +0 -117
- data/spec/rspec/core/pending_spec.rb +0 -8
- data/spec/rspec/core/project_initializer_spec.rb +0 -73
- data/spec/rspec/core/rake_task_spec.rb +0 -146
- data/spec/rspec/core/random_spec.rb +0 -47
- data/spec/rspec/core/reporter_spec.rb +0 -155
- data/spec/rspec/core/resources/a_bar.rb +0 -0
- data/spec/rspec/core/resources/a_foo.rb +0 -0
- data/spec/rspec/core/resources/a_spec.rb +0 -1
- data/spec/rspec/core/resources/custom_example_group_runner.rb +0 -14
- data/spec/rspec/core/resources/formatter_specs.rb +0 -58
- data/spec/rspec/core/resources/utf8_encoded.rb +0 -8
- data/spec/rspec/core/rspec_matchers_spec.rb +0 -45
- data/spec/rspec/core/ruby_project_spec.rb +0 -26
- data/spec/rspec/core/runner_spec.rb +0 -151
- data/spec/rspec/core/shared_context_spec.rb +0 -102
- data/spec/rspec/core/shared_example_group/collection_spec.rb +0 -57
- data/spec/rspec/core/shared_example_group_spec.rb +0 -114
- data/spec/rspec/core/warnings_spec.rb +0 -29
- data/spec/rspec/core/world_spec.rb +0 -142
- data/spec/rspec/core_spec.rb +0 -91
- data/spec/spec_helper.rb +0 -160
- data/spec/support/config_options_helper.rb +0 -13
- data/spec/support/formatter_support.rb +0 -83
- data/spec/support/helper_methods.rb +0 -26
- data/spec/support/isolate_load_path_mutation.rb +0 -5
- data/spec/support/isolated_directory.rb +0 -10
- data/spec/support/isolated_home_directory.rb +0 -16
- data/spec/support/legacy_formatter_using_sub_classing_example.rb +0 -87
- data/spec/support/matchers.rb +0 -85
- data/spec/support/mathn_integration_support.rb +0 -12
- data/spec/support/old_style_formatter_example.rb +0 -69
- data/spec/support/shared_example_groups.rb +0 -13
- data/spec/support/spec_files.rb +0 -44
- data/spec/support/stderr_splitter.rb +0 -36
@@ -1,58 +0,0 @@
|
|
1
|
-
# Deliberately named _specs.rb to avoid being loaded except when specified
|
2
|
-
|
3
|
-
RSpec.describe "pending spec with no implementation" do
|
4
|
-
it "is pending"
|
5
|
-
end
|
6
|
-
|
7
|
-
RSpec.describe "pending command with block format" do
|
8
|
-
context "with content that would fail" do
|
9
|
-
it "is pending" do
|
10
|
-
pending
|
11
|
-
expect(1).to eq(2)
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
context "with content that would pass" do
|
16
|
-
it "fails" do
|
17
|
-
pending
|
18
|
-
expect(1).to eq(1)
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
RSpec.describe "passing spec" do
|
24
|
-
it "passes" do
|
25
|
-
expect(1).to eq(1)
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
RSpec.describe "failing spec" do
|
30
|
-
it "fails" do
|
31
|
-
expect(1).to eq(2)
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
RSpec.describe "a failing spec with odd backtraces" do
|
36
|
-
it "fails with a backtrace that has no file" do
|
37
|
-
require 'erb'
|
38
|
-
|
39
|
-
ERB.new("<%= raise 'foo' %>").result
|
40
|
-
end
|
41
|
-
|
42
|
-
it "fails with a backtrace containing an erb file" do
|
43
|
-
e = Exception.new
|
44
|
-
|
45
|
-
def e.backtrace
|
46
|
-
["/foo.html.erb:1:in `<main>': foo (RuntimeError)",
|
47
|
-
" from /lib/ruby/1.9.1/erb.rb:753:in `eval'"]
|
48
|
-
end
|
49
|
-
|
50
|
-
def e.message
|
51
|
-
# Redefining message steps around this behaviour
|
52
|
-
# on JRuby: http://jira.codehaus.org/browse/JRUBY-5637
|
53
|
-
self.class.name
|
54
|
-
end
|
55
|
-
|
56
|
-
raise e
|
57
|
-
end
|
58
|
-
end
|
@@ -1,45 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
module RSpec::Matchers
|
4
|
-
def __method_with_super
|
5
|
-
super
|
6
|
-
end
|
7
|
-
|
8
|
-
module ModThatIncludesMatchers
|
9
|
-
include RSpec::Matchers
|
10
|
-
end
|
11
|
-
|
12
|
-
RSpec.configure do |c|
|
13
|
-
c.include RSpec::Matchers, :include_rspec_matchers => true
|
14
|
-
c.include ModThatIncludesMatchers, :include_mod_that_includes_rspec_matchers => true
|
15
|
-
end
|
16
|
-
|
17
|
-
RSpec.describe self do
|
18
|
-
shared_examples_for "a normal module with a method that supers" do
|
19
|
-
it "raises the expected error (and not SystemStackError)" do
|
20
|
-
expect { __method_with_super }.to raise_error(NoMethodError) # there is no __method_with_super in an ancestor
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
it_behaves_like "a normal module with a method that supers"
|
25
|
-
|
26
|
-
context "when RSpec::Matchers has been included in an example group" do
|
27
|
-
include RSpec::Matchers
|
28
|
-
it_behaves_like "a normal module with a method that supers"
|
29
|
-
end
|
30
|
-
|
31
|
-
context "when a module that includes RSpec::Matchers has been included in an example group" do
|
32
|
-
include RSpec::Matchers::ModThatIncludesMatchers
|
33
|
-
it_behaves_like "a normal module with a method that supers"
|
34
|
-
end
|
35
|
-
|
36
|
-
context "when RSpec::Matchers is included via configuration", :include_rspec_matchers => true do
|
37
|
-
it_behaves_like "a normal module with a method that supers"
|
38
|
-
end
|
39
|
-
|
40
|
-
context "when RSpec::Matchers is included in a module that is included via configuration", :include_mod_that_includes_rspec_matchers => true do
|
41
|
-
it_behaves_like "a normal module with a method that supers"
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
@@ -1,26 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
module RSpec
|
4
|
-
module Core
|
5
|
-
RSpec.describe RubyProject do
|
6
|
-
|
7
|
-
describe "#determine_root" do
|
8
|
-
|
9
|
-
context "with ancestor containing spec directory" do
|
10
|
-
it "returns ancestor containing the spec directory" do
|
11
|
-
allow(RubyProject).to receive(:ascend_until).and_return('foodir')
|
12
|
-
expect(RubyProject.determine_root).to eq("foodir")
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
context "without ancestor containing spec directory" do
|
17
|
-
it "returns current working directory" do
|
18
|
-
allow(RubyProject).to receive(:find_first_parent_containing).and_return(nil)
|
19
|
-
expect(RubyProject.determine_root).to eq(".")
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
@@ -1,151 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'rspec/core/drb_command_line'
|
3
|
-
|
4
|
-
module RSpec::Core
|
5
|
-
RSpec.describe Runner do
|
6
|
-
describe 'invocation' do
|
7
|
-
before do
|
8
|
-
# Simulate invoking the suite like exe/rspec does.
|
9
|
-
allow(RSpec::Core::Runner).to receive(:run)
|
10
|
-
RSpec::Core::Runner.invoke
|
11
|
-
end
|
12
|
-
|
13
|
-
it 'does not autorun after having been invoked' do
|
14
|
-
expect(RSpec::Core::Runner).not_to receive(:at_exit)
|
15
|
-
RSpec::Core::Runner.autorun
|
16
|
-
end
|
17
|
-
|
18
|
-
it 'prints a warning when autorun is attempted' do
|
19
|
-
expect_deprecation_with_call_site(__FILE__, __LINE__ + 1)
|
20
|
-
RSpec::Core::Runner.autorun
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
describe 'at_exit' do
|
25
|
-
it 'sets an at_exit hook if none is already set' do
|
26
|
-
allow(RSpec::Core::Runner).to receive(:autorun_disabled?).and_return(false)
|
27
|
-
allow(RSpec::Core::Runner).to receive(:installed_at_exit?).and_return(false)
|
28
|
-
allow(RSpec::Core::Runner).to receive(:running_in_drb?).and_return(false)
|
29
|
-
allow(RSpec::Core::Runner).to receive(:invoke)
|
30
|
-
expect(RSpec::Core::Runner).to receive(:at_exit)
|
31
|
-
RSpec::Core::Runner.autorun
|
32
|
-
end
|
33
|
-
|
34
|
-
it 'does not set the at_exit hook if it is already set' do
|
35
|
-
allow(RSpec::Core::Runner).to receive(:autorun_disabled?).and_return(false)
|
36
|
-
allow(RSpec::Core::Runner).to receive(:installed_at_exit?).and_return(true)
|
37
|
-
allow(RSpec::Core::Runner).to receive(:running_in_drb?).and_return(false)
|
38
|
-
expect(RSpec::Core::Runner).to receive(:at_exit).never
|
39
|
-
RSpec::Core::Runner.autorun
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
|
-
# This is intermittently slow because this method calls out to the network
|
44
|
-
# interface.
|
45
|
-
describe "#running_in_drb?", :slow do
|
46
|
-
it "returns true if drb server is started with 127.0.0.1" do
|
47
|
-
allow(::DRb).to receive(:current_server).and_return(double(:uri => "druby://127.0.0.1:0000/"))
|
48
|
-
|
49
|
-
expect(RSpec::Core::Runner.running_in_drb?).to be_truthy
|
50
|
-
end
|
51
|
-
|
52
|
-
it "returns true if drb server is started with localhost" do
|
53
|
-
allow(::DRb).to receive(:current_server).and_return(double(:uri => "druby://localhost:0000/"))
|
54
|
-
|
55
|
-
expect(RSpec::Core::Runner.running_in_drb?).to be_truthy
|
56
|
-
end
|
57
|
-
|
58
|
-
it "returns true if drb server is started with another local ip address" do
|
59
|
-
allow(::DRb).to receive(:current_server).and_return(double(:uri => "druby://192.168.0.1:0000/"))
|
60
|
-
allow(::IPSocket).to receive(:getaddress).and_return("192.168.0.1")
|
61
|
-
|
62
|
-
expect(RSpec::Core::Runner.running_in_drb?).to be_truthy
|
63
|
-
end
|
64
|
-
|
65
|
-
it "returns false if no drb server is running" do
|
66
|
-
allow(::DRb).to receive(:current_server).and_raise(::DRb::DRbServerNotFound)
|
67
|
-
|
68
|
-
expect(RSpec::Core::Runner.running_in_drb?).to be_falsey
|
69
|
-
end
|
70
|
-
end
|
71
|
-
|
72
|
-
describe "#invoke" do
|
73
|
-
let(:runner) { RSpec::Core::Runner }
|
74
|
-
|
75
|
-
it "runs the specs via #run" do
|
76
|
-
allow(runner).to receive(:exit)
|
77
|
-
expect(runner).to receive(:run)
|
78
|
-
runner.invoke
|
79
|
-
end
|
80
|
-
|
81
|
-
it "doesn't exit on success" do
|
82
|
-
allow(runner).to receive(:run) { 0 }
|
83
|
-
expect(runner).to_not receive(:exit)
|
84
|
-
runner.invoke
|
85
|
-
end
|
86
|
-
|
87
|
-
it "exits with #run's status on failure" do
|
88
|
-
allow(runner).to receive(:run) { 123 }
|
89
|
-
expect(runner).to receive(:exit).with(123)
|
90
|
-
runner.invoke
|
91
|
-
end
|
92
|
-
end
|
93
|
-
|
94
|
-
describe "#run" do
|
95
|
-
let(:err) { StringIO.new }
|
96
|
-
let(:out) { StringIO.new }
|
97
|
-
|
98
|
-
it "tells RSpec to reset" do
|
99
|
-
allow(CommandLine).to receive_messages(:new => double.as_null_object)
|
100
|
-
allow(RSpec.configuration).to receive_messages(:files_to_run => [], :warn => nil)
|
101
|
-
expect(RSpec).to receive(:reset)
|
102
|
-
RSpec::Core::Runner.run([], err, out)
|
103
|
-
end
|
104
|
-
|
105
|
-
context "with --drb or -X" do
|
106
|
-
before(:each) do
|
107
|
-
@options = RSpec::Core::ConfigurationOptions.new(%w[--drb --drb-port 8181 --color])
|
108
|
-
allow(RSpec::Core::ConfigurationOptions).to receive(:new) { @options }
|
109
|
-
end
|
110
|
-
|
111
|
-
def run_specs
|
112
|
-
RSpec::Core::Runner.run(%w[ --drb ], err, out)
|
113
|
-
end
|
114
|
-
|
115
|
-
context 'and a DRb server is running' do
|
116
|
-
it "builds a DRbCommandLine and runs the specs" do
|
117
|
-
drb_proxy = double(RSpec::Core::DRbCommandLine, :run => true)
|
118
|
-
expect(drb_proxy).to receive(:run).with(err, out)
|
119
|
-
|
120
|
-
expect(RSpec::Core::DRbCommandLine).to receive(:new).and_return(drb_proxy)
|
121
|
-
|
122
|
-
run_specs
|
123
|
-
end
|
124
|
-
end
|
125
|
-
|
126
|
-
context 'and a DRb server is not running' do
|
127
|
-
before(:each) do
|
128
|
-
expect(RSpec::Core::DRbCommandLine).to receive(:new).and_raise(DRb::DRbConnError)
|
129
|
-
end
|
130
|
-
|
131
|
-
it "outputs a message" do
|
132
|
-
allow(RSpec.configuration).to receive(:files_to_run) { [] }
|
133
|
-
expect(err).to receive(:puts).with(
|
134
|
-
"No DRb server is running. Running in local process instead ..."
|
135
|
-
)
|
136
|
-
run_specs
|
137
|
-
end
|
138
|
-
|
139
|
-
it "builds a CommandLine and runs the specs" do
|
140
|
-
process_proxy = double(RSpec::Core::CommandLine, :run => 0)
|
141
|
-
expect(process_proxy).to receive(:run).with(err, out)
|
142
|
-
|
143
|
-
expect(RSpec::Core::CommandLine).to receive(:new).and_return(process_proxy)
|
144
|
-
|
145
|
-
run_specs
|
146
|
-
end
|
147
|
-
end
|
148
|
-
end
|
149
|
-
end
|
150
|
-
end
|
151
|
-
end
|
@@ -1,102 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
|
3
|
-
RSpec.describe RSpec::SharedContext do
|
4
|
-
it "is accessible as RSpec::Core::SharedContext" do
|
5
|
-
RSpec::Core::SharedContext
|
6
|
-
end
|
7
|
-
|
8
|
-
it "is accessible as RSpec::SharedContext" do
|
9
|
-
RSpec::SharedContext
|
10
|
-
end
|
11
|
-
|
12
|
-
it "supports before and after hooks" do
|
13
|
-
before_all_hook = false
|
14
|
-
before_each_hook = false
|
15
|
-
after_each_hook = false
|
16
|
-
after_all_hook = false
|
17
|
-
shared = Module.new do
|
18
|
-
extend RSpec::SharedContext
|
19
|
-
before(:all) { before_all_hook = true }
|
20
|
-
before(:each) { before_each_hook = true }
|
21
|
-
after(:each) { after_each_hook = true }
|
22
|
-
after(:all) { after_all_hook = true }
|
23
|
-
end
|
24
|
-
group = RSpec::Core::ExampleGroup.describe do
|
25
|
-
include shared
|
26
|
-
example { }
|
27
|
-
end
|
28
|
-
|
29
|
-
group.run
|
30
|
-
|
31
|
-
expect(before_all_hook).to be_truthy
|
32
|
-
expect(before_each_hook).to be_truthy
|
33
|
-
expect(after_each_hook).to be_truthy
|
34
|
-
expect(after_all_hook).to be_truthy
|
35
|
-
end
|
36
|
-
|
37
|
-
include RSpec::Core::SharedExampleGroup::TopLevelDSL
|
38
|
-
|
39
|
-
it "runs the before each hooks in configuration before those of the shared context" do
|
40
|
-
ordered_hooks = []
|
41
|
-
RSpec.configure do |c|
|
42
|
-
c.before(:each) { ordered_hooks << "config" }
|
43
|
-
end
|
44
|
-
|
45
|
-
RSpec.shared_context("before each stuff", :example => :before_each_hook_order) do
|
46
|
-
before(:each) { ordered_hooks << "shared_context"}
|
47
|
-
end
|
48
|
-
|
49
|
-
group = RSpec.describe :example => :before_each_hook_order do
|
50
|
-
before(:each) { ordered_hooks << "example_group" }
|
51
|
-
example {}
|
52
|
-
end
|
53
|
-
|
54
|
-
group.run
|
55
|
-
|
56
|
-
expect(ordered_hooks).to be == ["config", "shared_context", "example_group"]
|
57
|
-
end
|
58
|
-
|
59
|
-
it "supports let" do
|
60
|
-
shared = Module.new do
|
61
|
-
extend RSpec::SharedContext
|
62
|
-
let(:foo) { 'foo' }
|
63
|
-
end
|
64
|
-
group = RSpec.describe do
|
65
|
-
include shared
|
66
|
-
end
|
67
|
-
|
68
|
-
expect(group.new.foo).to eq('foo')
|
69
|
-
end
|
70
|
-
|
71
|
-
it 'supports explicit subjects' do
|
72
|
-
shared = Module.new do
|
73
|
-
extend RSpec::SharedContext
|
74
|
-
subject { 17 }
|
75
|
-
end
|
76
|
-
|
77
|
-
group = RSpec::Core::ExampleGroup.describe do
|
78
|
-
include shared
|
79
|
-
end
|
80
|
-
|
81
|
-
expect(group.new.subject).to eq(17)
|
82
|
-
end
|
83
|
-
|
84
|
-
%w[describe context].each do |method_name|
|
85
|
-
it "supports nested example groups using #{method_name}" do
|
86
|
-
shared = Module.new do
|
87
|
-
extend RSpec::SharedContext
|
88
|
-
send(method_name, "nested using describe") do
|
89
|
-
example {}
|
90
|
-
end
|
91
|
-
end
|
92
|
-
group = RSpec::Core::ExampleGroup.describe do
|
93
|
-
include shared
|
94
|
-
end
|
95
|
-
|
96
|
-
group.run
|
97
|
-
|
98
|
-
expect(group.children.length).to eq(1)
|
99
|
-
expect(group.children.first.examples.length).to eq(1)
|
100
|
-
end
|
101
|
-
end
|
102
|
-
end
|
@@ -1,57 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
module RSpec::Core::SharedExampleGroup
|
4
|
-
RSpec.describe Collection do
|
5
|
-
|
6
|
-
# this represents:
|
7
|
-
#
|
8
|
-
# shared_examples "top level group"
|
9
|
-
#
|
10
|
-
# context do
|
11
|
-
# shared_examples "nested level one"
|
12
|
-
# end
|
13
|
-
#
|
14
|
-
# context do
|
15
|
-
# shared_examples "nested level two"
|
16
|
-
# end
|
17
|
-
#
|
18
|
-
let(:examples) do
|
19
|
-
Hash.new { |hash,k| hash[k] = Hash.new }.tap do |hash|
|
20
|
-
hash["main"] = { "top level group" => example_1 }
|
21
|
-
hash["nested 1"] = { "nested level one" => example_2 }
|
22
|
-
hash["nested 2"] = { "nested level two" => example_3 }
|
23
|
-
end
|
24
|
-
end
|
25
|
-
(1..3).each { |num| let("example_#{num}") { double "example #{num}" } }
|
26
|
-
|
27
|
-
context 'setup with one source, which is the top level' do
|
28
|
-
|
29
|
-
let(:collection) { Collection.new ['main'], examples }
|
30
|
-
|
31
|
-
it 'fetches examples from the top level' do
|
32
|
-
expect(collection['top level group']).to eq example_1
|
33
|
-
end
|
34
|
-
|
35
|
-
it 'wont fetches examples across the nested context' do
|
36
|
-
expect(collection['nested level two']).to eq nil
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
context 'setup with multiple sources' do
|
41
|
-
|
42
|
-
let(:collection) { Collection.new ['main','nested 1'], examples }
|
43
|
-
|
44
|
-
it 'fetches examples from the context' do
|
45
|
-
expect(collection['nested level one']).to eq example_2
|
46
|
-
end
|
47
|
-
|
48
|
-
it 'fetches examples from main' do
|
49
|
-
expect(collection['top level group']).to eq example_1
|
50
|
-
end
|
51
|
-
|
52
|
-
it 'wont fetch examples across the nested context' do
|
53
|
-
expect(collection['nested level two']).to eq nil
|
54
|
-
end
|
55
|
-
end
|
56
|
-
end
|
57
|
-
end
|