rspec-core 2.4.0 → 2.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (78) hide show
  1. data/.gitignore +1 -0
  2. data/Gemfile +9 -4
  3. data/Guardfile +3 -3
  4. data/README.md +1 -1
  5. data/features/.nav +7 -2
  6. data/features/{README.markdown → Autotest.md} +17 -20
  7. data/features/Changelog.md +57 -2
  8. data/features/README.md +17 -0
  9. data/features/Upgrade.md +8 -66
  10. data/features/command_line/configure.feature +2 -2
  11. data/features/command_line/example_name_option.feature +10 -10
  12. data/features/command_line/exit_status.feature +4 -4
  13. data/features/command_line/line_number_appended_to_path.feature +11 -11
  14. data/features/command_line/line_number_option.feature +9 -9
  15. data/features/command_line/tag.feature +9 -9
  16. data/features/configuration/custom_settings.feature +3 -3
  17. data/features/configuration/fail_fast.feature +3 -3
  18. data/features/configuration/read_options_from_file.feature +4 -4
  19. data/features/example_groups/shared_example_group.feature +4 -4
  20. data/features/expectation_framework_integration/configure_expectation_framework.feature +8 -9
  21. data/features/filtering/exclusion_filters.feature +1 -1
  22. data/features/filtering/run_all_when_everything_filtered.feature +1 -1
  23. data/features/formatters/custom_formatter.feature +17 -13
  24. data/features/helper_methods/arbitrary_methods.feature +40 -0
  25. data/features/helper_methods/let.feature +50 -0
  26. data/features/hooks/before_and_after_hooks.feature +10 -10
  27. data/features/hooks/filtering.feature +37 -20
  28. data/features/metadata/described_class.feature +1 -1
  29. data/features/mock_framework_integration/use_flexmock.feature +1 -1
  30. data/features/mock_framework_integration/use_mocha.feature +1 -1
  31. data/features/mock_framework_integration/use_rr.feature +1 -1
  32. data/features/mock_framework_integration/use_rspec.feature +1 -1
  33. data/features/spec_files/arbitrary_file_suffix.feature +1 -1
  34. data/features/step_definitions/additional_cli_steps.rb +1 -1
  35. data/features/subject/attribute_of_subject.feature +2 -2
  36. data/features/subject/explicit_subject.feature +5 -5
  37. data/features/subject/implicit_receiver.feature +2 -2
  38. data/features/subject/implicit_subject.feature +2 -2
  39. data/lib/autotest/rspec2.rb +63 -13
  40. data/lib/rspec/core/configuration.rb +0 -1
  41. data/lib/rspec/core/configuration_options.rb +15 -12
  42. data/lib/rspec/core/example.rb +14 -6
  43. data/lib/rspec/core/example_group.rb +5 -4
  44. data/lib/rspec/core/formatters/base_formatter.rb +1 -1
  45. data/lib/rspec/core/formatters/documentation_formatter.rb +1 -1
  46. data/lib/rspec/core/formatters/html_formatter.rb +131 -32
  47. data/lib/rspec/core/formatters/snippet_extractor.rb +1 -1
  48. data/lib/rspec/core/hooks.rb +16 -1
  49. data/lib/rspec/core/option_parser.rb +6 -6
  50. data/lib/rspec/core/rake_task.rb +1 -1
  51. data/lib/rspec/core/subject.rb +7 -7
  52. data/lib/rspec/core/version.rb +1 -1
  53. data/rspec-core.gemspec +0 -12
  54. data/script/FullBuildRakeFile +63 -0
  55. data/script/cucumber +1 -0
  56. data/script/full_build +1 -0
  57. data/script/spec +1 -0
  58. data/spec/autotest/failed_results_re_spec.rb +22 -5
  59. data/spec/autotest/rspec_spec.rb +132 -16
  60. data/spec/rspec/core/configuration_options_spec.rb +38 -6
  61. data/spec/rspec/core/example_group_spec.rb +15 -64
  62. data/spec/rspec/core/formatters/base_formatter_spec.rb +23 -0
  63. data/spec/rspec/core/formatters/html_formatted-1.8.6.html +150 -48
  64. data/spec/rspec/core/formatters/html_formatted-1.8.7-jruby.html +151 -49
  65. data/spec/rspec/core/formatters/html_formatted-1.8.7.html +150 -48
  66. data/spec/rspec/core/formatters/html_formatted-1.9.1.html +150 -48
  67. data/spec/rspec/core/formatters/html_formatted-1.9.2.html +150 -48
  68. data/spec/rspec/core/formatters/text_mate_formatted-1.8.6.html +150 -48
  69. data/spec/rspec/core/formatters/text_mate_formatted-1.8.7-jruby.html +151 -49
  70. data/spec/rspec/core/formatters/text_mate_formatted-1.8.7.html +150 -48
  71. data/spec/rspec/core/formatters/text_mate_formatted-1.9.1.html +150 -48
  72. data/spec/rspec/core/formatters/text_mate_formatted-1.9.2.html +150 -48
  73. data/spec/rspec/core/hooks_filtering_spec.rb +49 -0
  74. data/spec/rspec/core/rake_task_spec.rb +3 -3
  75. data/spec/rspec/core/subject_spec.rb +81 -0
  76. metadata +20 -22
  77. data/History.markdown +0 -186
  78. data/Upgrade.markdown +0 -345
