rspec-core 2.99.2 → 3.0.0.beta1

Sign up to get free protection for your applications and to get access to all the features.
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
@@ -11,21 +11,21 @@ Feature: custom settings
11
11
 
12
12
  describe "custom setting" do
13
13
  it "is nil by default" do
14
- RSpec.configuration.custom_setting.should be_nil
14
+ expect(RSpec.configuration.custom_setting).to be_nil
15
15
  end
16
16
 
17
17
  it "acts false by default" do
18
- RSpec.configuration.custom_setting.should be_falsey
18
+ expect(RSpec.configuration.custom_setting).to be_falsey
19
19
  end
20
20
 
21
21
  it "is exposed as a predicate" do
22
- RSpec.configuration.custom_setting?.should be_falsey
22
+ expect(RSpec.configuration.custom_setting?).to be_falsey
23
23
  end
24
24
 
25
25
  it "can be overridden" do
26
26
  RSpec.configuration.custom_setting = true
27
- RSpec.configuration.custom_setting.should be_truthy
28
- RSpec.configuration.custom_setting?.should be_truthy
27
+ expect(RSpec.configuration.custom_setting).to be_truthy
28
+ expect(RSpec.configuration.custom_setting?).to be_truthy
29
29
  end
30
30
  end
31
31
  """
@@ -41,17 +41,17 @@ Feature: custom settings
41
41
 
42
42
  describe "custom setting" do
43
43
  it "is true by default" do
44
- RSpec.configuration.custom_setting.should be_truthy
44
+ expect(RSpec.configuration.custom_setting).to be_truthy
45
45
  end
46
46
 
47
47
  it "is exposed as a predicate" do
48
- RSpec.configuration.custom_setting?.should be_truthy
48
+ expect(RSpec.configuration.custom_setting?).to be_truthy
49
49
  end
50
50
 
51
51
  it "can be overridden" do
52
52
  RSpec.configuration.custom_setting = false
53
- RSpec.configuration.custom_setting.should be_falsey
54
- RSpec.configuration.custom_setting?.should be_falsey
53
+ expect(RSpec.configuration.custom_setting).to be_falsey
54
+ expect(RSpec.configuration.custom_setting?).to be_falsey
55
55
  end
56
56
  end
57
57
  """
@@ -71,11 +71,11 @@ Feature: custom settings
71
71
 
72
72
  describe "custom setting" do
73
73
  it "returns the value set in the last cofigure block to get eval'd" do
74
- RSpec.configuration.custom_setting.should be_truthy
74
+ expect(RSpec.configuration.custom_setting).to be_truthy
75
75
  end
76
76
 
77
77
  it "is exposed as a predicate" do
78
- RSpec.configuration.custom_setting?.should be_truthy
78
+ expect(RSpec.configuration.custom_setting?).to be_truthy
79
79
  end
80
80
  end
