rspec-core 2.99.2 → 3.0.0.beta1

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 (165) hide show
  1. checksums.yaml +14 -6
  2. checksums.yaml.gz.sig +2 -0
  3. data.tar.gz.sig +0 -0
  4. data/Changelog.md +103 -191
  5. data/License.txt +1 -0
  6. data/README.md +4 -25
  7. data/features/Upgrade.md +2 -14
  8. data/features/command_line/dry_run.feature +29 -0
  9. data/features/command_line/example_name_option.feature +1 -1
  10. data/features/command_line/fail_fast.feature +26 -0
  11. data/features/command_line/format_option.feature +3 -3
  12. data/features/command_line/line_number_option.feature +16 -11
  13. data/features/command_line/order.feature +2 -3
  14. data/features/command_line/pattern_option.feature +3 -3
  15. data/features/command_line/randomization.feature +63 -0
  16. data/features/command_line/require_option.feature +2 -2
  17. data/features/command_line/ruby.feature +1 -1
  18. data/features/configuration/alias_example_to.feature +13 -22
  19. data/features/configuration/{backtrace_clean_patterns.feature → backtrace_exclusion_patterns.feature} +17 -14
  20. data/features/configuration/custom_settings.feature +11 -11
  21. data/features/configuration/overriding_global_ordering.feature +93 -0
  22. data/features/configuration/profile.feature +13 -13
  23. data/features/configuration/read_options_from_file.feature +7 -7
  24. data/features/example_groups/basic_structure.feature +1 -1
  25. data/features/example_groups/shared_context.feature +8 -8
  26. data/features/example_groups/shared_examples.feature +6 -14
  27. data/features/expectation_framework_integration/configure_expectation_framework.feature +27 -122
  28. data/features/filtering/exclusion_filters.feature +2 -5
  29. data/features/filtering/inclusion_filters.feature +1 -5
  30. data/features/formatters/json_formatter.feature +2 -2
  31. data/features/formatters/text_formatter.feature +4 -4
  32. data/features/helper_methods/arbitrary_methods.feature +2 -2
  33. data/features/helper_methods/let.feature +5 -5
  34. data/features/helper_methods/modules.feature +5 -8
  35. data/features/hooks/around_hooks.feature +2 -2
  36. data/features/hooks/before_and_after_hooks.feature +14 -14
  37. data/features/hooks/filtering.feature +12 -14
  38. data/features/metadata/described_class.feature +1 -1
  39. data/features/metadata/user_defined.feature +16 -29
  40. data/features/mock_framework_integration/use_flexmock.feature +1 -1
  41. data/features/mock_framework_integration/use_mocha.feature +1 -1
  42. data/features/mock_framework_integration/use_rr.feature +1 -1
  43. data/features/mock_framework_integration/use_rspec.feature +5 -5
  44. data/features/pending/pending_examples.feature +5 -5
  45. data/features/spec_files/arbitrary_file_suffix.feature +1 -1
  46. data/features/step_definitions/additional_cli_steps.rb +3 -3
  47. data/features/subject/explicit_subject.feature +8 -8
  48. data/features/subject/implicit_receiver.feature +29 -0
  49. data/features/subject/implicit_subject.feature +4 -4
  50. data/features/support/env.rb +10 -3
  51. data/features/support/require_expect_syntax_in_aruba_specs.rb +16 -0
  52. data/lib/rspec/core.rb +11 -48
  53. data/lib/rspec/core/backport_random.rb +302 -0
  54. data/lib/rspec/core/backtrace_formatter.rb +65 -0
  55. data/lib/rspec/core/command_line.rb +7 -18
  56. data/lib/rspec/core/configuration.rb +202 -507
  57. data/lib/rspec/core/configuration_options.rb +17 -30
  58. data/lib/rspec/core/example.rb +29 -39
  59. data/lib/rspec/core/example_group.rb +166 -259
  60. data/lib/rspec/core/filter_manager.rb +30 -47
  61. data/lib/rspec/core/flat_map.rb +17 -0
  62. data/lib/rspec/core/formatters.rb +0 -138
  63. data/lib/rspec/core/formatters/base_formatter.rb +46 -1
  64. data/lib/rspec/core/formatters/base_text_formatter.rb +38 -61
  65. data/lib/rspec/core/formatters/deprecation_formatter.rb +21 -52
  66. data/lib/rspec/core/formatters/helpers.rb +0 -28
  67. data/lib/rspec/core/formatters/html_formatter.rb +1 -1
  68. data/lib/rspec/core/formatters/json_formatter.rb +38 -9
  69. data/lib/rspec/core/formatters/snippet_extractor.rb +14 -5
  70. data/lib/rspec/core/hooks.rb +55 -39
  71. data/lib/rspec/core/memoized_helpers.rb +17 -167
  72. data/lib/rspec/core/metadata.rb +16 -64
  73. data/lib/rspec/core/option_parser.rb +30 -39
  74. data/lib/rspec/core/ordering.rb +154 -0
  75. data/lib/rspec/core/pending.rb +12 -69
  76. data/lib/rspec/core/project_initializer.rb +12 -10
  77. data/lib/rspec/core/rake_task.rb +5 -108
  78. data/lib/rspec/core/reporter.rb +15 -18
  79. data/lib/rspec/core/runner.rb +16 -30
  80. data/lib/rspec/core/shared_context.rb +3 -5
  81. data/lib/rspec/core/shared_example_group.rb +3 -51
  82. data/lib/rspec/core/shared_example_group/collection.rb +1 -19
  83. data/lib/rspec/core/version.rb +1 -1
  84. data/lib/rspec/core/warnings.rb +22 -0
  85. data/lib/rspec/core/world.rb +12 -8
  86. data/spec/command_line/order_spec.rb +20 -23
  87. data/spec/rspec/core/backtrace_formatter_spec.rb +216 -0
  88. data/spec/rspec/core/command_line_spec.rb +32 -48
  89. data/spec/rspec/core/configuration_options_spec.rb +19 -50
  90. data/spec/rspec/core/configuration_spec.rb +142 -713
  91. data/spec/rspec/core/drb_command_line_spec.rb +2 -0
  92. data/spec/rspec/core/dsl_spec.rb +0 -1
  93. data/spec/rspec/core/example_group_spec.rb +192 -223
  94. data/spec/rspec/core/example_spec.rb +40 -16
  95. data/spec/rspec/core/filter_manager_spec.rb +2 -2
  96. data/spec/rspec/core/formatters/base_formatter_spec.rb +0 -41
  97. data/spec/rspec/core/formatters/base_text_formatter_spec.rb +5 -123
  98. data/spec/rspec/core/formatters/deprecation_formatter_spec.rb +2 -87
  99. data/spec/rspec/core/formatters/documentation_formatter_spec.rb +2 -3
  100. data/spec/rspec/core/formatters/{text_mate_formatted.html → html_formatted-1.8.7-jruby.html} +44 -25
  101. data/spec/rspec/core/formatters/html_formatted-1.8.7-rbx.html +477 -0
  102. data/spec/rspec/core/formatters/{html_formatted.html → html_formatted-1.8.7.html} +42 -25
  103. data/spec/rspec/core/formatters/html_formatted-1.9.2.html +425 -0
  104. data/spec/rspec/core/formatters/html_formatted-1.9.3-jruby.html +416 -0
  105. data/spec/rspec/core/formatters/html_formatted-1.9.3-rbx.html +477 -0
  106. data/spec/rspec/core/formatters/html_formatted-1.9.3.html +419 -0
  107. data/spec/rspec/core/formatters/html_formatted-2.0.0.html +425 -0
  108. data/spec/rspec/core/formatters/html_formatter_spec.rb +21 -46
  109. data/spec/rspec/core/formatters/json_formatter_spec.rb +97 -8
  110. data/spec/rspec/core/hooks_filtering_spec.rb +5 -5
  111. data/spec/rspec/core/hooks_spec.rb +61 -47
  112. data/spec/rspec/core/memoized_helpers_spec.rb +20 -322
  113. data/spec/rspec/core/metadata_spec.rb +1 -24
  114. data/spec/rspec/core/option_parser_spec.rb +20 -62
  115. data/spec/rspec/core/ordering_spec.rb +102 -0
  116. data/spec/rspec/core/pending_example_spec.rb +0 -40
  117. data/spec/rspec/core/project_initializer_spec.rb +1 -25
  118. data/spec/rspec/core/rake_task_spec.rb +5 -72
  119. data/spec/rspec/core/random_spec.rb +47 -0
  120. data/spec/rspec/core/reporter_spec.rb +23 -48
  121. data/spec/rspec/core/runner_spec.rb +31 -39
  122. data/spec/rspec/core/shared_context_spec.rb +3 -15
  123. data/spec/rspec/core/shared_example_group/collection_spec.rb +4 -17
  124. data/spec/rspec/core/shared_example_group_spec.rb +12 -45
  125. data/spec/rspec/core/{deprecation_spec.rb → warnings_spec.rb} +3 -1
  126. data/spec/rspec/core_spec.rb +4 -21
  127. data/spec/spec_helper.rb +41 -5
  128. data/spec/support/helper_methods.rb +0 -29
  129. data/spec/support/sandboxed_mock_space.rb +0 -16
  130. data/spec/support/shared_example_groups.rb +7 -36
  131. data/spec/support/stderr_splitter.rb +36 -0
  132. metadata +163 -157
  133. metadata.gz.sig +1 -0
  134. data/exe/autospec +0 -13
  135. data/features/Autotest.md +0 -38
  136. data/features/configuration/treat_symbols_as_metadata_keys_with_true_values.feature +0 -52
  137. data/features/subject/attribute_of_subject.feature +0 -124
  138. data/features/subject/one_liner_syntax.feature +0 -71
  139. data/lib/autotest/discover.rb +0 -10
  140. data/lib/autotest/rspec2.rb +0 -77
  141. data/lib/rspec/core/backtrace_cleaner.rb +0 -46
  142. data/lib/rspec/core/backward_compatibility.rb +0 -55
  143. data/lib/rspec/core/caller_filter.rb +0 -60
  144. data/lib/rspec/core/deprecated_mutable_array_proxy.rb +0 -32
  145. data/lib/rspec/core/deprecation.rb +0 -26
  146. data/lib/rspec/core/extensions/instance_eval_with_args.rb +0 -44
  147. data/lib/rspec/core/extensions/kernel.rb +0 -9
  148. data/lib/rspec/core/extensions/module_eval_with_args.rb +0 -38
  149. data/lib/rspec/core/extensions/ordered.rb +0 -27
  150. data/lib/rspec/core/formatters/console_codes.rb +0 -42
  151. data/lib/rspec/core/formatters/text_mate_formatter.rb +0 -34
  152. data/lib/rspec/core/metadata_hash_builder.rb +0 -97
  153. data/lib/rspec/core/minitest_assertions_adapter.rb +0 -28
  154. data/lib/rspec/core/test_unit_assertions_adapter.rb +0 -30
  155. data/spec/autotest/discover_spec.rb +0 -49
  156. data/spec/autotest/failed_results_re_spec.rb +0 -45
  157. data/spec/autotest/rspec_spec.rb +0 -133
  158. data/spec/rspec/core/backtrace_cleaner_spec.rb +0 -68
  159. data/spec/rspec/core/caller_filter_spec.rb +0 -58
  160. data/spec/rspec/core/deprecations_spec.rb +0 -59
  161. data/spec/rspec/core/formatters/console_codes_spec.rb +0 -50
  162. data/spec/rspec/core/formatters/text_mate_formatter_spec.rb +0 -107
  163. data/spec/rspec/core/kernel_extensions_spec.rb +0 -9
  164. data/spec/rspec/core/pending_spec.rb +0 -27
  165. data/spec/support/silence_dsl_deprecations.rb +0 -32