@@ -1,8 +1,8 @@
1
- Feature: --line option
1
+ Feature: --line_number option
2
2
 
3
- To run a single example or group, you can use the --line option:
3
+ To run a single example or group, you can use the --line_number option:
4
4
 
5
- rspec path/to/example_spec.rb --line 37
5
+ rspec path/to/example_spec.rb --line_number 37
6
6
 
7
7
  Scenario: standard examples
8
8
  Given a file named "example_spec.rb" with:
@@ -21,10 +21,10 @@ Feature: --line option
21
21
 
22
22
  end
23
23
  """
24
- When I run "rspec example_spec.rb --line 5 --format doc"
25
- Then the output should contain "1 example, 0 failures"
24
+ When I run "rspec example_spec.rb --line_number 5 --format doc"
25
+ Then the examples should all pass
26
26
  Then the output should contain "should be > 8"
27
- But the stdout should not contain "should be < 10"
27
+ But the output should not contain "should be < 10"
28
28
 
29
29
  Scenario: one liner
30
30
  Given a file named "example_spec.rb" with:
@@ -39,7 +39,7 @@ Feature: --line option
39
39
 
40
40
  end
41
41
  """
42
- When I run "rspec example_spec.rb --line 5 --format doc"
43
- Then the output should contain "1 example, 0 failures"
42
+ When I run "rspec example_spec.rb --line_number 5 --format doc"
43
+ Then the examples should all pass
44
44
  Then the output should contain "should be > 8"
45
- But the stdout should not contain "should be < 10"
45
+ But the output should not contain "should be < 10"
@@ -28,17 +28,17 @@ Feature: --tag option
28
28
 
29
29
  Scenario: filter examples with non-existent tag
30
30
  When I run "rspec . --tag mytag"
31
- And the output should contain "0 examples, 0 failures"
31
+ And the examples should all pass
32
32
 
33
33
  Scenario: filter examples with a simple tag
34
34
  When I run "rspec . --tag focus"
35
35
  Then the output should contain "Run filtered using {:focus=>true}"
36
- And the output should contain "1 example, 0 failures"
36
+ And the examples should all pass
37
37
 
38
38
  Scenario: filter examples with a simple tag and @
39
39
  When I run "rspec . --tag @focus"
40
40
  Then the output should contain "Run filtered using {:focus=>true}"
41
- Then the output should contain "1 example, 0 failures"
41
+ Then the examples should all pass
42
42
 
43
43
  Scenario: filter examples with a name:value tag
44
44
  When I run "rspec . --tag type:special"
@@ -46,7 +46,7 @@ Feature: --tag option
46
46
  """
47
47
  Run filtered using {:type=>"special"}
48
48
  """
49
- And the output should contain "1 example, 0 failures"
49
+ And the examples should all pass
50
50
 
51
51
  Scenario: filter examples with a name:value tag and @
52
52
  When I run "rspec . --tag @type:special"
@@ -54,21 +54,21 @@ Feature: --tag option
54
54
  """
55
55
  Run filtered using {:type=>"special"}
56
56
  """