81
81
  """
@@ -0,0 +1,93 @@
1
+ Feature: Overriding global ordering
2
+
3
+ You can customize how RSpec orders examples and example groups.
4
+ For an individual group, you can control it by tagging it with
5
+ `:order` metadata:
6
+
7
+ * `:defined` runs the examples (and sub groups) in defined order.
8
+ * `:random` runs them in random order.
9
+
10
+ If you have more specialized needs, you can register your own ordering
11
+ using the `register_ordering` configuration option. If you register
12
+ an ordering as `:global`, it will be the global default, used by all
13
+ groups that do not have `:order` metadata (and by RSpec to order the
14
+ top-level groups).
15
+
16
+ Scenario: running a specific examples group in order
17
+ Given a file named "order_dependent_spec.rb" with:
18
+ """ruby
19
+ describe "examples only pass when they are run in order", :order => :defined do
20
+ before(:all) { @list = [] }
21
+
22
+ it "passes when run first" do
23
+ @list << 1
24
+ expect(@list).to eq([1])
25
+ end
26
+
27
+ it "passes when run second" do
28
+ @list << 2
29
+ expect(@list).to eq([1, 2])
30
+ end
31
+
32
+ it "passes when run third" do
33
+ @list << 3
34
+ expect(@list).to eq([1, 2, 3])
35
+ end
36
+ end
37
+ """
38
+
39
+ When I run `rspec order_dependent_spec.rb --order random:1`
40
+ Then the examples should all pass
41
+
42
+ Scenario: Registering a custom ordering
43
+ Given a file named "register_custom_ordering_spec.rb" with:
44
+ """ruby
45
+ RSpec.configure do |rspec|
46
+ rspec.register_ordering(:reverse) do |items|
47
+ items.reverse
48
+ end
49
+ end
50
+
51
+ describe "A group that must run in reverse order", :order => :reverse do
52
+ before(:all) { @list = [] }
53
+
54
+ it "passes when run second" do
55
+ @list << 2
56
+ expect(@list).to eq([1, 2])
57
+ end
58
+
59
+ it "passes when run first" do
60
+ @list << 1
61
+ expect(@list).to eq([1])
62
+ end
63
+ end
64
+ """
65
+ When I run `rspec register_custom_ordering_spec.rb`
66
+ Then the examples should all pass
67
+
68
+ Scenario: Using a custom global ordering
69
+ Given a file named "register_global_ordering_spec.rb" with:
70
+ """ruby
71
+ RSpec.configure do |rspec|
72
+ rspec.register_ordering(:global) do |items|
73
+ items.reverse
74
+ end
75
+ end
76
+
77
+ describe "A group without :order metadata" do
78
+ before(:all) { @list = [] }
79
+
80
+ it "passes when run second" do
81
+ @list << 2
82
+ expect(@list).to eq([1, 2])
83
+ end
84
+
85
+ it "passes when run first" do
86
+ @list << 1
87
+ expect(@list).to eq([1])
88
+ end
89
+ end
90
+ """
91
+ When I run `rspec register_global_ordering_spec.rb`
92
+ Then the examples should all pass
93
+
@@ -18,56 +18,56 @@ Feature: Profile examples
18
18
  describe "something" do
19
19
  it "sleeps for 0.1 seconds (example 1)" do
20
20
  sleep 0.1
21
- 1.should == 1
21
+ expect(1).to eq(1)
22
22
  end
23
23
 
24
24
  it "sleeps for 0 seconds (example 2)" do
25
- 2.should == 2
25
+ expect(2).to eq(2)
26
26
  end
27
27
 
28
28
  it "sleeps for 0.15 seconds (example 3)" do
29
29
  sleep 0.15
30
- 3.should == 3
30
+ expect(3).to eq(3)
31
31
  end
32
32
 
33
33
  it "sleeps for 0.05 seconds (example 4)" do
34
34
  sleep 0.05
35
- 4.should == 4
35
+ expect(4).to eq(4)
36
36
  end
37
37
 
38
38
  it "sleeps for 0.05 seconds (example 5)" do
39
39
  sleep 0.05
40
- 5.should == 5
40
+ expect(5).to eq(5)
41
41
  end
42
42
 
43
43
  it "sleeps for 0.05 seconds (example 6)" do
44
44
  sleep 0.05
45
- 6.should == 6
45
+ expect(6).to eq(6)
46
46
  end
47
47
 
48
48
  it "sleeps for 0.05 seconds (example 7)" do
49
49
  sleep 0.05
50
- 7.should == 7
50
+ expect(7).to eq(7)
51
51
  end
52
52
 
53
53
  it "sleeps for 0.05 seconds (example 8)" do
54
54
  sleep 0.05
55
- 8.should == 8
55
+ expect(8).to eq(8)
56
56
  end
57
57
 
58
58
  it "sleeps for 0.05 seconds (example 9)" do
59
59
  sleep 0.05
60
- 9.should == 9
60
+ expect(9).to eq(9)
61
61
  end
62
62
 
63
63
  it "sleeps for 0.05 seconds (example 10)" do
64
64
  sleep 0.05
65
- 10.should == 10
65
+ expect(10).to eq(10)
66
66
  end
67
67
 
68
68
  it "sleeps for 0.05 seconds (example 11)" do
69
69
  sleep 0.05
70
- 11.should == 11
70
+ expect(11).to eq(11)
71
71
  end
72
72
  end
73
73
  """