@@ -0,0 +1,47 @@
1
+ require 'spec_helper'
2
+
3
+ module RSpec
4
+ module Core
5
+ describe RandomNumberGenerator do
6
+ it 'is a random number generator' do
7
+ random = described_class.new
8
+
9
+ expect([Fixnum, Bignum]).to include random.seed.class
10
+ expect(random.rand).to be_a Float
11
+
12
+ rands = []
13
+ 100.times do
14
+ rands << random.rand
15
+ end
16
+
17
+ expect(rands.uniq.count).to be > 90
18
+ end
19
+
20
+ it 'produces the same results given the same seed' do
21
+ seed = rand(999)
22
+
23
+ random = described_class.new(seed)
24
+
25
+ expect(random.seed).to eq seed
26
+
27
+ expected = []
28
+ 5.times do
29
+ expected << random.rand(999)
30
+ end
31
+
32
+ 10.times do
33
+ random = described_class.new(seed)
34
+
35
+ expect(random.seed).to eq seed
36
+
37
+ actual = []
38
+ 5.times do
39
+ actual << random.rand(999)
40
+ end
41
+
42
+ expect(actual).to eq expected
43
+ end
44
+ end
45
+ end
46
+ end
47
+ end
@@ -2,45 +2,25 @@ require "spec_helper"
2
2
 