57
- And the output should contain "1 example, 0 failures"
57
+ And the examples should all pass
58
58
 
59
59
  Scenario: exclude examples with a simple tag
60
60
  When I run "rspec . --tag ~skip"
61
- Then the output should contain "4 examples, 0 failures"
61
+ Then the examples should all pass
62
62
 
63
63
  Scenario: exclude examples with a simple tag and @
64
64
  When I run "rspec . --tag ~@skip"
65
- Then the output should contain "4 examples, 0 failures"
65
+ Then the examples should all pass
66
66
 
67
67
  Scenario: exclude examples with a name:value tag
68
68
  When I run "rspec . --tag ~speed:slow"
69
- Then the output should contain "4 examples, 0 failures"
69
+ Then the examples should all pass
70
70
 
71
71
  Scenario: exclude examples with a name:value tag and @
72
72
  When I run "rspec . --tag ~@speed:slow"
73
- Then the output should contain "4 examples, 0 failures"
73
+ Then the examples should all pass
74
74
 
@@ -30,7 +30,7 @@ Feature: custom settings
30
30
  end
31
31
  """
32
32
  When I run "rspec ./additional_setting_spec.rb"
33
- Then the output should contain "0 failures"
33
+ Then the examples should all pass
34
34
 
35
35
  Scenario: default to true
36
36
  Given a file named "additional_setting_spec.rb" with:
@@ -56,7 +56,7 @@ Feature: custom settings
56
56
  end
57
57
  """
58
58
  When I run "rspec ./additional_setting_spec.rb"
59
- Then the output should contain "0 failures"
59
+ Then the examples should all pass
60
60
 
61
61
  Scenario: overridden in a subsequent RSpec.configure block
62
62
  Given a file named "additional_setting_spec.rb" with:
@@ -80,5 +80,5 @@ Feature: custom settings
80
80
  end
81
81
  """
82
82
  When I run "rspec ./additional_setting_spec.rb"
83
- Then the output should contain "0 failures"
83
+ Then the examples should all pass
84
84
 
@@ -1,8 +1,8 @@
1
1
  Feature: fail fast
2
2
 
3
- Use the fail_fast option to tell RSpec to abort the run on first failure.
3
+ Use the fail_fast option to tell RSpec to abort the run on first failure:
4
4
 
5
- RSpec.configure {|c| c.fail_fast = true}
5
+ RSpec.configure {|c| c.fail_fast = true}
6
6
 
7
7
  Background:
8
8
  Given a file named "spec/spec_helper.rb" with:
@@ -22,7 +22,7 @@ Feature: fail fast
22
22
  end
23
23
  """
24
24
  When I run "rspec spec/example_spec.rb"
25
- Then the output should contain "2 examples, 0 failures"
25
+ Then the examples should all pass
26
26
 
27
27
  Scenario: fail_fast with first example failing (only runs the one example)
28
28
  Given a file named "spec/example_spec.rb" with:
@@ -31,7 +31,7 @@ Feature: read command line configuration options from files
31
31
  end
32
32
  """
33
33
  When I run "rspec ./spec/example_spec.rb"
34
- Then the output should contain "1 example, 0 failures"
34
+ Then the examples should all pass
35
35
 
36
36
  Scenario: custom options file
37
37
  Given a file named "my.options" with:
@@ -48,7 +48,7 @@ Feature: read command line configuration options from files
48
48
  end
49
49
  """
50
50
  When I run "rspec spec/example_spec.rb --options my.options"
51
- Then the output should contain "1 example, 0 failures"
51
+ Then the examples should all pass
52
52
 
53
53
  Scenario: RSpec ignores ./.rspec when custom options file is used
54
54
  Given a file named "my.options" with:
@@ -68,7 +68,7 @@ Feature: read command line configuration options from files
68
68
  end
69
69
  """
70
70
  When I run "rspec spec/example_spec.rb --options my.options"
71
- Then the output should contain "1 example, 0 failures"
71
+ Then the examples should all pass
72
72
 
73
73
  Scenario: using ERB in .rspec
74
74
  Given a file named ".rspec" with:
@@ -84,4 +84,4 @@ Feature: read command line configuration options from files
84
84
  end
85
85
  """