@@ -186,7 +186,7 @@ Feature: Profile examples
186
186
  describe "something" do
187
187
  it "sleeps for 0.1 seconds (example 1)" do
188
188
  sleep 0.1
189
- 1.should == 1
189
+ expect(1).to eq(1)
190
190
  end
191
191
 
192
192
  it "fails" do
@@ -207,7 +207,7 @@ Feature: Profile examples
207
207
  describe "something" do
208
208
  it "sleeps for 0.1 seconds (example 1)" do
209
209
  sleep 0.1
210
- 1.should == 1
210
+ expect(1).to eq(1)
211
211
  end
212
212
 
213
213
  it "fails" do
@@ -19,16 +19,16 @@ Feature: read command line configuration options from files
19
19
  """
20
20
  And a file named "spec/example_spec.rb" with:
21
21
  """ruby
22
- describe "color" do
22
+ describe "color_enabled" do
23
23
  context "when set with RSpec.configure" do
24
24
  before do
25
25
  # color is disabled for non-tty output, so stub the output stream
26
26
  # to say it is tty, even though we're running this with cucumber
27
- RSpec.configuration.output_stream.stub(:tty?) { true }
27
+ allow(RSpec.configuration.output_stream).to receive(:tty?) { true }
28
28
  end
29
29
 
30
30
  it "is true" do
31
- RSpec.configuration.should be_color_enabled
31
+ expect(RSpec.configuration).to be_color_enabled
32
32
  end
33
33
  end
34
34
  end
@@ -45,8 +45,8 @@ Feature: read command line configuration options from files
45
45
  """ruby
46
46
  describe "formatter set in custom options file" do
47
47
  it "sets formatter" do
48
- RSpec.configuration.formatters.first.
49
- should be_a(RSpec::Core::Formatters::DocumentationFormatter)
48
+ expect(RSpec.configuration.formatters.first).
49
+ to be_a(RSpec::Core::Formatters::DocumentationFormatter)
50
50
  end
51
51
  end
52
52
  """
@@ -66,7 +66,7 @@ Feature: read command line configuration options from files
66
66
  """ruby
67
67
  describe "custom options file" do
68
68
  it "causes .rspec to be ignored" do
69
- RSpec.configuration.color.should be_falsey
69
+ expect(RSpec.configuration.color_enabled).to be_falsey
70
70
  end
71
71
  end
72
72
  """
@@ -82,7 +82,7 @@ Feature: read command line configuration options from files
82
82
  """ruby
83
83
  describe "formatter" do
84
84
  it "is set to documentation" do
85
- RSpec.configuration.formatters.first.should be_an(RSpec::Core::Formatters::DocumentationFormatter)
85
+ expect(RSpec.configuration.formatters.first).to be_an(RSpec::Core::Formatters::DocumentationFormatter)
86
86
  end
87
87
  end
88
88
  """
@@ -23,7 +23,7 @@ Feature: basic structure (describe/it)
23
23
  end
24
24
  end
25
25
  """
26
- When I run `rspec sample_spec.rb -f doc`
26
+ When I run `rspec sample_spec.rb -fn`
27
27
  Then the output should contain:
28
28
  """
29
29
  something
@@ -28,19 +28,19 @@ Feature: shared context
28
28
  include_context "shared stuff"
29
29
 
30
30
  it "has access to methods defined in shared context" do
31
- shared_method.should eq("it works")
31
+ expect(shared_method).to eq("it works")
32
32
  end