3
3
  module RSpec::Core
4
4
  describe Reporter do
5
- describe "abort" do
6
- let(:formatter) { double("formatter") }
7
- let(:example) { double("example") }
8
- let(:reporter) { Reporter.new(formatter) }
9
-
10
- before do
11
- allow_deprecation
12
- end
13
-
14
- %w[start_dump dump_pending dump_failures dump_summary close].each do |message|
15
- it "sends #{message} to the formatter(s) that respond to message" do
16
- formatter.should_receive(message)
17
- reporter.abort(nil)
18
- end
19
-
20
- it "doesnt notify formatters about messages they dont implement" do
21
- expect { reporter.abort(nil) }.to_not raise_error
22
- end
5
+ let(:config) { Configuration.new }
23
6
 
24
- it 'warns of deprecation' do
25
- expect_deprecation_with_call_site(__FILE__, __LINE__ + 1)
26
- reporter.abort(nil)
27
- end
28
- end
7
+ def reporter_for(*formatters)
8
+ Reporter.new(config, *formatters)
29
9
  end
30
10
 
31
- describe "finish" do
11
+ describe "abort" do
32
12
  let(:formatter) { double("formatter") }
33
13
  let(:example) { double("example") }
34
- let(:reporter) { Reporter.new(formatter) }
14
+ let(:reporter) { reporter_for(formatter) }
35
15
 