86
86
  When I run "rspec ./spec/example_spec.rb"
87
- Then the output should contain "1 example, 0 failures"
87
+ Then the examples should all pass
@@ -46,7 +46,7 @@ Feature: shared example group
46
46
  end
47
47
  """
48
48
  When I run "rspec collection_spec.rb --format documentation"
49
- Then the output should contain "6 examples, 0 failures"
49
+ Then the examples should all pass
50
50
  And the output should contain:
51
51
  """
52
52
  Array
@@ -98,7 +98,7 @@ Feature: shared example group
98
98
  end
99
99
  """
100
100
  When I run "rspec shared_example_group_spec.rb --format documentation"
101
- Then the output should contain "2 examples, 0 failures"
101
+ Then the examples should all pass
102
102
  And the output should contain:
103
103
  """
104
104
  Array
@@ -134,7 +134,7 @@ Feature: shared example group
134
134
  end
135
135
  """
136
136
  When I run "rspec shared_example_group_params_spec.rb --format documentation"
137
- Then the output should contain "4 examples, 0 failures"
137
+ Then the examples should all pass
138
138
  And the output should contain:
139
139
  """
140
140
  Array with 3 items
@@ -168,7 +168,7 @@ Feature: shared example group
168
168
  end
169
169
  """
170
170
  When I run "rspec shared_example_group_spec.rb --format documentation"
171
- Then the output should contain "1 example, 0 failures"
171
+ Then the examples should all pass
172
172
  And the output should contain:
173
173
  """
174
174
  String
@@ -3,9 +3,11 @@ Feature: configure expectation framework
3
3
  By default, RSpec is configured to include rspec-expectations for expressing
4
4
  desired outcomes. You can also configure RSpec to use:
5
5
 
6
- rspec/expectations (explicitly)
7
- test/unit/assertions
8
- rspec/expecations _and_ test/unit assertions
6
+ * rspec/expectations (explicitly)
7
+ * stdlib assertions
8
+ * test/unit assertions in ruby 1.8
9
+ * minitest assertions in ruby 1.9
10
+ * rspec/expecations _and_ stlib assertions
9
11
 
10
12
  Scenario: configure rspec-expectations (explicitly)
11
13
  Given a file named "example_spec.rb" with:
@@ -21,8 +23,7 @@ Feature: configure expectation framework
21
23
  end
22
24
  """
23
25
  When I run "rspec example_spec.rb"
24
- Then the output should contain "1 example, 0 failures"
25
- And the exit status should be 0
26
+ Then the examples should all pass
26
27
 
27
28
  Scenario: configure test/unit assertions
28
29
  Given a file named "example_spec.rb" with:
@@ -38,8 +39,7 @@ Feature: configure expectation framework
38
39
  end
39
40
  """
40
41
  When I run "rspec example_spec.rb"
41
- Then the output should contain "1 example, 0 failures"
42
- And the exit status should be 0
42
+ Then the examples should all pass
43
43
 
44
44
  Scenario: configure rspec/expecations AND test/unit assertions
45
45
  Given a file named "example_spec.rb" with:
@@ -59,5 +59,4 @@ Feature: configure expectation framework
59
59
  end
60
60
  """
61
61
  When I run "rspec example_spec.rb"
62
- Then the output should contain "2 examples, 0 failures"
63
- And the exit status should be 0
62
+ Then the examples should all pass
@@ -79,7 +79,7 @@ Feature: exclusion filters
79
79
  """
80
80
  When I run "rspec ./spec/sample_spec.rb --format doc"
81
81
  Then the output should match /No examples were matched. Perhaps \{.*:broken=>true.*\} is excluding everything?/
82
- And the output should contain "0 examples, 0 failures"
82
+ And the examples should all pass
83
83
  And the output should not contain "group 1"
84
84
  And the output should not contain "group 2"
85
85
 
@@ -33,7 +33,7 @@ Feature: run all when everything filtered
33
33
  """
34
34
  When I run "rspec spec/sample_spec.rb --format doc"
35
35
  Then the output should contain "No examples were matched by {:focus=>true}, running all"
36
- And the output should contain "3 examples, 0 failures"
36
+ And the examples should all pass
37
37
  And the output should contain:
38
38
  """
39
39
  group 1
