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.
Files changed (201) hide show
  1. checksums.yaml +7 -0
  2. checksums.yaml.gz.sig +0 -0
  3. data.tar.gz.sig +0 -0
  4. data/.yardopts +1 -0
  5. data/Changelog.md +297 -57
  6. data/README.md +16 -13
  7. data/lib/rspec/core.rb +55 -84
  8. data/lib/rspec/core/backport_random.rb +35 -3
  9. data/lib/rspec/core/backtrace_formatter.rb +4 -13
  10. data/lib/rspec/core/configuration.rb +330 -114
  11. data/lib/rspec/core/configuration_options.rb +38 -22
  12. data/lib/rspec/core/drb.rb +111 -0
  13. data/lib/rspec/core/dsl.rb +8 -2
  14. data/lib/rspec/core/example.rb +203 -94
  15. data/lib/rspec/core/example_group.rb +344 -316
  16. data/lib/rspec/core/filter_manager.rb +135 -90
  17. data/lib/rspec/core/flat_map.rb +1 -0
  18. data/lib/rspec/core/formatters.rb +50 -14
  19. data/lib/rspec/core/formatters/base_formatter.rb +32 -138
  20. data/lib/rspec/core/formatters/base_text_formatter.rb +32 -253
  21. data/lib/rspec/core/formatters/console_codes.rb +65 -0
  22. data/lib/rspec/core/formatters/deprecation_formatter.rb +24 -15
  23. data/lib/rspec/core/formatters/documentation_formatter.rb +7 -10
  24. data/lib/rspec/core/formatters/helpers.rb +15 -9
  25. data/lib/rspec/core/formatters/html_formatter.rb +17 -16
  26. data/lib/rspec/core/formatters/html_printer.rb +1 -0
  27. data/lib/rspec/core/formatters/json_formatter.rb +18 -20
  28. data/lib/rspec/core/formatters/profile_formatter.rb +67 -0
  29. data/lib/rspec/core/formatters/progress_formatter.rb +6 -7
  30. data/lib/rspec/core/formatters/snippet_extractor.rb +8 -6
  31. data/lib/rspec/core/hooks.rb +131 -125
  32. data/lib/rspec/core/memoized_helpers.rb +31 -26
  33. data/lib/rspec/core/metadata.rb +277 -184
  34. data/lib/rspec/core/metadata_filter.rb +86 -0
  35. data/lib/rspec/core/minitest_assertions_adapter.rb +28 -0
  36. data/lib/rspec/core/mocking_adapters/flexmock.rb +1 -1
  37. data/lib/rspec/core/mocking_adapters/mocha.rb +1 -1
  38. data/lib/rspec/core/mocking_adapters/null.rb +1 -1
  39. data/lib/rspec/core/mocking_adapters/rr.rb +2 -1
  40. data/lib/rspec/core/mocking_adapters/rspec.rb +1 -1
  41. data/lib/rspec/core/notifications.rb +435 -24
  42. data/lib/rspec/core/option_parser.rb +16 -25
  43. data/lib/rspec/core/ordering.rb +3 -1
  44. data/lib/rspec/core/pending.rb +57 -33
  45. data/lib/rspec/core/project_initializer.rb +2 -0
  46. data/lib/rspec/core/project_initializer/spec_helper.rb +5 -4
  47. data/lib/rspec/core/rake_task.rb +45 -20
  48. data/lib/rspec/core/reporter.rb +50 -22
  49. data/lib/rspec/core/ruby_project.rb +1 -0
  50. data/lib/rspec/core/runner.rb +93 -39
  51. data/lib/rspec/core/shared_context.rb +7 -5
  52. data/lib/rspec/core/shared_example_group.rb +85 -77
  53. data/lib/rspec/core/test_unit_assertions_adapter.rb +30 -0
  54. data/lib/rspec/core/version.rb +3 -1
  55. data/lib/rspec/core/warnings.rb +35 -17
  56. data/lib/rspec/core/world.rb +57 -5
  57. metadata +56 -369
  58. metadata.gz.sig +3 -3
  59. data/features/README.md +0 -13
  60. data/features/Upgrade.md +0 -352
  61. data/features/command_line/README.md +0 -25
  62. data/features/command_line/dry_run.feature +0 -29
  63. data/features/command_line/example_name_option.feature +0 -97
  64. data/features/command_line/exit_status.feature +0 -82
  65. data/features/command_line/fail_fast.feature +0 -26
  66. data/features/command_line/format_option.feature +0 -75
  67. data/features/command_line/init.feature +0 -57
  68. data/features/command_line/line_number_appended_to_path.feature +0 -140
  69. data/features/command_line/line_number_option.feature +0 -58
  70. data/features/command_line/order.feature +0 -25
  71. data/features/command_line/pattern_option.feature +0 -49
  72. data/features/command_line/rake_task.feature +0 -122
  73. data/features/command_line/randomization.feature +0 -63
  74. data/features/command_line/require_option.feature +0 -43
  75. data/features/command_line/ruby.feature +0 -23
  76. data/features/command_line/tag.feature +0 -98
  77. data/features/command_line/warnings_option.feature +0 -29
  78. data/features/configuration/alias_example_to.feature +0 -39
  79. data/features/configuration/backtrace_exclusion_patterns.feature +0 -105
  80. data/features/configuration/custom_settings.feature +0 -84
  81. data/features/configuration/default_path.feature +0 -38
  82. data/features/configuration/deprecation_stream.feature +0 -58
  83. data/features/configuration/enable_global_dsl.feature +0 -54
  84. data/features/configuration/fail_fast.feature +0 -77
  85. data/features/configuration/failure_exit_code.feature +0 -36
  86. data/features/configuration/order_and_seed.feature +0 -3
  87. data/features/configuration/output_stream.feature +0 -24
  88. data/features/configuration/overriding_global_ordering.feature +0 -93
  89. data/features/configuration/pattern.feature +0 -38
  90. data/features/configuration/profile.feature +0 -220
  91. data/features/configuration/read_options_from_file.feature +0 -90
  92. data/features/configuration/run_all_when_everything_filtered.feature +0 -76
  93. data/features/example_groups/aliasing.feature +0 -48
  94. data/features/example_groups/basic_structure.feature +0 -55
  95. data/features/example_groups/shared_context.feature +0 -74
  96. data/features/example_groups/shared_examples.feature +0 -286
  97. data/features/expectation_framework_integration/configure_expectation_framework.feature +0 -102
  98. data/features/filtering/exclusion_filters.feature +0 -135
  99. data/features/filtering/if_and_unless.feature +0 -138
  100. data/features/filtering/inclusion_filters.feature +0 -101
  101. data/features/formatters/configurable_colors.feature +0 -31
  102. data/features/formatters/custom_formatter.feature +0 -68
  103. data/features/formatters/json_formatter.feature +0 -30
  104. data/features/formatters/regression_tests.feature +0 -95
  105. data/features/formatters/text_formatter.feature +0 -46
  106. data/features/helper_methods/arbitrary_methods.feature +0 -40
  107. data/features/helper_methods/let.feature +0 -50
  108. data/features/helper_methods/modules.feature +0 -146
  109. data/features/hooks/around_hooks.feature +0 -344
  110. data/features/hooks/before_and_after_hooks.feature +0 -427
  111. data/features/hooks/filtering.feature +0 -232
  112. data/features/metadata/current_example.feature +0 -56
  113. data/features/metadata/described_class.feature +0 -17
  114. data/features/metadata/user_defined.feature +0 -100
  115. data/features/mock_framework_integration/use_any_framework.feature +0 -106
  116. data/features/mock_framework_integration/use_flexmock.feature +0 -94
  117. data/features/mock_framework_integration/use_mocha.feature +0 -95
  118. data/features/mock_framework_integration/use_rr.feature +0 -96
  119. data/features/mock_framework_integration/use_rspec.feature +0 -95
  120. data/features/pending_and_skipped_examples/README.md +0 -3
  121. data/features/pending_and_skipped_examples/pending_examples.feature +0 -118
  122. data/features/pending_and_skipped_examples/skipped_examples.feature +0 -106
  123. data/features/spec_files/arbitrary_file_suffix.feature +0 -13
  124. data/features/step_definitions/additional_cli_steps.rb +0 -83
  125. data/features/subject/explicit_subject.feature +0 -101
  126. data/features/subject/implicit_subject.feature +0 -63
  127. data/features/subject/one_liner_syntax.feature +0 -71
  128. data/features/support/env.rb +0 -21
  129. data/features/support/require_expect_syntax_in_aruba_specs.rb +0 -16
  130. data/features/support/rubinius.rb +0 -6
  131. data/lib/rspec/core/command_line.rb +0 -35
  132. data/lib/rspec/core/drb_command_line.rb +0 -26
  133. data/lib/rspec/core/drb_options.rb +0 -87
  134. data/lib/rspec/core/formatters/legacy_formatter.rb +0 -227
  135. data/lib/rspec/core/shared_example_group/collection.rb +0 -27
  136. data/spec/command_line/order_spec.rb +0 -211
  137. data/spec/rspec/core/backtrace_formatter_spec.rb +0 -230
  138. data/spec/rspec/core/command_line_spec.rb +0 -112
  139. data/spec/rspec/core/command_line_spec_output.txt +0 -0
  140. data/spec/rspec/core/configuration_options_spec.rb +0 -409
  141. data/spec/rspec/core/configuration_spec.rb +0 -1479
  142. data/spec/rspec/core/drb_command_line_spec.rb +0 -102
  143. data/spec/rspec/core/drb_options_spec.rb +0 -193
  144. data/spec/rspec/core/dsl_spec.rb +0 -88
  145. data/spec/rspec/core/example_group_spec.rb +0 -1533
  146. data/spec/rspec/core/example_spec.rb +0 -642
  147. data/spec/rspec/core/filter_manager_spec.rb +0 -229
  148. data/spec/rspec/core/formatters/base_formatter_spec.rb +0 -64
  149. data/spec/rspec/core/formatters/base_text_formatter_spec.rb +0 -303
  150. data/spec/rspec/core/formatters/deprecation_formatter_spec.rb +0 -208
  151. data/spec/rspec/core/formatters/documentation_formatter_spec.rb +0 -75
  152. data/spec/rspec/core/formatters/helpers_spec.rb +0 -104
  153. data/spec/rspec/core/formatters/html_formatted-2.1.0.html +0 -392
  154. data/spec/rspec/core/formatters/html_formatted.html +0 -397
  155. data/spec/rspec/core/formatters/html_formatter_spec.rb +0 -122
  156. data/spec/rspec/core/formatters/json_formatter_spec.rb +0 -206
  157. data/spec/rspec/core/formatters/legacy_formatter_spec.rb +0 -137
  158. data/spec/rspec/core/formatters/progress_formatter_spec.rb +0 -43
  159. data/spec/rspec/core/formatters/snippet_extractor_spec.rb +0 -26
  160. data/spec/rspec/core/formatters_spec.rb +0 -120
  161. data/spec/rspec/core/hooks_filtering_spec.rb +0 -227
  162. data/spec/rspec/core/hooks_spec.rb +0 -294
  163. data/spec/rspec/core/memoized_helpers_spec.rb +0 -495
  164. data/spec/rspec/core/metadata_spec.rb +0 -491
  165. data/spec/rspec/core/option_parser_spec.rb +0 -262
  166. data/spec/rspec/core/ordering_spec.rb +0 -102
  167. data/spec/rspec/core/pending_example_spec.rb +0 -117
  168. data/spec/rspec/core/pending_spec.rb +0 -8
  169. data/spec/rspec/core/project_initializer_spec.rb +0 -73
  170. data/spec/rspec/core/rake_task_spec.rb +0 -146
  171. data/spec/rspec/core/random_spec.rb +0 -47
  172. data/spec/rspec/core/reporter_spec.rb +0 -155
  173. data/spec/rspec/core/resources/a_bar.rb +0 -0
  174. data/spec/rspec/core/resources/a_foo.rb +0 -0
  175. data/spec/rspec/core/resources/a_spec.rb +0 -1
  176. data/spec/rspec/core/resources/custom_example_group_runner.rb +0 -14
  177. data/spec/rspec/core/resources/formatter_specs.rb +0 -58
  178. data/spec/rspec/core/resources/utf8_encoded.rb +0 -8
  179. data/spec/rspec/core/rspec_matchers_spec.rb +0 -45
  180. data/spec/rspec/core/ruby_project_spec.rb +0 -26
  181. data/spec/rspec/core/runner_spec.rb +0 -151
  182. data/spec/rspec/core/shared_context_spec.rb +0 -102
  183. data/spec/rspec/core/shared_example_group/collection_spec.rb +0 -57
  184. data/spec/rspec/core/shared_example_group_spec.rb +0 -114
  185. data/spec/rspec/core/warnings_spec.rb +0 -29
  186. data/spec/rspec/core/world_spec.rb +0 -142
  187. data/spec/rspec/core_spec.rb +0 -91
  188. data/spec/spec_helper.rb +0 -160
  189. data/spec/support/config_options_helper.rb +0 -13
  190. data/spec/support/formatter_support.rb +0 -83
  191. data/spec/support/helper_methods.rb +0 -26
  192. data/spec/support/isolate_load_path_mutation.rb +0 -5
  193. data/spec/support/isolated_directory.rb +0 -10
  194. data/spec/support/isolated_home_directory.rb +0 -16
  195. data/spec/support/legacy_formatter_using_sub_classing_example.rb +0 -87
  196. data/spec/support/matchers.rb +0 -85
  197. data/spec/support/mathn_integration_support.rb +0 -12
  198. data/spec/support/old_style_formatter_example.rb +0 -69
  199. data/spec/support/shared_example_groups.rb +0 -13
  200. data/spec/support/spec_files.rb +0 -44
  201. 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
@@ -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
-
@@ -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