36
16
  %w[start_dump dump_pending dump_failures dump_summary close].each do |message|
37
17
  it "sends #{message} to the formatter(s) that respond to message" do
38
- formatter.should_receive(message)
39
- reporter.finish(nil)
18
+ formatter.as_null_object.should_receive(message)
19
+ reporter.abort
40
20
  end
41
21
 
42
22
  it "doesnt notify formatters about messages they dont implement" do
43
- expect { reporter.finish(nil) }.to_not raise_error
23
+ expect { reporter.abort }.to_not raise_error
44
24
  end
45
25
  end
46
26
  end
@@ -49,7 +29,7 @@ module RSpec::Core
49
29
  it "passes messages to that formatter" do
50
30
  formatter = double("formatter", :example_started => nil)
51
31
  example = double("example")
52
- reporter = Reporter.new(formatter)
32
+ reporter = reporter_for(formatter)
53
33
 
54
34
  formatter.should_receive(:example_started).
55
35
  with(example)
@@ -60,7 +40,7 @@ module RSpec::Core
60
40
  it "passes example_group_started and example_group_finished messages to that formatter in that order" do
61
41
  order = []
62
42
 
63
- formatter = double("formatter")
43
+ formatter = double("formatter").as_null_object
64
44
  formatter.stub(:example_group_started) { |group| order << "Started: #{group.description}" }
65
45
  formatter.stub(:example_group_finished) { |group| order << "Finished: #{group.description}" }
66
46
 
@@ -72,7 +52,7 @@ module RSpec::Core
72
52
  example("ignore") {}
73
53
  end
74
54
 
75
- group.run(Reporter.new(formatter))
55
+ group.run(reporter_for(formatter))
76
56
 
77
57
  expect(order).to eq([
78
58
  "Started: root",
@@ -87,13 +67,13 @@ module RSpec::Core
87
67
 
88
68
  context "given an example group with no examples" do
89
69
  it "does not pass example_group_started or example_group_finished to formatter" do
90
- formatter = double("formatter")
70
+ formatter = double("formatter").as_null_object
91
71
  formatter.should_not_receive(:example_group_started)
92
72
  formatter.should_not_receive(:example_group_finished)
93
73
 
94
74
  group = ExampleGroup.describe("root")
95
75
 
96
- group.run(Reporter.new(formatter))
76
+ group.run(reporter_for(formatter))
97
77
  end
98
78
  end
99
79
 
@@ -101,7 +81,7 @@ module RSpec::Core
101
81
  it "passes messages to all formatters" do
102
82
  formatters = (1..2).map { double("formatter", :example_started => nil) }
103
83
  example = double("example")
104
- reporter = Reporter.new(*formatters)
84
+ reporter = reporter_for(*formatters)
105
85
 
106
86
  formatters.each do |formatter|
107
87
  formatter.
@@ -115,15 +95,11 @@ module RSpec::Core
115
95
 
116
96
  describe "#report" do
117
97
  it "supports one arg (count)" do
118
- Reporter.new.report(1) {}
119
- end
120
-
121
- it "supports two args (count, seed)" do
122
- Reporter.new.report(1, 2) {}
98
+ reporter_for.report(1) {}
123
99
  end
124
100
 
125
101
  it "yields itself" do
126
- reporter = Reporter.new
102
+ reporter = reporter_for
127
103
  yielded = nil
128
104
  reporter.report(3) {|r| yielded = r}
129
105
  expect(yielded).to eq(reporter)
@@ -131,7 +107,7 @@ module RSpec::Core
131
107
  end
132
108
 
133
109
  describe "#register_listener" do
134
- let(:reporter) { Reporter.new }
110
+ let(:reporter) { reporter_for }
135
111
  let(:listener) { double("listener", :start => nil) }
136
112
 
137
113
  before { reporter.register_listener listener, :start }
@@ -148,18 +124,17 @@ module RSpec::Core
148
124
 
149
125
  describe "timing" do
150
126
  it "uses RSpec::Core::Time as to not be affected by changes to time in examples" do
151
- formatter = double(:formatter)
127
+ formatter = double(:formatter).as_null_object
128
+ reporter = reporter_for formatter
129
+ reporter.start 1
130
+ Time.stub(:now => ::Time.utc(2012, 10, 1))
131
+
152
132
  duration = nil
153
133
  formatter.stub(:dump_summary) do |dur, _, _, _|
154
134
  duration = dur
155
135
  end
156
136
 
157
- reporter = Reporter.new formatter
158
- reporter.start 1
159
- Time.stub(:now => ::Time.utc(2012, 10, 1))
160
-
161
-
162
- reporter.finish 1234
137
+ reporter.finish
163
138
  expect(duration).to be < 0.2
164
139
  end
165
140
  end
@@ -22,53 +22,45 @@ module RSpec::Core
22
22
  end
23
23
  end
24
24
 
25
- describe "#run" do
26
- let(:err) { StringIO.new }
27
- let(:out) { StringIO.new }
25
+ describe "#running_in_drb?" do
26
+ it "returns true if drb server is started with 127.0.0.1" do
27
+ allow(::DRb).to receive(:current_server).and_return(double(:uri => "druby://127.0.0.1:0000/"))
28
28
 
29
- after { RSpec.resets_required = 0 }
30
- before { RSpec.resets_required = 0 }
29
+ expect(RSpec::Core::Runner.running_in_drb?).to be_truthy
30
+ end
31
31
 
32
- it "tells RSpec to reset" do
33
- RSpec.configuration.stub(:files_to_run => [])
34
- RSpec.should_receive(:internal_reset)
35
- RSpec::Core::Runner.run([], err, out)
32
+ it "returns true if drb server is started with localhost" do
33
+ allow(::DRb).to receive(:current_server).and_return(double(:uri => "druby://localhost:0000/"))
34
+
35
+ expect(RSpec::Core::Runner.running_in_drb?).to be_truthy
36
36
  end
37
37
 
38
- it "does not issue a deprecation warning at the end of the first run" do
39
- RSpec.configuration.stub(:files_to_run => [])
40
- RSpec.should_receive(:internal_reset)
41
- allow(RSpec.configuration).to receive(:deprecation_stream).and_return(err)
42
- RSpec::Core::Runner.run([], err, out)
43
- expect(err.string).to eq("")
38
+ it "returns true if drb server is started with another local ip address" do
39
+ allow(::DRb).to receive(:current_server).and_return(double(:uri => "druby://192.168.0.1:0000/"))
40
+ allow(::IPSocket).to receive(:getaddress).and_return("192.168.0.1")
41
+
42
+ expect(RSpec::Core::Runner.running_in_drb?).to be_truthy
44
43
  end
45
44
 
46
- it "issues a deprecation if warn is invoked twice and reset is not called manually" do
47
- RSpec.configuration.stub(:files_to_run => [])
48
- RSpec::Core::Runner.run([], err, out)
49
- RSpec.configuration.stub(:files_to_run => [])
50
- allow(RSpec.configuration).to receive(:deprecation_stream).and_return(err)
51
- RSpec::Core::Runner.run([], err, out)
52
- expect(err.string).to match(/no longer implicitly/)
45
+ it "returns false if no drb server is running" do
46
+ ::DRb.stub(:current_server).and_raise(::DRb::DRbServerNotFound)
47
+
48
+ expect(RSpec::Core::Runner.running_in_drb?).to be_falsey
53
49
  end
50
+ end
54
51
 
55
- context "when the user manually invokes reset" do
56
- after { RSpec.instance_variable_set(:@reset_called_by_user, false) }
57
-
58
- it "does not issue a deprecation warning" do
59
- RSpec.configuration.stub(:files_to_run => [])
60
- RSpec::Core::Runner.run([], err, out)
61
- RSpec.configuration.stub(:files_to_run => [])
62
- RSpec.reset
63
- RSpec.configuration.stub(:files_to_run => [])
64
- allow(RSpec.configuration).to receive(:deprecation_stream).and_return(err)
65
- RSpec::Core::Runner.run([], err, out)
66
- expect(err.string).to eq("")
67
- end
52
+ describe "#run" do
53
+ let(:err) { StringIO.new }
54
+ let(:out) { StringIO.new }
55
+
56
+ it "tells RSpec to reset" do
57
+ CommandLine.stub(:new => double.as_null_object)
58
+ RSpec.configuration.stub(:files_to_run => [], :warn => nil)
59
+ RSpec.should_receive(:reset)
60
+ RSpec::Core::Runner.run([], err, out)
68
61
  end
69
62
 
70
63
  context "with --drb or -X" do
71
-
72
64
  before(:each) do
73
65
  @options = RSpec::Core::ConfigurationOptions.new(%w[--drb --drb-port 8181 --color])
74
66
  RSpec::Core::ConfigurationOptions.stub(:new) { @options }
@@ -102,11 +94,11 @@ module RSpec::Core
102
94
  run_specs
103
95
  end
104
96
 
105
- it "builds a Runner and runs the specs" do
106
- process_proxy = double(RSpec::Core::Runner, :run => 0)
97
+ it "builds a CommandLine and runs the specs" do
98
+ process_proxy = double(RSpec::Core::CommandLine, :run => 0)
107
99
  process_proxy.should_receive(:run).with(err, out)
108
100
 
109
- RSpec::Core::Runner.should_receive(:new).and_return(process_proxy)
101
+ RSpec::Core::CommandLine.should_receive(:new).and_return(process_proxy)
110
102
 
111
103
  run_specs
112
104
  end
@@ -34,6 +34,8 @@ describe RSpec::SharedContext do
34
34
  expect(after_all_hook).to be_truthy
35
35
  end
36
36
 
37
+ include RSpec::Core::SharedExampleGroup::TopLevelDSL
38
+
37
39
  it "runs the before each hooks in configuration before those of the shared context" do
38
40
  ordered_hooks = []
39
41
  RSpec.configure do |c|
@@ -44,7 +46,7 @@ describe RSpec::SharedContext do
44
46
  before(:each) { ordered_hooks << "shared_context"}
45
47
  end
46
48
 
47
- group = RSpec::Core::ExampleGroup.describe "group", :example => :before_each_hook_order do
49
+ group = RSpec::Core::ExampleGroup.describe :example => :before_each_hook_order do
48
50
  before(:each) { ordered_hooks << "example_group" }
49
51
  example {}
50
52
  end
@@ -79,20 +81,6 @@ describe RSpec::SharedContext do
79
81
  expect(group.new.subject).to eq(17)
80
82
  end
81
83
 
82
- it 'supports `its` with an implicit subject' do
83
- shared = Module.new do
84
- extend RSpec::SharedContext
85
- its(:size) { should eq 0 }
86
- end
87
-
88
- group = RSpec::Core::ExampleGroup.describe(Array) do
89
- include shared
90
- end
91
-
92
- group.run
93
- expect(group.children.first.examples.first.execution_result).to include(:status => "passed")
94
- end
95
-
96
84
  %w[describe context].each do |method_name|
97
85
  it "supports nested example groups using #{method_name}" do
98
86
  shared = Module.new do
@@ -32,14 +32,8 @@ module RSpec::Core::SharedExampleGroup
32
32
  expect(collection['top level group']).to eq example_1
33
33
  end
34
34
 
35
- it 'fetches examples across the nested context' do
36
- RSpec.stub(:warn_deprecation)
37
- expect(collection['nested level two']).to eq example_3
38
- end
39
-
40
- it 'warns about deprecation when you fetch across nested contexts' do
41
- RSpec.should_receive(:warn_deprecation)
42
- collection['nested level two']
35
+ it 'wont fetches examples across the nested context' do
36
+ expect(collection['nested level two']).to eq nil
43
37
  end
44
38
  end
45
39
 
@@ -55,16 +49,9 @@ module RSpec::Core::SharedExampleGroup
55
49
  expect(collection['top level group']).to eq example_1
56
50
  end
57
51
 
58
- it 'fetches examples across the nested context' do
59
- RSpec.stub(:warn_deprecation)
60
- expect(collection['nested level two']).to eq example_3
52
+ it 'wont fetch examples across the nested context' do
53
+ expect(collection['nested level two']).to eq nil
61
54
  end
62
-
63
- it 'warns about deprecation when you fetch across nested contexts' do
64
- RSpec.should_receive(:warn_deprecation)
65
- collection['nested level two']
66
- end
67
-
68
55
  end
69
56
  end
70
57
  end
@@ -32,22 +32,10 @@ module RSpec::Core
32
32
 
33
33
  %w[share_examples_for shared_examples_for shared_examples shared_context].each do |shared_method_name|
34
34
  describe shared_method_name do
35
- if shared_method_name == "share_examples_for"
36
- before { allow_deprecation }
35
+ let(:group) { ExampleGroup.describe('example group') }
37
36
 
38
- it 'is deprecated when called from within an example group' do
39
- expect_deprecation_with_call_site(__FILE__, __LINE__ + 2, /share_examples_for/)
40
- ExampleGroup.describe("example group") do
41
- send(shared_method_name, "group") { }
42
- end
43
- end
44
-
45
- it 'is deprecated when called from the top level' do
46
- expect_deprecation_with_call_site(__FILE__, __LINE__ + 2, /share_examples_for/)
47
- Module.new do
48
- send(shared_method_name, "group") { }
49
- end
50
- end
37
+ define_method :define_shared_group do |*args, &block|
38
+ group.send(shared_method_name, *args, &block)
51
39
  end
52
40
 
53
41
  it "is exposed to the global namespace" do
@@ -55,16 +43,16 @@ module RSpec::Core
55
43
  end
56
44
 
57
45
  it "displays a warning when adding a second shared example group with the same name" do
58
- group = ExampleGroup.describe('example group')
59
46
  group.send(shared_method_name, 'some shared group') {}
60
47
  original_declaration = [__FILE__, __LINE__ - 1].join(':')
61
48
 
62
49
  warning = nil
63
- Kernel.stub(:warn) { |msg| warning = msg }
50
+ allow(::Kernel).to receive(:warn) { |msg| warning = msg }
64
51
 
65
52
  group.send(shared_method_name, 'some shared group') {}
66
53
  second_declaration = [__FILE__, __LINE__ - 1].join(':')
67
54
  expect(warning).to include('some shared group', original_declaration, second_declaration)
55
+ expect(warning).to_not include 'Called from'
68
56
  end
69
57
 
70
58
  it 'works with top level defined examples in modules' do
@@ -77,8 +65,8 @@ module RSpec::Core
77
65
  context "given a #{type}" do
78
66
  it "captures the given #{type} and block in the collection of shared example groups" do
79
67
  implementation = lambda {}
80
- send(shared_method_name, object, &implementation)
81
- expect(SharedExampleGroup.registry.shared_example_groups[self][object]).to eq implementation
68
+ define_shared_group(object, &implementation)
69
+ expect(SharedExampleGroup.registry.shared_example_groups[group][object]).to eq implementation
82
70
  end
83
71
  end
84
72
  end
@@ -86,7 +74,7 @@ module RSpec::Core
86
74
  context "given a hash" do
87
75
  it "delegates extend on configuration" do
88
76
  implementation = Proc.new { def bar; 'bar'; end }
89
- send(shared_method_name, :foo => :bar, &implementation)
77
+ define_shared_group(:foo => :bar, &implementation)
90
78
  a = RSpec.configuration.include_or_extend_modules.first
91
79
  expect(a[0]).to eq(:extend)
92
80
  expect(Class.new.extend(a[1]).new.bar).to eq('bar')
@@ -97,13 +85,13 @@ module RSpec::Core
97
85
  context "given a string and a hash" do
98
86
  it "captures the given string and block in the World's collection of shared example groups" do
99
87
  implementation = lambda {}
100
- send(shared_method_name, "name", :foo => :bar, &implementation)
101
- expect(SharedExampleGroup.registry.shared_example_groups[self]["name"]).to eq implementation
88
+ define_shared_group("name", :foo => :bar, &implementation)
89
+ expect(SharedExampleGroup.registry.shared_example_groups[group]["name"]).to eq implementation
102
90
  end
103
91
 
104
92
  it "delegates extend on configuration" do
105
93
  implementation = Proc.new { def bar; 'bar'; end }
106
- send(shared_method_name, "name", :foo => :bar, &implementation)
94
+ define_shared_group("name", :foo => :bar, &implementation)
107
95
  a = RSpec.configuration.include_or_extend_modules.first
108
96
  expect(a[0]).to eq(:extend)
109
97
  expect(Class.new.extend(a[1]).new.bar).to eq('bar')
@@ -112,27 +100,6 @@ module RSpec::Core
112
100
  end
113
101
  end
114
102
  end
115
-
116
- describe "#share_as" do
117
- before { allow(RSpec).to receive(:deprecate) }
118
-
119
- it "is exposed to the global namespace" do
120
- expect(Kernel).to respond_to("share_as")
121
- end
122
-
123
- it "adds examples to current example_group using include", :compat => 'rspec-1.2' do
124
- share_as('Cornucopia') do
125
- it "is plentiful" do
126
- expect(5).to eq(4)
127
- end
128
- end
129
- group = ExampleGroup.describe('group') { include Cornucopia }
130
- phantom_group = group.children.first
131
- expect(phantom_group.description).to eql("")
132
- expect(phantom_group.metadata[:shared_group_name]).to eql('Cornucopia')
133
- expect(phantom_group.examples.length).to eq(1)
134
- expect(phantom_group.examples.first.metadata[:description]).to eq("is plentiful")
135
- end
136
- end
137
103
  end
138
104
  end
105
+