33
33
 
34
34
  it "has access to methods defined with let in shared context" do
35
- shared_let['arbitrary'].should eq('object')
35
+ expect(shared_let['arbitrary']).to eq('object')
36
36
  end
37
37
 
38
38
  it "runs the before hooks defined in the shared context" do
39
- @some_var.should be(:some_value)
39
+ expect(@some_var).to be(:some_value)
40
40
  end
41
41
 
42
42
  it "accesses the subject defined in the shared context" do
43
- subject.should eq('this is the subject')
43
+ expect(subject).to eq('this is the subject')
44
44
  end
45
45
  end
46
46
  """
@@ -54,19 +54,19 @@ Feature: shared context
54
54
 
55
55
  describe "group that includes a shared context using metadata", :a => :b do
56
56
  it "has access to methods defined in shared context" do
57
- shared_method.should eq("it works")
57
+ expect(shared_method).to eq("it works")
58
58
  end
59
59
 
60
60
  it "has access to methods defined with let in shared context" do
61
- shared_let['arbitrary'].should eq('object')
61
+ expect(shared_let['arbitrary']).to eq('object')
62
62
  end
63
63
 
64
64
  it "runs the before hooks defined in the shared context" do
65
- @some_var.should be(:some_value)
65
+ expect(@some_var).to be(:some_value)
66
66
  end
67
67
 
68
68
  it "accesses the subject defined in the shared context" do
69
- subject.should eq('this is the subject')
69
+ expect(subject).to eq('this is the subject')
70
70
  end
71
71
  end
72
72
  """
@@ -46,20 +46,20 @@ Feature: shared examples
46
46
 
47
47
  context "initialized with 3 items" do
48
48
  it "says it has three items" do
49
- collection.size.should eq(3)
49
+ expect(collection.size).to eq(3)
50
50
  end
51
51
  end
52
52
 
53
53
  describe "#include?" do
54
54
  context "with an an item that is in the collection" do
55
55
  it "returns true" do
56
- collection.include?(7).should be_truthy
56
+ expect(collection.include?(7)).to be_truthy
57
57
  end
58
58
  end
59
59
 
60
60
  context "with an an item that is not in the collection" do
61
61
  it "returns false" do
62
- collection.include?(9).should be_falsey
62
+ expect(collection.include?(9)).to be_falsey
63
63
  end
64
64
  end
65
65
  end
@@ -146,7 +146,7 @@ Feature: shared examples
146
146
  shared_examples "a measurable object" do |measurement, measurement_methods|
147
147
  measurement_methods.each do |measurement_method|
148
148
  it "should return #{measurement} from ##{measurement_method}" do
149
- subject.send(measurement_method).should == measurement
149
+ expect(subject.send(measurement_method)).to eq(measurement)
150
150
  end
151
151
  end
152
152
  end
@@ -185,7 +185,7 @@ Feature: shared examples
185
185
 
186
186
  shared_examples 'sortability' do
187
187
  it 'responds to <=>' do
188
- sortable.should respond_to(:<=>)
188
+ expect(sortable).to respond_to(:<=>)
189
189
  end
190
190
  end
191
191
 
@@ -282,13 +282,5 @@ Feature: shared examples
282
282
  When I run `rspec isolated_shared_examples_spec.rb`
283
283
  Then the output should contain:
284
284
  """
285
- 1 example, 0 failures
286
- """
287
- But the output should contain:
288
- """
289
- Accessing shared_examples defined across contexts is deprecated
290
- """
291
- And the output should contain:
292
- """
293
- isolated_shared_examples_spec.rb:9
285
+ Could not find shared examples \"shared examples are isolated\"
294
286
  """
@@ -4,16 +4,16 @@ Feature: configure expectation framework
4
4
  desired outcomes. You can also configure RSpec to use:
5
5
 
6
6
  * rspec/expectations (explicitly)
7
- * stdlib assertions **DEPRECATED: Use test/unit or minitest explicitly**
8
- * test/unit assertions
9
- * minitest assertions
10
- * any combination of the above libraries
7
+ * stdlib assertions
8
+ * test/unit assertions in ruby 1.8
9
+ * minitest assertions in ruby 1.9
10
+ * rspec/expectations _and_ stlib assertions
11
11
 
12
- Note that when you do not use rspec-expectations, you must explicitly provide
13
- a description to every example. You cannot rely on the generated descriptions
14
- provided by rspec-expectations.
12
+ Note that when you do not use rspec-expectations, you must explicitly
13
+ provide a description to every example. You cannot rely on the generated
14
+ descriptions provided by rspec-expectations.
15
15
 
16
- Scenario: Default configuration uses rspec-expectations
16
+ Scenario: rspec-expectations can be used by default if nothing is configured
17
17
  Given a file named "example_spec.rb" with:
18
18
  """ruby
19
19
  RSpec::Matchers.define :be_a_multiple_of do |factor|
@@ -23,13 +23,13 @@ Feature: configure expectation framework
23
23
  end
24
24
 
25
25
  describe 6 do
26
- it { is_expected.to be_a_multiple_of 3 }
26
+ it { should be_a_multiple_of(3) }
27
27
  end
28
28
  """
29
29
  When I run `rspec example_spec.rb`
30
30
  Then the examples should all pass
31
31
 
32
- Scenario: Configure rspec-expectations (explicitly)
32
+ Scenario: configure rspec-expectations (explicitly)
33
33
  Given a file named "example_spec.rb" with:
34
34
  """ruby
35
35
  RSpec.configure do |config|
@@ -38,15 +38,14 @@ Feature: configure expectation framework
38
38
 
39
39
  describe 5 do
40
40
  it "is greater than 4" do
41
- 5.should be > 4
41
+ expect(5).to be > 4
42
42
  end
43
43
  end
44
44
  """
45
45
  When I run `rspec example_spec.rb`
46
46
  Then the examples should all pass
47
47
 
48
- @deprecated
49
- Scenario: Configure 'stdlib' assertions
48
+ Scenario: configure test/unit assertions (passing examples)
50
49
  Given a file named "example_spec.rb" with:
51
50
  """ruby
52
51
  RSpec.configure do |config|
@@ -59,138 +58,44 @@ Feature: configure expectation framework
59
58
  end
60
59
 
61
60
  specify { assert 5 < 6 }
62
-
63
- it "is greater than 6 (no it isn't!)" do
64
- assert 5 > 6, "errantly expected 5 to be greater than 5"
65
- end
66
- end
67
- """
68
- When I run `rspec example_spec.rb`
69
- Then the output should match:
70
- """
71
- (Test::Unit::AssertionFailedError|Mini(T|t)est::Assertion):
72
- errantly expected 5 to be greater than 5
73
- """
74
- And the output should contain "3 examples, 1 failure"
75
- And the output should contain ":stdlib is deprecated. Use :test_unit or :minitest instead"
76
-
77
- Scenario: Configure test/unit assertions
78
- Given a file named "example_spec.rb" with:
79
- """ruby
80
- RSpec.configure do |config|
81
- config.expect_with :test_unit
82
- end
83
-
84
- RSpec.describe [1] do
85
- it "is equal to [1]" do
86
- assert_equal [1], [1], "expected [1] to equal [1]"
87
- end
88
-
89
- specify { assert_not_equal [1], [] }
90
-
91
- it "is equal to [2] (intentional failure)" do
92
- assert [1] == [2], "errantly expected [2] to equal [1]"
93
- end
94
61
  end
95
62
  """
96
63
  When I run `rspec example_spec.rb`