@@ -1,32 +1,36 @@
1
1
  Feature: custom formatters
2
2
 
3
- In order to format output/reporting to my particular needs
4
- As an RSpec user
5
- I want to create my own custom output formatters
3
+ RSpec ships with general purpose output formatters. You can tell RSpec which
4
+ one to use using the [`--format` command line
5
+ option]('../command_line/format_option').
6
+
7
+ When RSpec's built-in output formatters don't, however, give you everything
8
+ you need, you can write your own custom formatter and tell RSpec to use that
9
+ one instead. The simplest way is to subclass RSpec's `BaseTextFormatter`,
10
+ and then override just the methods that you want to modify.
6
11
 
7
- @wip
8
- Scenario: specdoc format
12
+ Scenario: custom formatter
9
13
  Given a file named "custom_formatter.rb" with:
10
14
  """
11
- require "rspec/runner/formatter/base_formatter"
15
+ require "rspec/core/formatters/base_text_formatter"
12
16
 
13
- class CustomFormatter < RSpec::Runner::Formatter::BaseFormatter
14
- def initialize(options, output)
15
- @output = output
17
+ class CustomFormatter < RSpec::Core::Formatters::BaseTextFormatter
18
+ def initialize(output)
19
+ super(output)
16
20
  end
21
+
17
22
  def example_started(proxy)
18
- @output << "example: " << proxy.description
23
+ output << "example: " << proxy.description
19
24
  end
20
25
  end
21
26
  """
22
- And a file named "simple_example_spec.rb" with:
27
+ And a file named "example_spec.rb" with:
23
28
  """
24
29
  describe "my group" do
25
30
  specify "my example" do
26
31
  end
27
32
  end
28
33
  """
29
-
30
- When I run "rspec ./simple_example_spec.rb --require custom_formatter.rb --format CustomFormatter"
34
+ When I run "rspec example_spec.rb --require ./custom_formatter.rb --format CustomFormatter"
31
35
  Then the output should contain "example: my example"
32
36
  And the exit status should be 0
@@ -0,0 +1,40 @@
1
+ Feature: arbitrary helper methods
2
+
3
+ You can define methods in any example group using Ruby's `def` keyword or
4
+ `define_method` method. These _helper_ methods are exposed to examples in the
5
+ group in which they are defined and groups nested within that group, but not
6
+ parent or sibling groups.
7
+
8
+ Scenario: use a method defined in the same group
9
+ Given a file named "example_spec.rb" with:
10
+ """
11
+ describe "an example" do
12
+ def help
13
+ :available
14
+ end
15
+
16
+ it "has access to methods defined in its group" do
17
+ help.should be(:available)
18
+ end
19
+ end
20
+ """
21
+ When I run "rspec example_spec.rb"
22
+ Then the examples should all pass
23
+
24
+ Scenario: use a method defined in a parent group
25
+ Given a file named "example_spec.rb" with:
26
+ """
27
+ describe "an example" do
28
+ def help
29
+ :available
30
+ end
31
+
32
+ describe "in a nested group" do
33
+ it "has access to methods defined in its parent group" do
34
+ help.should be(:available)
35
+ end
36
+ end
37
+ end
38
+ """
39
+ When I run "rspec example_spec.rb"
40
+ Then the examples should all pass
@@ -0,0 +1,50 @@
1
+ Feature: let and let!
2
+
3
+ Use `let` to define a memoized helper method. The value will be cached
4
+ across multiple calls in the same example but not across examples.
5
+
6
+ Note that `let` is lazy-evaluated: it is not evaluated until the first time
7
+ the method it defines is invoked. You can use `let!` to force the method's
8
+ invocation before each example.
9
+
10
+ Scenario: use let to define memoized helper method
11
+ Given a file named "let_spec.rb" with:
12
+ """
13
+ $count = 0
14
+ describe "let" do
15
+ let(:count) { $count += 1 }
16
+
17
+ it "memoizes the value" do
18
+ count.should == 1
19
+ count.should == 1
20
+ end
21
+
22
+ it "is not cached across examples" do
23
+ count.should == 2
24
+ end
25
+ end
26
+ """
27
+ When I run "rspec let_spec.rb"
28
+ Then the examples should all pass
29
+
30
+ Scenario: use let! to define a memoized helper method that is called in a before hook
31
+ Given a file named "let_bang_spec.rb" with:
32
+ """
33
+ $count = 0
34
+ describe "let!" do
35
+ invocation_order = []
36
+
37
+ let!(:count) do
38
+ invocation_order << :let!
39
+ $count += 1
40
+ end
41
+
42
+ it "calls the helper method in a before hook" do
43
+ invocation_order << :example
44
+ invocation_order.should == [:let!, :example]
45
+ count.should == 1
46
+ end
47
+ end
48
+ """
49
+ When I run "rspec let_bang_spec.rb"
50
+ Then the examples should all pass
@@ -53,7 +53,7 @@ Feature: before and after hooks
53
53
  end
