rspec-core 2.6.0 → 2.7.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 (113) hide show
  1. data/README.md +1 -1
  2. data/features/Upgrade.md +11 -0
  3. data/features/command_line/exit_status.feature +20 -3
  4. data/features/command_line/format_option.feature +8 -0
  5. data/features/command_line/line_number_appended_to_path.feature +35 -1
  6. data/features/command_line/line_number_option.feature +16 -3
  7. data/features/command_line/pattern_option.feature +31 -0
  8. data/features/command_line/rake_task.feature +1 -1
  9. data/features/command_line/ruby.feature +22 -0
  10. data/features/configuration/default_path.feature +38 -0
  11. data/features/example_groups/{shared_example_group.feature → shared_examples.feature} +49 -26
  12. data/features/expectation_framework_integration/configure_expectation_framework.feature +1 -1
  13. data/features/filtering/inclusion_filters.feature +4 -5
  14. data/features/formatters/text_formatter.feature +16 -13
  15. data/features/helper_methods/let.feature +4 -4
  16. data/features/hooks/around_hooks.feature +1 -1
  17. data/features/hooks/before_and_after_hooks.feature +3 -3
  18. data/features/hooks/filtering.feature +13 -6
  19. data/features/metadata/user_defined.feature +12 -10
  20. data/features/pending/pending_examples.feature +21 -8
  21. data/features/step_definitions/additional_cli_steps.rb +1 -1
  22. data/features/subject/attribute_of_subject.feature +2 -2
  23. data/features/support/env.rb +1 -2
  24. data/lib/rspec/core/backward_compatibility.rb +1 -1
  25. data/lib/rspec/core/configuration.rb +71 -16
  26. data/lib/rspec/core/configuration_options.rb +46 -16
  27. data/lib/rspec/core/{extensions/object.rb → dsl.rb} +2 -4
  28. data/lib/rspec/core/example.rb +10 -7
  29. data/lib/rspec/core/example_group.rb +34 -18
  30. data/lib/rspec/core/expecting/with_rspec.rb +0 -2
  31. data/lib/rspec/core/extensions.rb +0 -1
  32. data/lib/rspec/core/formatters/base_formatter.rb +8 -4
  33. data/lib/rspec/core/formatters/base_text_formatter.rb +38 -18
  34. data/lib/rspec/core/formatters/html_formatter.rb +3 -1
  35. data/lib/rspec/core/formatters/snippet_extractor.rb +9 -3
  36. data/lib/rspec/core/formatters/text_mate_formatter.rb +20 -6
  37. data/lib/rspec/core/hooks.rb +7 -6
  38. data/lib/rspec/core/let.rb +5 -5
  39. data/lib/rspec/core/metadata.rb +136 -94
  40. data/lib/rspec/core/metadata_hash_builder.rb +1 -1
  41. data/lib/rspec/core/option_parser.rb +11 -7
  42. data/lib/rspec/core/pending.rb +2 -1
  43. data/lib/rspec/core/rake_task.rb +26 -15
  44. data/lib/rspec/core/reporter.rb +5 -6
  45. data/lib/rspec/core/runner.rb +1 -1
  46. data/lib/rspec/core/shared_example_group.rb +4 -4
  47. data/lib/rspec/core/subject.rb +7 -7
  48. data/lib/rspec/core/version.rb +1 -1
  49. data/lib/rspec/core/world.rb +9 -13
  50. data/lib/rspec/core.rb +14 -21
  51. data/spec/autotest/discover_spec.rb +2 -2
  52. data/spec/autotest/failed_results_re_spec.rb +29 -21
  53. data/spec/autotest/rspec_spec.rb +3 -3
  54. data/spec/rspec/core/command_line_spec.rb +1 -6
  55. data/spec/rspec/core/configuration_options_spec.rb +111 -27
  56. data/spec/rspec/core/configuration_spec.rb +161 -37
  57. data/spec/rspec/core/deprecations_spec.rb +2 -2
  58. data/spec/rspec/core/drb_command_line_spec.rb +6 -6
  59. data/spec/rspec/core/example_group_spec.rb +197 -61
  60. data/spec/rspec/core/example_spec.rb +33 -16
  61. data/spec/rspec/core/formatters/base_formatter_spec.rb +3 -3
  62. data/spec/rspec/core/formatters/base_text_formatter_spec.rb +222 -71
  63. data/spec/rspec/core/formatters/helpers_spec.rb +8 -8
  64. data/spec/rspec/core/formatters/html_formatted-1.8.7-jruby.html +90 -26
  65. data/spec/rspec/core/formatters/html_formatted-1.8.7.html +12 -11
  66. data/spec/rspec/core/formatters/html_formatted-1.9.2.html +12 -11
  67. data/spec/rspec/core/formatters/{html_formatted-1.9.1.html → html_formatted-1.9.3.html} +12 -11
  68. data/spec/rspec/core/formatters/html_formatter_spec.rb +5 -5
  69. data/spec/rspec/core/formatters/progress_formatter_spec.rb +2 -2
  70. data/spec/rspec/core/formatters/snippet_extractor_spec.rb +2 -2
  71. data/spec/rspec/core/formatters/text_mate_formatted-1.8.7-jruby.html +91 -27
  72. data/spec/rspec/core/formatters/text_mate_formatted-1.8.7.html +13 -12
  73. data/spec/rspec/core/formatters/text_mate_formatted-1.9.2.html +29 -28
  74. data/spec/rspec/core/formatters/{text_mate_formatted-1.9.1.html → text_mate_formatted-1.9.3.html} +29 -28
  75. data/spec/rspec/core/formatters/text_mate_formatter_spec.rb +2 -2
  76. data/spec/rspec/core/hooks_filtering_spec.rb +18 -18
  77. data/spec/rspec/core/let_spec.rb +19 -6
  78. data/spec/rspec/core/metadata_spec.rb +146 -61
  79. data/spec/rspec/core/pending_example_spec.rb +4 -4
  80. data/spec/rspec/core/rake_task_spec.rb +71 -50
  81. data/spec/rspec/core/reporter_spec.rb +2 -2
  82. data/spec/rspec/core/ruby_project_spec.rb +2 -2
  83. data/spec/rspec/core/runner_spec.rb +4 -1
  84. data/spec/rspec/core/shared_example_group_spec.rb +15 -119
  85. data/spec/rspec/core/subject_spec.rb +13 -13
  86. data/spec/rspec/core/world_spec.rb +31 -22
  87. data/spec/rspec/core_spec.rb +1 -29
  88. data/spec/spec_helper.rb +51 -50
  89. data/spec/support/shared_example_groups.rb +3 -3
  90. data/spec/support/spec_files.rb +8 -8
  91. metadata +79 -94
  92. data/.document +0 -5
  93. data/.gitignore +0 -12
  94. data/.rspec +0 -0
  95. data/.travis.yml +0 -7
  96. data/Gemfile +0 -50
  97. data/Guardfile +0 -5
  98. data/License.txt +0 -23
  99. data/Rakefile +0 -89
  100. data/cucumber.yml +0 -2
  101. data/features/.nav +0 -57
  102. data/features/Changelog.md +0 -269
  103. data/rspec-core.gemspec +0 -24
  104. data/script/FullBuildRakeFile +0 -63
  105. data/script/console +0 -8
  106. data/script/cucumber +0 -1
  107. data/script/full_build +0 -1
  108. data/script/spec +0 -1
  109. data/spec/rspec/core/formatters/html_formatted-1.8.6.html +0 -398
  110. data/spec/rspec/core/formatters/text_mate_formatted-1.8.6.html +0 -398
  111. data/spec.txt +0 -1126
  112. /data/{bin → exe}/autospec +0 -0
  113. /data/{bin → exe}/rspec +0 -0
data/README.md CHANGED
@@ -3,7 +3,7 @@
3
3
  RSpec Core provides the structure for writing executable examples of how your
4
4
  code should behave.
5
5
 
6
- [![build status](http://travis-ci.org/rspec/rspec-core.png)](http://travis-ci.org/rspec/rspec-core)
6
+ [![build status](https://secure.travis-ci.org/rspec/rspec-core.png)](http://travis-ci.org/rspec/rspec-core)
7
7
 
8
8
  ## Documentation
9
9
 
data/features/Upgrade.md CHANGED
@@ -1,3 +1,14 @@
1
+ # rspec-core-2.7 (not yet released - coming soon)
2
+
3
+ ## `--default_path`
4
+
5
+ Add the following to `.rspec`:
6
+
7
+ # in .rspec
8
+ --default_path spec
9
+
10
+ And now you can just type `rspec` to run all the specs in the `spec` directory.
11
+
1
12
  # rspec-core-2.6
2
13
 
3
14
  ## new APIs for sharing content
@@ -1,7 +1,7 @@
1
1
  Feature: exit status
2
2
 
3
- In order to fail the build when it should, the spec CLI exits with an
4
- appropriate exit status
3
+ The rspec command exits with an exit status of 0 if all examples pass,
4
+ and 1 if any examples fail.
5
5
 
6
6
  Scenario: exit with 0 when all examples pass
7
7
  Given a file named "ok_spec.rb" with:
@@ -42,7 +42,7 @@ Feature: exit status
42
42
  When I run `rspec nested_ko_spec.rb`
43
43
  Then the exit status should be 1
44
44
  And the output should contain "1 example, 1 failure"
45
-
45
+
46
46
  Scenario: exit with 0 when no examples are run
47
47
  Given a file named "a_no_examples_spec.rb" with:
48
48
  """
@@ -50,3 +50,20 @@ Feature: exit status
50
50
  When I run `rspec a_no_examples_spec.rb`
51
51
  Then the exit status should be 0
52
52
  And the output should contain "0 examples"
53
+
54
+ @wip
55
+ Scenario: exit with rspec's exit code when an at_exit hook is added upstream
56
+ Given a file named "exit_at_spec.rb" with:
57
+ """
58
+ require 'rspec/autorun'
59
+
60
+ describe "exit 0 at_exit" do
61
+ it "does not interfere with rspec's exit code" do
62
+ at_exit { exit 0 }
63
+ fail
64
+ end
65
+ end
66
+ """
67
+ When I run `rspec exit_at_spec.rb`
68
+ Then the exit status should be 1
69
+ And the output should contain "1 example, 1 failure"
@@ -19,6 +19,14 @@ Feature: --format option
19
19
 
20
20
  $ rspec spec --format documentation:rspec.output.txt
21
21
 
22
+ `rspec --help` lists available formatters:
23
+
24
+ [p]rogress (default - dots)
25
+ [d]ocumentation (group and example names)
26
+ [h]tml
27
+ [t]extmate
28
+ custom formatter class name
29
+
22
30
  Background:
23
31
  Given a file named "example_spec.rb" with:
24
32
  """
@@ -1,6 +1,6 @@
1
1
  Feature: line number appended to file path
2
2
 
3
- To run a single example or group, you can append the line number to the path, e.g.
3
+ To run one or more examples or groups, you can append the line number to the path, e.g.
4
4
 
5
5
  rspec path/to/example_spec.rb:37
6
6
 
@@ -27,6 +27,15 @@ Feature: line number appended to file path
27
27
 
28
28
  end
29
29
  """
30
+ And a file named "example2_spec.rb" with:
31
+ """
32
+ describe "yet another group" do
33
+ it "first example in second file" do
34
+ end
35
+ it "second example in second file" do
36
+ end
37
+ end
38
+ """
30
39
 
31
40
  Scenario: nested groups - outer group on declaration line
32
41
  When I run `rspec example_spec.rb:1 --format doc`
@@ -104,3 +113,28 @@ Feature: line number appended to file path
104
113
  And the output should contain "second example in outer group"
105
114
  But the output should not contain "first example in outer group"
106
115
  And the output should not contain "example in nested group"
116
+
117
+ Scenario: specified multiple times for different files
118
+ When I run `rspec example_spec.rb:7 example2_spec.rb:4 --format doc`
119
+ Then the examples should all pass
120
+ And the output should contain "second example in outer group"
121
+ And the output should contain "second example in second file"
122
+ But the output should not contain "first example in outer group"
123
+ And the output should not contain "nested group"
124
+ And the output should not contain "first example in second file"
125
+
126
+ Scenario: specified multiple times for the same file with multiple arguments
127
+ When I run `rspec example_spec.rb:7 example_spec.rb:11 --format doc`
128
+ Then the examples should all pass
129
+ And the output should contain "second example in outer group"
130
+ And the output should contain "nested group"
131
+ But the output should not contain "first example in outer group"
132
+ And the output should not contain "second file"
133
+
134
+ Scenario: specified multiple times for the same file with a single argument
135
+ When I run `rspec example_spec.rb:7:11 --format doc`
136
+ Then the examples should all pass
137
+ And the output should contain "second example in outer group"
138
+ And the output should contain "nested group"
139
+ But the output should not contain "first example in outer group"
140
+ And the output should not contain "second file"
@@ -1,9 +1,11 @@
1
1
  Feature: --line_number option
2
2
 
3
- To run a single example or group, you can use the --line_number option:
3
+ To run a examples or groups by line numbers, one can use the --line_number option:
4
4
 
5
5
  rspec path/to/example_spec.rb --line_number 37
6
6
 
7
+ This option can be specified multiple times.
8
+
7
9
  Scenario: standard examples
8
10
  Given a file named "example_spec.rb" with:
9
11
  """
@@ -18,13 +20,24 @@ Feature: --line_number option
18
20
  it "should be < 10" do
19
21
  9.should be < 10
20
22
  end
21
-
23
+
24
+ it "should be 3 squared" do
25
+ 9.should be 3*3
26
+ end
27
+
22
28
  end
23
29
  """
24
30
  When I run `rspec example_spec.rb --line_number 5 --format doc`
25
31
  Then the examples should all pass
26
- Then the output should contain "should be > 8"
32
+ And the output should contain "should be > 8"
27
33
  But the output should not contain "should be < 10"
34
+ And the output should not contain "should be 3*3"
35
+
36
+ When I run `rspec example_spec.rb --line_number 5 --line_number 9 --format doc`
37
+ Then the examples should all pass
38
+ And the output should contain "should be > 8"
39
+ And the output should contain "should be < 10"
40
+ But the output should not contain "should be 3*3"
28
41
 
29
42
  Scenario: one liner
30
43
  Given a file named "example_spec.rb" with:
@@ -0,0 +1,31 @@
1
+ Feature: pattern option
2
+
3
+ By default, RSpec loads files matching the pattern:
4
+
5
+ "spec/**/*_spec.rb"
6
+
7
+ Use the `--pattern` option to declare a different pattern.
8
+
9
+ Scenario: default pattern
10
+ Given a file named "spec/example_spec.rb" with:
11
+ """
12
+ describe "addition" do
13
+ it "adds things" do
14
+ (1 + 2).should eq(3)
15
+ end
16
+ end
17
+ """
18
+ When I run `rspec`
19
+ Then the output should contain "1 example, 0 failures"
20
+
21
+ Scenario: override the default pattern on the command line
22
+ Given a file named "spec/example.spec" with:
23
+ """
24
+ describe "addition" do
25
+ it "adds things" do
26
+ (1 + 2).should eq(3)
27
+ end
28
+ end
29
+ """
30
+ When I run `rspec --pattern "spec/**/*.spec"`
31
+ Then the output should contain "1 example, 0 failures"
@@ -20,7 +20,7 @@ Feature: rake task
20
20
  end
21
21
  """
22
22
  When I run `rake`
23
- Then the stderr should contain "ruby -S rspec"
23
+ Then the output should contain "ruby -S rspec"
24
24
  Then the exit status should be 0
25
25
 
26
26
  Scenario: default options with failing spec (exit status is 1)
@@ -0,0 +1,22 @@
1
+ Feature: run with ruby command
2
+
3
+ You can use the `ruby` command to run specs. You just need to require
4
+ `rspec/autorun`.
5
+
6
+ Generally speaking, you're better off using the `rspec` command, which
7
+ requires `rspec/autorun` for you, but some tools only work with the `ruby`
8
+ command.
9
+
10
+ Scenario:
11
+ Given a file named "example_spec.rb" with:
12
+ """
13
+ require 'rspec/autorun'
14
+
15
+ describe 1 do
16
+ it "is < 2" do
17
+ 1.should be < 2
18
+ end
19
+ end
20
+ """
21
+ When I run `ruby example_spec.rb`
22
+ Then the output should contain "1 example, 0 failures"
@@ -0,0 +1,38 @@
1
+ Feature: default_path
2
+
3
+ As of rspec-2.7 (not yet released), you can just type `rspec` to run all
4
+ specs that live in the `spec` directory.
5
+
6
+ This is supported by a `--default_path` option, which is set to `spec` by
7
+ default. If you prefer to keep your specs in a different directory, or assign
8
+ an individual file to `--default_path`, you can do so on the command line or
9
+ in a configuration file (`.rspec`, `~/.rspec`, or a custom file).
10
+
11
+ NOTE: this option is not supported on `RSpec.configuration`, as it needs to
12
+ be set before spec files are loaded.
13
+
14
+ Scenario: run `rspec` with default default_path (`spec` directory)
15
+ Given a file named "spec/example_spec.rb" with:
16
+ """
17
+ describe "an example" do
18
+ it "passes" do
19
+ end
20
+ end
21
+ """
22
+ When I run `rspec`
23
+ Then the output should contain "1 example, 0 failures"
24
+
25
+ Scenario: run `rspec` with customized default_path
26
+ Given a file named ".rspec" with:
27
+ """
28
+ --default_path behavior
29
+ """
30
+ Given a file named "behavior/example_spec.rb" with:
31
+ """
32
+ describe "an example" do
33
+ it "passes" do
34
+ end
35
+ end
36
+ """
37
+ When I run `rspec`
38
+ Then the output should contain "1 example, 0 failures"
@@ -8,47 +8,70 @@ Feature: shared examples
8
8
  A shared group is included in another group using any of:
9
9
 
10
10
  include_examples "name" # include the examples in the current context
11
-
12
11
  it_behaves_like "name" # include the examples in a nested context
13
12
  it_should_behave_like "name" # include the examples in a nested context
14
13
 
15
- Scenario: shared examples group included in two groups
14
+ WARNING: Files containing shared groups must be loaded before the files that
15
+ use them. While there are conventions to handle this, RSpec does _not_ do
16
+ anything special (like autoload). Doing so would require a strict naming
17
+ convention for files that would break existing suites.
18
+
19
+ CONVENTIONS:
20
+
21
+ 1. The simplest approach is to require files with shared examples explicitly
22
+ from the files that use them. Keep in mind that RSpec adds the `spec`
23
+ directory to the `LOAD_PATH`, so you can say `require
24
+ 'shared_examples_for_widgets'` to require a file at
25
+ `#{PROJECT_ROOT}/spec/shared_examples_for_widgets.rb`.
26
+
27
+ 2. Put files containing shared examples in `spec/support/` and require files
28
+ in that directory from `spec/spec_helper.rb`:
29
+
30
+ Dir["spec/support/**/*.rb"].each {|f| require f}
31
+
32
+ This is included in the generated `spec/spec_helper.rb` file in
33
+ `rspec-rails`
34
+
35
+ 3. When all of the groups that include the shared group, just declare
36
+ the shared group in the same file.
37
+
38
+ Scenario: shared examples group included in two groups in one file
16
39
  Given a file named "collection_spec.rb" with:
17
- """
18
- require "set"
40
+ """
41
+ require "set"
19
42
 
20
- shared_examples "a collection" do
21
- let(:collection) { described_class.new([7, 2, 4]) }
43
+ shared_examples "a collection" do
44
+ let(:collection) { described_class.new([7, 2, 4]) }
22
45
 
23
- context "initialized with 3 items" do
24
- it "says it has three items" do
25
- collection.size.should eq(3)
46
+ context "initialized with 3 items" do
47
+ it "says it has three items" do
48
+ collection.size.should eq(3)
49
+ end
26
50
  end
27
- end
28
51
 
29
- describe "#include?" do
30
- context "with an an item that is in the collection" do
31
- it "returns true" do
32
- collection.include?(7).should be_true
52
+ describe "#include?" do
53
+ context "with an an item that is in the collection" do
54
+ it "returns true" do
55
+ collection.include?(7).should be_true
56
+ end
33
57
  end
34
- end
35
58
 
36
- context "with an an item that is not in the collection" do
37
- it "returns false" do
38
- collection.include?(9).should be_false
59
+ context "with an an item that is not in the collection" do
60
+ it "returns false" do
61
+ collection.include?(9).should be_false
62
+ end
39
63
  end
40
64
  end
41
65
  end
42
- end
43
66
 
44
- describe Array do
45
- it_behaves_like "a collection"
46
- end
67
+ describe Array do
68
+ it_behaves_like "a collection"
69
+ end
47
70
 
48
- describe Set do
49
- it_behaves_like "a collection"
50
- end
51
- """
71
+ describe Set do
72
+ it_behaves_like "a collection"
73
+ end
74
+ """
52
75
  When I run `rspec collection_spec.rb --format documentation`
53
76
  Then the examples should all pass
54
77
  And the output should contain:
@@ -64,7 +64,7 @@ Feature: configure expectation framework
64
64
  assert 5 > 4, "expected 5 to be greater than 4"
65
65
  end
66
66
 
67
- it "is less than 4" do
67
+ it "is less than 6" do
68
68
  5.should be < 6
69
69
  end
70
70
  end
@@ -1,18 +1,17 @@
1
1
  Feature: inclusion filters
2
2
 
3
- You can restrict which examples are run by declaring an inclusion filter. The
3
+ You can constrain which examples are run by declaring an inclusion filter. The
4
4
  most common use case is to focus on a subset of examples as you're focused on
5
5
  a particular problem.
6
6
 
7
- If you set the `treat_symbols_as_metadata_keys_with_true_values` config option
8
- to `true`, you can specify metadata using only symbols.
7
+ You can specify metadata using only symbols if you set the
8
+ `treat_symbols_as_metadata_keys_with_true_values` config option to `true`.
9
9
 
10
10
  Background:
11
11
  Given a file named "spec/spec_helper.rb" with:
12
12
  """
13
13
  RSpec.configure do |c|
14
- # filter_run is short-form alias for filter_run_including
15
- c.filter_run :focus => true
14
+ c.filter_run_including :focus => true
16
15
  end
17
16
  """
18
17
 
@@ -9,35 +9,38 @@ Feature: text formatter
9
9
  """
10
10
  describe String do
11
11
  it "has a failing example" do
12
- "foo".reverse.should == "ofo"
12
+ "foo".reverse.should eq("ofo")
13
13
  end
14
14
  end
15
15
  """
16
16
  And a file named "integer_spec.rb" with:
17
17
  """
18
- require 'rspec/autorun'
19
-
20
18
  describe Integer do
21
19
  it "has a failing example" do
22
- (7 + 5).should == 11
20
+ (7 + 5).should eq(11)
23
21
  end
24
22
  end
25
23
  """
26
- When I run `ruby ./integer_spec.rb ./string_spec.rb`
24
+ When I run `rspec integer_spec.rb string_spec.rb`
27
25
  Then the backtrace-normalized output should contain:
28
26
  """
29
27
  Failures:
30
-
28
+
31
29
  1) Integer has a failing example
32
- Failure/Error: (7 + 5).should == 11
30
+ Failure/Error: (7 + 5).should eq(11)
31
+
33
32
  expected: 11
34
- got: 12 (using ==)
35
- # ./integer_spec.rb:5
36
-
33
+ got: 12
34
+
35
+ (compared using ==)
36
+ # ./integer_spec.rb:3
37
+
37
38
  2) String has a failing example
38
- Failure/Error: "foo".reverse.should == "ofo"
39
+ Failure/Error: "foo".reverse.should eq("ofo")
40
+
39
41
  expected: "ofo"
40
- got: "oof" (using ==)
42
+ got: "oof"
43
+
44
+ (compared using ==)
41
45
  # ./string_spec.rb:3
42
46
  """
43
-
@@ -15,12 +15,12 @@ Feature: let and let!
15
15
  let(:count) { $count += 1 }
16
16
 
17
17
  it "memoizes the value" do
18
- count.should == 1
19
- count.should == 1
18
+ count.should eq(1)
19
+ count.should eq(1)
20
20
  end
21
21
 
22
22
  it "is not cached across examples" do
23
- count.should == 2
23
+ count.should eq(2)
24
24
  end
25
25
  end
26
26
  """
@@ -42,7 +42,7 @@ Feature: let and let!
42
42
  it "calls the helper method in a before hook" do
43
43
  invocation_order << :example
44
44
  invocation_order.should == [:let!, :example]
45
- count.should == 1
45
+ count.should eq(1)
46
46
  end
47
47
  end
48
48
  """
@@ -259,7 +259,7 @@ Feature: around hooks
259
259
 
260
260
  it "they should all be run" do
261
261
  puts "in the example"
262
- 1.should == 1
262
+ 1.should eq(1)
263
263
  end
264
264
  end
265
265
  """
@@ -187,12 +187,12 @@ Feature: before and after hooks
187
187
  describe "stuff in before blocks" do
188
188
  describe "with :all" do
189
189
  it "should be available in the example" do
190
- @before_all.should == "before all"
190
+ @before_all.should eq("before all")
191
191
  end
192
192
  end
193
193
  describe "with :each" do
194
194
  it "should be available in the example" do
195
- @before_each.should == "before each"
195
+ @before_each.should eq("before each")
196
196
  end
197
197
  end
198
198
  end
@@ -363,7 +363,7 @@ Feature: before and after hooks
363
363
 
364
364
  describe "nested in parallel" do
365
365
  it "access state set in before(:all)" do
366
- @value.should == 123
366
+ @value.should eq(123)
367
367
  end
368
368
  end
369
369
  end
@@ -1,12 +1,19 @@
1
1
  Feature: filters
2
2
 
3
- `before`/`after`/`around` hooks defined in the RSpec configuration block can
4
- be filtered using metadata. Arbitrary metadata can be applied to an example
5
- or example group, and used to make a hook only apply to examples with the
6
- given metadata.
3
+ `before`, `after`, and `around` hooks defined in the block passed to
4
+ `RSpec.configure` can be constrained to specific examples and/or groups using
5
+ metadata as a filter.
7
6
 
8
- If you set the `treat_symbols_as_metadata_keys_with_true_values` config option
9
- to `true`, you can specify metadata using only symbols.
7
+ RSpec.configure do |c|
8
+ c.before(:each, :type => :model) do
9
+ end
10
+ end
11
+
12
+ describe "something", :type => :model do
13
+ end
14
+
15
+ You can specify metadata using only symbols if you set the
16
+ `treat_symbols_as_metadata_keys_with_true_values` config option to `true`.
10
17
 
11
18
  Scenario: filter `before(:each)` hooks using arbitrary metadata
12
19
  Given a file named "filter_before_each_hooks_spec.rb" with:
@@ -12,9 +12,11 @@ Feature: User-defined metadata
12
12
  behavior in RSpec 3) that allows you to specify metadata using just
13
13
  symbols:
14
14
 
15
- RSpec.configure do |c|
16
- c.treat_symbols_as_metadata_keys_with_true_values = true
17
- end
15
+ ```ruby
16
+ RSpec.configure do |c|
17
+ c.treat_symbols_as_metadata_keys_with_true_values = true
18
+ end
19
+ ```
18
20
 
19
21
  Each symbol passed as an argument to `describe`, `context` or `it` will
20
22
  be a key in the metadata hash, with a corresponding value of `true`.
@@ -24,7 +26,7 @@ Feature: User-defined metadata
24
26
  """
25
27
  describe "a group with user-defined metadata", :foo => 17 do
26
28
  it 'has access to the metadata in the example' do
27
- example.metadata[:foo].should == 17
29
+ example.metadata[:foo].should eq(17)
28
30
  end
29
31
 
30
32
  it 'does not have access to metadata defined on sub-groups' do
@@ -33,11 +35,11 @@ Feature: User-defined metadata
33
35
 
34
36
  describe 'a sub-group with user-defined metadata', :bar => 12 do
35
37
  it 'has access to the sub-group metadata' do
36
- example.metadata[:foo].should == 17
38
+ example.metadata[:foo].should eq(17)
37
39
  end
38
40
 
39
41
  it 'also has access to metadata defined on parent groups' do
40
- example.metadata[:bar].should == 12
42
+ example.metadata[:bar].should eq(12)
41
43
  end
42
44
  end
43
45
  end
@@ -50,13 +52,13 @@ Feature: User-defined metadata
50
52
  """
51
53
  describe "a group with no user-defined metadata" do
52
54
  it 'has an example with metadata', :foo => 17 do
53
- example.metadata[:foo].should == 17
55
+ example.metadata[:foo].should eq(17)
54
56
  example.metadata.should_not include(:bar)
55
57
  end
56
58
 
57
59
  it 'has another example with metadata', :bar => 12, :bazz => 33 do
58
- example.metadata[:bar].should == 12
59
- example.metadata[:bazz].should == 33
60
+ example.metadata[:bar].should eq(12)
61
+ example.metadata[:bazz].should eq(33)
60
62
  example.metadata.should_not include(:foo)
61
63
  end
62
64
  end
@@ -99,7 +101,7 @@ Feature: User-defined metadata
99
101
  end
100
102
 
101
103
  it 'can still use a hash for metadata' do
102
- example.metadata[:bug].should == 73
104
+ example.metadata[:bug].should eq(73)
103
105
  end
104
106
 
105
107
  it 'can define simple metadata on an example', :special do