97
- Then the output should match:
98
- """
99
- (Test::Unit::AssertionFailedError|Mini(T|t)est::Assertion):
100
- errantly expected \[2\] to equal \[1\]
101
- """
102
- And the output should contain "3 examples, 1 failure"
64
+ Then the output should contain "2 examples, 0 failures"
103
65
 
104
- Scenario: Configure minitest assertions
66
+ Scenario: configure test/unit assertions (failing examples)
105
67
  Given a file named "example_spec.rb" with:
106
68
  """ruby
107
69
  RSpec.configure do |config|
108
- config.expect_with :minitest
109
- end
110
-
111
- RSpec.describe "Object identity" do
112
- it "the an object is the same as itself" do
113
- x = [1]
114
- assert_same x, x, "expected x to be the same x"
115
- end
116
-
117
- specify { refute_same [1], [1] }
118
-
119
- it "is empty (intentional failure)" do
120
- assert_empty [1], "errantly expected [1] to be empty"
121
- end
122
- end
123
- """
124
- When I run `rspec -b example_spec.rb`
125
- Then the output should match:
126
- """
127
- MiniT|test::Assertion:
128
- errantly expected \[1\] to be empty
129
- """
130
- And the output should contain "3 examples, 1 failure"
131
- And the output should not contain "Warning: you should require 'minitest/autorun' instead."
132
-
133
- Scenario: Configure rspec/expectations AND test/unit assertions
134
- Given a file named "example_spec.rb" with:
135
- """ruby
136
- RSpec.configure do |config|
137
- config.expect_with :rspec, :test_unit
138
- end
139
-
140
- RSpec.describe [1] do
141
- it "is equal to [1]" do
142
- assert_equal [1], [1], "expected [1] to equal [1]"
143
- end
144
-
145
- it "matches array [1]" do
146
- is_expected.to match_array([1])
147
- end
148
- end
149
- """
150
- When I run `rspec example_spec.rb`
151
- Then the examples should all pass
152
-
153
- Scenario: Configure rspec/expecations AND minitest assertions
154
- Given a file named "example_spec.rb" with:
155
- """ruby
156
- RSpec.configure do |config|
157
- config.expect_with :rspec, :minitest
70
+ config.expect_with :stdlib
158
71
  end
159
72
 
160
- RSpec.describe "Object identity" do
161
- it "two arrays are not the same object" do
162
- refute_same [1], [1]
73
+ describe 5 do
74
+ it "is greater than 6 (no it isn't!)" do
75
+ assert 5 > 6, "errantly expected 5 to be greater than 5"
163
76
  end
164
77
 
165
- it "an array is itself" do
166
- array = [1]
167
- expect(array).to be array
168
- end
78
+ specify { assert 5 > 6 }
169
79
  end
170
80
  """
171
81
  When I run `rspec example_spec.rb`
172
- Then the examples should all pass
82
+ Then the output should contain "2 examples, 2 failures"
173
83
 
174
- Scenario: Configure test/unit and minitest assertions
84
+ Scenario: configure rspec/expecations AND test/unit assertions
175
85
  Given a file named "example_spec.rb" with:
176
86
  """ruby
177
87
  RSpec.configure do |config|
178
- config.expect_with :test_unit, :minitest
88
+ config.expect_with :rspec, :stdlib
179
89
  end
180
90
 
181
- RSpec.describe [1] do
182
- it "is equal to [1]" do
183
- assert_equal [1], [1], "expected [1] to equal [1]"
91
+ describe 5 do
92
+ it "is greater than 4" do
93
+ assert 5 > 4, "expected 5 to be greater than 4"
184
94
  end
185
95
 
186
- specify { assert_not_equal [1], [] }
187
-
188
- it "the an object is the same as itself" do
189
- x = [1]
190
- assert_same x, x, "expected x to be the same x"
96
+ it "is less than 6" do
97
+ expect(5).to be < 6
191
98
  end
192
-
193
- specify { refute_same [1], [1] }
194
99
  end
195
100
  """
196
101
  When I run `rspec example_spec.rb`