54
54
  """
55
55
  When I run "rspec ./before_each_spec.rb"
56
- Then the output should contain "3 examples, 0 failures"
56
+ Then the examples should all pass
57
57
 
58
58
  Scenario: define before(:all) block in example group
59
59
  Given a file named "before_all_spec.rb" with:
@@ -87,10 +87,10 @@ Feature: before and after hooks
87
87
  end
88
88
  """
89
89
  When I run "rspec ./before_all_spec.rb"
90
- Then the output should contain "3 examples, 0 failures"
90
+ Then the examples should all pass
91
91
 
92
92
  When I run "rspec ./before_all_spec.rb:15"
93
- Then the output should contain "1 example, 0 failures"
93
+ Then the examples should all pass
94
94
 
95
95
  Scenario: failure in before(:all) block
96
96
  Given a file named "before_all_spec.rb" with:
@@ -166,7 +166,7 @@ Feature: before and after hooks
166
166
  end
167
167
  """
168
168
  When I run "rspec after_all_spec.rb"
169
- Then the output should contain "2 examples, 0 failures"
169
+ Then the examples should all pass
170
170
  And the output should contain:
171
171
  """
172
172
  An error occurred in an after(:all) hook.
@@ -201,7 +201,7 @@ Feature: before and after hooks
201
201
  end
202
202
  """
203
203
  When I run "rspec ./befores_in_configuration_spec.rb"
204
- Then the output should contain "2 examples, 0 failures"
204
+ Then the examples should all pass
205
205
 
206
206
  Scenario: before/after blocks are run in order
207
207
  Given a file named "ensure_block_order_spec.rb" with:
@@ -317,7 +317,7 @@ Feature: before and after hooks
317
317
  end
318
318
  """
319
319
  When I run "rspec ./before_and_after_all_spec.rb"
320
- Then the output should contain "2 examples, 0 failures"
320
+ Then the examples should all pass
321
321
  And the output should contain:
322
322
  """
323
323
  outer before all
@@ -327,7 +327,7 @@ Feature: before and after hooks
327
327
  """
328
328
 
329
329
  When I run "rspec ./before_and_after_all_spec.rb:14"
330
- Then the output should contain "1 example, 0 failures"
330
+ Then the examples should all pass
331
331
  And the output should contain:
332
332
  """
333
333
  outer before all
@@ -337,7 +337,7 @@ Feature: before and after hooks
337
337
  """
338
338
 
339
339
  When I run "rspec ./before_and_after_all_spec.rb:6"
340
- Then the output should contain "1 example, 0 failures"
340
+ Then the examples should all pass
341
341
  And the output should contain:
342
342
  """
343
343
  outer before all
@@ -372,7 +372,7 @@ Feature: before and after hooks
372
372
  end
373
373
  """
374
374
  When I run "rspec before_all_spec.rb"
375
- Then the output should contain "3 examples, 0 failures"
375
+ Then the examples should all pass
376
376
 
377
377
  Scenario: before/after all blocks have access to state
378
378
  Given a file named "before_and_after_all_spec.rb" with:
@@ -408,7 +408,7 @@ Feature: before and after hooks
408
408
  end
409
409
  """
410
410
  When I run "rspec ./before_and_after_all_spec.rb"
411
- Then the output should contain "2 examples, 0 failures"
411
+ Then the examples should all pass
412
412
 
413
413
  Scenario: exception in before(:each) is captured and reported as failure
414
414
  Given a file named "error_in_before_each_spec.rb" with: