rspec-core 3.0.0.beta2 → 3.0.0.rc1
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.
- 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,114 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'rspec/support/spec/in_sub_process'
|
3
|
-
|
4
|
-
module RandomTopLevelModule
|
5
|
-
def self.setup!
|
6
|
-
RSpec.shared_examples_for("top level in module") {}
|
7
|
-
end
|
8
|
-
end
|
9
|
-
|
10
|
-
module RSpec::Core
|
11
|
-
RSpec.describe SharedExampleGroup do
|
12
|
-
include RSpec::Support::InSubProcess
|
13
|
-
|
14
|
-
ExampleModule = Module.new
|
15
|
-
ExampleClass = Class.new
|
16
|
-
|
17
|
-
it 'does not add a bunch of private methods to Module' do
|
18
|
-
seg_methods = RSpec::Core::SharedExampleGroup.private_instance_methods
|
19
|
-
expect(Module.private_methods & seg_methods).to eq([])
|
20
|
-
end
|
21
|
-
|
22
|
-
module SharedExampleGroup
|
23
|
-
RSpec.describe Registry do
|
24
|
-
it "can safely be reset when there aren't any shared groups" do
|
25
|
-
expect { Registry.new.clear }.to_not raise_error
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
before(:all) do
|
31
|
-
# this is a work around as SharedExampleGroup is not world safe
|
32
|
-
RandomTopLevelModule.setup!
|
33
|
-
end
|
34
|
-
|
35
|
-
%w[share_examples_for shared_examples_for shared_examples shared_context].each do |shared_method_name|
|
36
|
-
describe shared_method_name do
|
37
|
-
let(:group) { ExampleGroup.describe('example group') }
|
38
|
-
|
39
|
-
define_method :define_shared_group do |*args, &block|
|
40
|
-
group.send(shared_method_name, *args, &block)
|
41
|
-
end
|
42
|
-
|
43
|
-
it "is exposed to the global namespace when expose_dsl_globally is enabled" do
|
44
|
-
in_sub_process do
|
45
|
-
RSpec.configuration.expose_dsl_globally = true
|
46
|
-
expect(Kernel).to respond_to(shared_method_name)
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
50
|
-
it "is not exposed to the global namespace when monkey patching is disabled" do
|
51
|
-
expect(Kernel).to_not respond_to(shared_method_name)
|
52
|
-
end
|
53
|
-
|
54
|
-
it "displays a warning when adding a second shared example group with the same name" do
|
55
|
-
group.send(shared_method_name, 'some shared group') {}
|
56
|
-
original_declaration = [__FILE__, __LINE__ - 1].join(':')
|
57
|
-
|
58
|
-
warning = nil
|
59
|
-
allow(::Kernel).to receive(:warn) { |msg| warning = msg }
|
60
|
-
|
61
|
-
group.send(shared_method_name, 'some shared group') {}
|
62
|
-
second_declaration = [__FILE__, __LINE__ - 1].join(':')
|
63
|
-
expect(warning).to include('some shared group', original_declaration, second_declaration)
|
64
|
-
expect(warning).to_not include 'Called from'
|
65
|
-
end
|
66
|
-
|
67
|
-
it 'works with top level defined examples in modules' do
|
68
|
-
expect(RSpec::configuration.reporter).to_not receive(:deprecation)
|
69
|
-
ExampleGroup.describe('example group') { include_context 'top level in module' }
|
70
|
-
end
|
71
|
-
|
72
|
-
["name", :name, ExampleModule, ExampleClass].each do |object|
|
73
|
-
type = object.class.name.downcase
|
74
|
-
context "given a #{type}" do
|
75
|
-
it "captures the given #{type} and block in the collection of shared example groups" do
|
76
|
-
implementation = lambda {}
|
77
|
-
define_shared_group(object, &implementation)
|
78
|
-
expect(SharedExampleGroup.registry.shared_example_groups[group][object]).to eq implementation
|
79
|
-
end
|
80
|
-
end
|
81
|
-
end
|
82
|
-
|
83
|
-
context "given a hash" do
|
84
|
-
it "delegates include on configuration" do
|
85
|
-
implementation = Proc.new { def bar; 'bar'; end }
|
86
|
-
define_shared_group(:foo => :bar, &implementation)
|
87
|
-
a = RSpec.configuration.include_or_extend_modules.first
|
88
|
-
expect(a[0]).to eq(:include)
|
89
|
-
expect(Class.new.send(:include, a[1]).new.bar).to eq('bar')
|
90
|
-
expect(a[2]).to eq(:foo => :bar)
|
91
|
-
end
|
92
|
-
end
|
93
|
-
|
94
|
-
context "given a string and a hash" do
|
95
|
-
it "captures the given string and block in the World's collection of shared example groups" do
|
96
|
-
implementation = lambda {}
|
97
|
-
define_shared_group("name", :foo => :bar, &implementation)
|
98
|
-
expect(SharedExampleGroup.registry.shared_example_groups[group]["name"]).to eq implementation
|
99
|
-
end
|
100
|
-
|
101
|
-
it "delegates include on configuration" do
|
102
|
-
implementation = Proc.new { def bar; 'bar'; end }
|
103
|
-
define_shared_group("name", :foo => :bar, &implementation)
|
104
|
-
a = RSpec.configuration.include_or_extend_modules.first
|
105
|
-
expect(a[0]).to eq(:include)
|
106
|
-
expect(Class.new.send(:include, a[1]).new.bar).to eq('bar')
|
107
|
-
expect(a[2]).to eq(:foo => :bar)
|
108
|
-
end
|
109
|
-
end
|
110
|
-
end
|
111
|
-
end
|
112
|
-
end
|
113
|
-
end
|
114
|
-
|
@@ -1,29 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
|
3
|
-
RSpec.describe "rspec warnings and deprecations" do
|
4
|
-
|
5
|
-
describe "#deprecate" do
|
6
|
-
it "passes the hash to the reporter" do
|
7
|
-
expect(RSpec.configuration.reporter).to receive(:deprecation).with(hash_including :deprecated => "deprecated_method", :replacement => "replacement")
|
8
|
-
RSpec.deprecate("deprecated_method", :replacement => "replacement")
|
9
|
-
end
|
10
|
-
|
11
|
-
it "adds the call site" do
|
12
|
-
expect_deprecation_with_call_site(__FILE__, __LINE__ + 1)
|
13
|
-
RSpec.deprecate("deprecated_method")
|
14
|
-
end
|
15
|
-
|
16
|
-
it "doesn't override a passed call site" do
|
17
|
-
expect_deprecation_with_call_site("some_file.rb", 17)
|
18
|
-
RSpec.deprecate("deprecated_method", :call_site => "/some_file.rb:17")
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
describe "#warn_deprecation" do
|
23
|
-
it "puts message in a hash" do
|
24
|
-
expect(RSpec.configuration.reporter).to receive(:deprecation).with(hash_including :message => "this is the message")
|
25
|
-
RSpec.warn_deprecation("this is the message")
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
end
|
@@ -1,142 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
class Bar; end
|
4
|
-
class Foo; end
|
5
|
-
|
6
|
-
module RSpec::Core
|
7
|
-
|
8
|
-
RSpec.describe RSpec::Core::World do
|
9
|
-
let(:configuration) { RSpec::Core::Configuration.new }
|
10
|
-
let(:world) { RSpec::Core::World.new(configuration) }
|
11
|
-
|
12
|
-
describe '#reset' do
|
13
|
-
it 'clears #example_groups' do
|
14
|
-
world.example_groups << :example_group
|
15
|
-
world.reset
|
16
|
-
expect(world.example_groups).to be_empty
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
describe "#example_groups" do
|
21
|
-
it "contains all registered example groups" do
|
22
|
-
group = RSpec::Core::ExampleGroup.describe("group"){}
|
23
|
-
world.register(group)
|
24
|
-
expect(world.example_groups).to include(group)
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
describe "#preceding_declaration_line (again)" do
|
29
|
-
let(:group) do
|
30
|
-
RSpec::Core::ExampleGroup.describe("group") do
|
31
|
-
|
32
|
-
example("example") {}
|
33
|
-
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
let(:second_group) do
|
38
|
-
RSpec::Core::ExampleGroup.describe("second_group") do
|
39
|
-
|
40
|
-
example("second_example") {}
|
41
|
-
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
let(:group_declaration_line) { group.metadata[:example_group][:line_number] }
|
46
|
-
let(:example_declaration_line) { group_declaration_line + 2 }
|
47
|
-
|
48
|
-
context "with one example" do
|
49
|
-
before { world.register(group) }
|
50
|
-
|
51
|
-
it "returns nil if no example or group precedes the line" do
|
52
|
-
expect(world.preceding_declaration_line(group_declaration_line - 1)).to be_nil
|
53
|
-
end
|
54
|
-
|
55
|
-
it "returns the argument line number if a group starts on that line" do
|
56
|
-
expect(world.preceding_declaration_line(group_declaration_line)).to eq(group_declaration_line)
|
57
|
-
end
|
58
|
-
|
59
|
-
it "returns the argument line number if an example starts on that line" do
|
60
|
-
expect(world.preceding_declaration_line(example_declaration_line)).to eq(example_declaration_line)
|
61
|
-
end
|
62
|
-
|
63
|
-
it "returns line number of a group that immediately precedes the argument line" do
|
64
|
-
expect(world.preceding_declaration_line(group_declaration_line + 1)).to eq(group_declaration_line)
|
65
|
-
end
|
66
|
-
|
67
|
-
it "returns line number of an example that immediately precedes the argument line" do
|
68
|
-
expect(world.preceding_declaration_line(example_declaration_line + 1)).to eq(example_declaration_line)
|
69
|
-
end
|
70
|
-
end
|
71
|
-
|
72
|
-
context "with two exaples and the second example is registre first" do
|
73
|
-
let(:second_group_declaration_line) { second_group.metadata[:example_group][:line_number] }
|
74
|
-
|
75
|
-
before do
|
76
|
-
world.register(second_group)
|
77
|
-
world.register(group)
|
78
|
-
end
|
79
|
-
|
80
|
-
it 'return line number of group if a group start on that line' do
|
81
|
-
expect(world.preceding_declaration_line(second_group_declaration_line)).to eq(second_group_declaration_line)
|
82
|
-
end
|
83
|
-
end
|
84
|
-
end
|
85
|
-
|
86
|
-
describe "#announce_filters" do
|
87
|
-
let(:reporter) { double('reporter').as_null_object }
|
88
|
-
before { allow(world).to receive(:reporter) { reporter } }
|
89
|
-
|
90
|
-
context "with no examples" do
|
91
|
-
before { allow(world).to receive(:example_count) { 0 } }
|
92
|
-
|
93
|
-
context "with no filters" do
|
94
|
-
it "announces" do
|
95
|
-
expect(reporter).to receive(:message).
|
96
|
-
with("No examples found.")
|
97
|
-
world.announce_filters
|
98
|
-
end
|
99
|
-
end
|
100
|
-
|
101
|
-
context "with an inclusion filter" do
|
102
|
-
it "announces" do
|
103
|
-
configuration.filter_run_including :foo => 'bar'
|
104
|
-
expect(reporter).to receive(:message).
|
105
|
-
with(/All examples were filtered out/)
|
106
|
-
world.announce_filters
|
107
|
-
end
|
108
|
-
end
|
109
|
-
|
110
|
-
context "with an inclusion filter and run_all_when_everything_filtered" do
|
111
|
-
it "announces" do
|
112
|
-
allow(configuration).to receive(:run_all_when_everything_filtered?) { true }
|
113
|
-
configuration.filter_run_including :foo => 'bar'
|
114
|
-
expect(reporter).to receive(:message).
|
115
|
-
with(/All examples were filtered out/)
|
116
|
-
world.announce_filters
|
117
|
-
end
|
118
|
-
end
|
119
|
-
|
120
|
-
context "with an exclusion filter" do
|
121
|
-
it "announces" do
|
122
|
-
configuration.filter_run_excluding :foo => 'bar'
|
123
|
-
expect(reporter).to receive(:message).
|
124
|
-
with(/All examples were filtered out/)
|
125
|
-
world.announce_filters
|
126
|
-
end
|
127
|
-
end
|
128
|
-
end
|
129
|
-
|
130
|
-
context "with examples" do
|
131
|
-
before { allow(world).to receive(:example_count) { 1 } }
|
132
|
-
|
133
|
-
context "with no filters" do
|
134
|
-
it "does not announce" do
|
135
|
-
expect(reporter).not_to receive(:message)
|
136
|
-
world.announce_filters
|
137
|
-
end
|
138
|
-
end
|
139
|
-
end
|
140
|
-
end
|
141
|
-
end
|
142
|
-
end
|
data/spec/rspec/core_spec.rb
DELETED
@@ -1,91 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
RSpec.describe RSpec do
|
4
|
-
describe "::configuration" do
|
5
|
-
it "returns the same object every time" do
|
6
|
-
expect(RSpec.configuration).to equal(RSpec.configuration)
|
7
|
-
end
|
8
|
-
end
|
9
|
-
|
10
|
-
describe "::configuration=" do
|
11
|
-
it "sets the configuration object" do
|
12
|
-
configuration = RSpec::Core::Configuration.new
|
13
|
-
|
14
|
-
RSpec.configuration = configuration
|
15
|
-
|
16
|
-
expect(RSpec.configuration).to equal(configuration)
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
describe "::configure" do
|
21
|
-
it "yields the current configuration" do
|
22
|
-
RSpec.configure do |config|
|
23
|
-
expect(config).to equal(RSpec::configuration)
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
describe "::world" do
|
29
|
-
it "returns the same object every time" do
|
30
|
-
expect(RSpec.world).to equal(RSpec.world)
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
describe "::world=" do
|
35
|
-
it "sets the world object" do
|
36
|
-
world = RSpec::Core::World.new
|
37
|
-
|
38
|
-
RSpec.world = world
|
39
|
-
|
40
|
-
expect(RSpec.world).to equal(world)
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
describe ".current_example" do
|
45
|
-
it "sets the example being executed" do
|
46
|
-
group = RSpec::Core::ExampleGroup.describe("an example group")
|
47
|
-
example = group.example("an example")
|
48
|
-
|
49
|
-
RSpec.current_example = example
|
50
|
-
expect(RSpec.current_example).to be(example)
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
|
-
describe "::reset" do
|
55
|
-
it "resets the configuration and world objects" do
|
56
|
-
config_before_reset = RSpec.configuration
|
57
|
-
world_before_reset = RSpec.world
|
58
|
-
|
59
|
-
RSpec.reset
|
60
|
-
|
61
|
-
expect(RSpec.configuration).not_to equal(config_before_reset)
|
62
|
-
expect(RSpec.world).not_to equal(world_before_reset)
|
63
|
-
end
|
64
|
-
end
|
65
|
-
|
66
|
-
describe "::Core.path_to_executable" do
|
67
|
-
it 'returns the absolute location of the exe/rspec file' do
|
68
|
-
expect(File.exist? RSpec::Core.path_to_executable).to be_truthy
|
69
|
-
expect(File.executable? RSpec::Core.path_to_executable).to be_truthy
|
70
|
-
end
|
71
|
-
end
|
72
|
-
|
73
|
-
# This is hard to test :(. Best way I could come up with was starting
|
74
|
-
# fresh ruby process w/o this stuff already loaded.
|
75
|
-
it "loads mocks and expectations when the constants are referenced", :slow do
|
76
|
-
code = "$LOAD_PATH.replace(#{$LOAD_PATH.inspect}); " +
|
77
|
-
'require "rspec"; ' +
|
78
|
-
"puts RSpec::Mocks.name; " +
|
79
|
-
"puts RSpec::Expectations.name"
|
80
|
-
|
81
|
-
result = `ruby -e '#{code}'`.chomp
|
82
|
-
expect(result.split("\n")).to eq(%w[ RSpec::Mocks RSpec::Expectations ])
|
83
|
-
end
|
84
|
-
|
85
|
-
it 'correctly raises an error when an invalid const is referenced' do
|
86
|
-
expect {
|
87
|
-
RSpec::NotAConst
|
88
|
-
}.to raise_error(NameError, /RSpec::NotAConst/)
|
89
|
-
end
|
90
|
-
end
|
91
|
-
|
data/spec/spec_helper.rb
DELETED
@@ -1,160 +0,0 @@
|
|
1
|
-
require 'rubygems' if RUBY_VERSION.to_f < 1.9
|
2
|
-
|
3
|
-
begin
|
4
|
-
require 'spork'
|
5
|
-
rescue LoadError
|
6
|
-
module Spork
|
7
|
-
def self.prefork
|
8
|
-
yield
|
9
|
-
end
|
10
|
-
|
11
|
-
def self.each_run
|
12
|
-
yield
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
Spork.prefork do
|
18
|
-
require 'rspec/support/spec'
|
19
|
-
|
20
|
-
module ArubaLoader
|
21
|
-
extend RSpec::Support::WithIsolatedStdErr
|
22
|
-
with_isolated_stderr do
|
23
|
-
require 'aruba/api'
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
if RUBY_PLATFORM == 'java'
|
28
|
-
# Works around https://jira.codehaus.org/browse/JRUBY-5678
|
29
|
-
require 'fileutils'
|
30
|
-
ENV['TMPDIR'] = File.expand_path('../../tmp', __FILE__)
|
31
|
-
FileUtils.mkdir_p(ENV['TMPDIR'])
|
32
|
-
end
|
33
|
-
|
34
|
-
$rspec_core_without_stderr_monkey_patch = RSpec::Core::Configuration.new
|
35
|
-
|
36
|
-
class RSpec::Core::Configuration
|
37
|
-
def self.new(*args, &block)
|
38
|
-
super.tap do |config|
|
39
|
-
# We detect ruby warnings via $stderr,
|
40
|
-
# so direct our deprecations to $stdout instead.
|
41
|
-
config.deprecation_stream = $stdout
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
Dir['./spec/support/**/*.rb'].map {|f| require f}
|
47
|
-
|
48
|
-
class NullObject
|
49
|
-
private
|
50
|
-
def method_missing(method, *args, &block)
|
51
|
-
# ignore
|
52
|
-
end
|
53
|
-
end
|
54
|
-
|
55
|
-
module Sandboxing
|
56
|
-
def self.sandboxed(&block)
|
57
|
-
@orig_config = RSpec.configuration
|
58
|
-
@orig_world = RSpec.world
|
59
|
-
@orig_example = RSpec.current_example
|
60
|
-
new_config = RSpec::Core::Configuration.new
|
61
|
-
new_config.expose_dsl_globally = false
|
62
|
-
new_world = RSpec::Core::World.new(new_config)
|
63
|
-
RSpec.configuration = new_config
|
64
|
-
RSpec.world = new_world
|
65
|
-
object = Object.new
|
66
|
-
object.extend(RSpec::Core::SharedExampleGroup)
|
67
|
-
|
68
|
-
(class << RSpec::Core::ExampleGroup; self; end).class_eval do
|
69
|
-
alias_method :orig_run, :run
|
70
|
-
def run(reporter=nil)
|
71
|
-
RSpec.current_example = nil
|
72
|
-
orig_run(reporter || NullObject.new)
|
73
|
-
end
|
74
|
-
end
|
75
|
-
|
76
|
-
RSpec::Mocks.with_temporary_scope do
|
77
|
-
object.instance_eval(&block)
|
78
|
-
end
|
79
|
-
ensure
|
80
|
-
(class << RSpec::Core::ExampleGroup; self; end).class_eval do
|
81
|
-
remove_method :run
|
82
|
-
alias_method :run, :orig_run
|
83
|
-
remove_method :orig_run
|
84
|
-
end
|
85
|
-
|
86
|
-
RSpec.configuration = @orig_config
|
87
|
-
RSpec.world = @orig_world
|
88
|
-
RSpec.current_example = @orig_example
|
89
|
-
end
|
90
|
-
end
|
91
|
-
|
92
|
-
def in_editor?
|
93
|
-
ENV.has_key?('TM_MODE') || ENV.has_key?('EMACS') || ENV.has_key?('VIM')
|
94
|
-
end
|
95
|
-
|
96
|
-
module EnvHelpers
|
97
|
-
def with_env_vars(vars)
|
98
|
-
original = ENV.to_hash
|
99
|
-
vars.each { |k, v| ENV[k] = v }
|
100
|
-
|
101
|
-
begin
|
102
|
-
yield
|
103
|
-
ensure
|
104
|
-
ENV.replace(original)
|
105
|
-
end
|
106
|
-
end
|
107
|
-
|
108
|
-
def without_env_vars(*vars)
|
109
|
-
original = ENV.to_hash
|
110
|
-
vars.each { |k| ENV.delete(k) }
|
111
|
-
|
112
|
-
begin
|
113
|
-
yield
|
114
|
-
ensure
|
115
|
-
ENV.replace(original)
|
116
|
-
end
|
117
|
-
end
|
118
|
-
end
|
119
|
-
|
120
|
-
RSpec.configure do |c|
|
121
|
-
# structural
|
122
|
-
c.alias_it_behaves_like_to 'it_has_behavior'
|
123
|
-
c.around {|example| Sandboxing.sandboxed { example.run }}
|
124
|
-
c.include(RSpecHelpers)
|
125
|
-
c.include Aruba::Api, :example_group => {
|
126
|
-
:file_path => /spec\/command_line/
|
127
|
-
}
|
128
|
-
|
129
|
-
c.expect_with :rspec do |expectations|
|
130
|
-
expectations.syntax = :expect
|
131
|
-
end
|
132
|
-
|
133
|
-
c.mock_with :rspec do |mocks|
|
134
|
-
mocks.syntax = :expect
|
135
|
-
end
|
136
|
-
|
137
|
-
# runtime options
|
138
|
-
c.color = !in_editor?
|
139
|
-
c.include EnvHelpers
|
140
|
-
c.filter_run_excluding :ruby => lambda {|version|
|
141
|
-
case version.to_s
|
142
|
-
when "!jruby"
|
143
|
-
RUBY_ENGINE == "jruby"
|
144
|
-
when /^> (.*)/
|
145
|
-
!(RUBY_VERSION.to_s > $1)
|
146
|
-
else
|
147
|
-
!(RUBY_VERSION.to_s =~ /^#{version.to_s}/)
|
148
|
-
end
|
149
|
-
}
|
150
|
-
|
151
|
-
c.after(:suite) do
|
152
|
-
if $stderr.has_output?
|
153
|
-
raise "Ruby warnings were emitted:\n\n#{$stderr.output}"
|
154
|
-
end
|
155
|
-
end
|
156
|
-
end
|
157
|
-
end
|
158
|
-
|
159
|
-
Spork.each_run do
|
160
|
-
end
|