rspec-core 2.11.1 → 2.12.0
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.
- data/Changelog.md +59 -0
- data/README.md +22 -0
- data/features/command_line/example_name_option.feature +5 -5
- data/features/command_line/exit_status.feature +6 -6
- data/features/command_line/format_option.feature +2 -2
- data/features/command_line/line_number_appended_to_path.feature +2 -2
- data/features/command_line/line_number_option.feature +2 -2
- data/features/command_line/pattern_option.feature +2 -2
- data/features/command_line/rake_task.feature +62 -8
- data/features/command_line/ruby.feature +1 -1
- data/features/command_line/tag.feature +1 -1
- data/features/configuration/alias_example_to.feature +2 -2
- data/features/configuration/custom_settings.feature +3 -3
- data/features/configuration/default_path.feature +3 -3
- data/features/configuration/fail_fast.feature +5 -5
- data/features/configuration/read_options_from_file.feature +4 -4
- data/features/example_groups/basic_structure.feature +2 -2
- data/features/example_groups/shared_context.feature +3 -3
- data/features/example_groups/shared_examples.feature +25 -7
- data/features/expectation_framework_integration/configure_expectation_framework.feature +6 -6
- data/features/filtering/exclusion_filters.feature +5 -5
- data/features/filtering/if_and_unless.feature +5 -5
- data/features/filtering/inclusion_filters.feature +5 -5
- data/features/filtering/run_all_when_everything_filtered.feature +3 -3
- data/features/formatters/custom_formatter.feature +2 -2
- data/features/formatters/json_formatter.feature +30 -0
- data/features/formatters/text_formatter.feature +5 -5
- data/features/helper_methods/arbitrary_methods.feature +2 -2
- data/features/helper_methods/let.feature +2 -2
- data/features/helper_methods/modules.feature +6 -6
- data/features/hooks/around_hooks.feature +11 -11
- data/features/hooks/before_and_after_hooks.feature +15 -11
- data/features/hooks/filtering.feature +6 -6
- data/features/metadata/current_example.feature +1 -1
- data/features/metadata/described_class.feature +1 -1
- data/features/metadata/user_defined.feature +4 -4
- data/features/mock_framework_integration/use_any_framework.feature +6 -6
- data/features/mock_framework_integration/use_flexmock.feature +5 -5
- data/features/mock_framework_integration/use_mocha.feature +5 -5
- data/features/mock_framework_integration/use_rr.feature +5 -5
- data/features/mock_framework_integration/use_rspec.feature +5 -5
- data/features/pending/pending_examples.feature +11 -11
- data/features/spec_files/arbitrary_file_suffix.feature +1 -1
- data/features/step_definitions/additional_cli_steps.rb +2 -0
- data/features/subject/attribute_of_subject.feature +5 -5
- data/features/subject/explicit_subject.feature +5 -5
- data/features/subject/implicit_receiver.feature +2 -2
- data/features/subject/implicit_subject.feature +3 -3
- data/lib/autotest/rspec2.rb +1 -1
- data/lib/rspec/core.rb +53 -32
- data/lib/rspec/core/configuration.rb +123 -15
- data/lib/rspec/core/configuration_options.rb +17 -2
- data/lib/rspec/core/example.rb +5 -4
- data/lib/rspec/core/example_group.rb +19 -9
- data/lib/rspec/core/extensions/ordered.rb +12 -6
- data/lib/rspec/core/formatters.rb +55 -0
- data/lib/rspec/core/formatters/base_formatter.rb +43 -38
- data/lib/rspec/core/formatters/base_text_formatter.rb +9 -5
- data/lib/rspec/core/formatters/documentation_formatter.rb +1 -1
- data/lib/rspec/core/formatters/helpers.rb +30 -5
- data/lib/rspec/core/formatters/html_formatter.rb +58 -368
- data/lib/rspec/core/formatters/html_printer.rb +407 -0
- data/lib/rspec/core/formatters/json_formatter.rb +73 -0
- data/lib/rspec/core/formatters/snippet_extractor.rb +3 -1
- data/lib/rspec/core/hooks.rb +4 -4
- data/lib/rspec/core/metadata.rb +14 -6
- data/lib/rspec/core/mocking/with_mocha.rb +25 -2
- data/lib/rspec/core/mocking/with_rspec.rb +6 -2
- data/lib/rspec/core/option_parser.rb +28 -7
- data/lib/rspec/core/project_initializer.rb +0 -1
- data/lib/rspec/core/rake_task.rb +49 -38
- data/lib/rspec/core/reporter.rb +2 -2
- data/lib/rspec/core/shared_example_group.rb +89 -41
- data/lib/rspec/core/subject.rb +6 -2
- data/lib/rspec/core/version.rb +1 -1
- data/lib/rspec/core/world.rb +2 -2
- data/spec/autotest/rspec_spec.rb +6 -1
- data/spec/command_line/order_spec.rb +67 -0
- data/spec/rspec/core/configuration_options_spec.rb +45 -38
- data/spec/rspec/core/configuration_spec.rb +219 -44
- data/spec/rspec/core/deprecations_spec.rb +9 -0
- data/spec/rspec/core/drb_command_line_spec.rb +1 -7
- data/spec/rspec/core/drb_options_spec.rb +1 -1
- data/spec/rspec/core/dsl_spec.rb +17 -9
- data/spec/rspec/core/example_group_spec.rb +51 -5
- data/spec/rspec/core/example_spec.rb +39 -7
- data/spec/rspec/core/filter_manager_spec.rb +20 -30
- data/spec/rspec/core/formatters/base_formatter_spec.rb +29 -1
- data/spec/rspec/core/formatters/base_text_formatter_spec.rb +6 -2
- data/spec/rspec/core/formatters/helpers_spec.rb +12 -0
- data/spec/rspec/core/formatters/html_formatted-1.8.7-rbx.html +462 -0
- data/spec/rspec/core/formatters/html_formatted-1.9.2-jruby.html +410 -0
- data/spec/rspec/core/formatters/html_formatted-1.9.3-rbx.html +462 -0
- data/spec/rspec/core/formatters/html_formatter_spec.rb +11 -3
- data/spec/rspec/core/formatters/json_formatter_spec.rb +110 -0
- data/spec/rspec/core/formatters/snippet_extractor_spec.rb +8 -0
- data/spec/rspec/core/formatters/text_mate_formatted-1.8.7-rbx.html +462 -0
- data/spec/rspec/core/formatters/text_mate_formatted-1.9.2-jruby.html +410 -0
- data/spec/rspec/core/formatters/text_mate_formatted-1.9.3-rbx.html +462 -0
- data/spec/rspec/core/formatters/text_mate_formatter_spec.rb +11 -3
- data/spec/rspec/core/hooks_filtering_spec.rb +6 -6
- data/spec/rspec/core/metadata_spec.rb +29 -0
- data/spec/rspec/core/option_parser_spec.rb +42 -0
- data/spec/rspec/core/project_initializer_spec.rb +2 -2
- data/spec/rspec/core/rake_task_spec.rb +60 -17
- data/spec/rspec/core/reporter_spec.rb +17 -0
- data/spec/rspec/core/runner_spec.rb +1 -0
- data/spec/rspec/core/shared_example_group_spec.rb +17 -5
- data/spec/rspec/core/subject_spec.rb +11 -0
- data/spec/spec_helper.rb +32 -2
- data/spec/support/config_options_helper.rb +1 -10
- data/spec/support/helper_methods.rb +13 -0
- data/spec/support/isolated_directory.rb +10 -0
- data/spec/support/isolated_home_directory.rb +16 -0
- metadata +145 -148
- data/lib/rspec/core/extensions.rb +0 -4
@@ -6,7 +6,7 @@ Feature: text formatter
|
|
6
6
|
|
7
7
|
Scenario: Backtrace formatting for failing specs in multiple files
|
8
8
|
Given a file named "string_spec.rb" with:
|
9
|
-
"""
|
9
|
+
"""ruby
|
10
10
|
describe String do
|
11
11
|
it "has a failing example" do
|
12
12
|
"foo".reverse.should eq("ofo")
|
@@ -14,7 +14,7 @@ Feature: text formatter
|
|
14
14
|
end
|
15
15
|
"""
|
16
16
|
And a file named "integer_spec.rb" with:
|
17
|
-
"""
|
17
|
+
"""ruby
|
18
18
|
describe Integer do
|
19
19
|
it "has a failing example" do
|
20
20
|
(7 + 5).should eq(11)
|
@@ -24,8 +24,6 @@ Feature: text formatter
|
|
24
24
|
When I run `rspec integer_spec.rb string_spec.rb`
|
25
25
|
Then the backtrace-normalized output should contain:
|
26
26
|
"""
|
27
|
-
Failures:
|
28
|
-
|
29
27
|
1) Integer has a failing example
|
30
28
|
Failure/Error: (7 + 5).should eq(11)
|
31
29
|
|
@@ -34,7 +32,9 @@ Feature: text formatter
|
|
34
32
|
|
35
33
|
(compared using ==)
|
36
34
|
# ./integer_spec.rb:3
|
37
|
-
|
35
|
+
"""
|
36
|
+
And the backtrace-normalized output should contain:
|
37
|
+
"""
|
38
38
|
2) String has a failing example
|
39
39
|
Failure/Error: "foo".reverse.should eq("ofo")
|
40
40
|
|
@@ -7,7 +7,7 @@ Feature: arbitrary helper methods
|
|
7
7
|
|
8
8
|
Scenario: use a method defined in the same group
|
9
9
|
Given a file named "example_spec.rb" with:
|
10
|
-
"""
|
10
|
+
"""ruby
|
11
11
|
describe "an example" do
|
12
12
|
def help
|
13
13
|
:available
|
@@ -23,7 +23,7 @@ Feature: arbitrary helper methods
|
|
23
23
|
|
24
24
|
Scenario: use a method defined in a parent group
|
25
25
|
Given a file named "example_spec.rb" with:
|
26
|
-
"""
|
26
|
+
"""ruby
|
27
27
|
describe "an example" do
|
28
28
|
def help
|
29
29
|
:available
|
@@ -9,7 +9,7 @@ Feature: let and let!
|
|
9
9
|
|
10
10
|
Scenario: use let to define memoized helper method
|
11
11
|
Given a file named "let_spec.rb" with:
|
12
|
-
"""
|
12
|
+
"""ruby
|
13
13
|
$count = 0
|
14
14
|
describe "let" do
|
15
15
|
let(:count) { $count += 1 }
|
@@ -29,7 +29,7 @@ Feature: let and let!
|
|
29
29
|
|
30
30
|
Scenario: use let! to define a memoized helper method that is called in a before hook
|
31
31
|
Given a file named "let_bang_spec.rb" with:
|
32
|
-
"""
|
32
|
+
"""ruby
|
33
33
|
$count = 0
|
34
34
|
describe "let!" do
|
35
35
|
invocation_order = []
|
@@ -15,7 +15,7 @@ Feature: Define helper methods in a module
|
|
15
15
|
|
16
16
|
Background:
|
17
17
|
Given a file named "helpers.rb" with:
|
18
|
-
"""
|
18
|
+
"""ruby
|
19
19
|
module Helpers
|
20
20
|
def help
|
21
21
|
:available
|
@@ -25,7 +25,7 @@ Feature: Define helper methods in a module
|
|
25
25
|
|
26
26
|
Scenario: include a module in all example groups
|
27
27
|
Given a file named "include_module_spec.rb" with:
|
28
|
-
"""
|
28
|
+
"""ruby
|
29
29
|
require './helpers'
|
30
30
|
|
31
31
|
RSpec.configure do |c|
|
@@ -43,7 +43,7 @@ Feature: Define helper methods in a module
|
|
43
43
|
|
44
44
|
Scenario: extend a module in all example groups
|
45
45
|
Given a file named "extend_module_spec.rb" with:
|
46
|
-
"""
|
46
|
+
"""ruby
|
47
47
|
require './helpers'
|
48
48
|
|
49
49
|
RSpec.configure do |c|
|
@@ -64,7 +64,7 @@ Feature: Define helper methods in a module
|
|
64
64
|
|
65
65
|
Scenario: include a module in only some example groups
|
66
66
|
Given a file named "include_module_in_some_groups_spec.rb" with:
|
67
|
-
"""
|
67
|
+
"""ruby
|
68
68
|
require './helpers'
|
69
69
|
|
70
70
|
RSpec.configure do |c|
|
@@ -88,7 +88,7 @@ Feature: Define helper methods in a module
|
|
88
88
|
|
89
89
|
Scenario: extend a module in only some example groups
|
90
90
|
Given a file named "extend_module_in_only_some_groups_spec.rb" with:
|
91
|
-
"""
|
91
|
+
"""ruby
|
92
92
|
require './helpers'
|
93
93
|
|
94
94
|
RSpec.configure do |c|
|
@@ -118,7 +118,7 @@ Feature: Define helper methods in a module
|
|
118
118
|
|
119
119
|
Scenario: use symbols as metadata
|
120
120
|
Given a file named "symbols_as_metadata_spec.rb" with:
|
121
|
-
"""
|
121
|
+
"""ruby
|
122
122
|
require './helpers'
|
123
123
|
|
124
124
|
RSpec.configure do |c|
|
@@ -18,7 +18,7 @@ Feature: around hooks
|
|
18
18
|
|
19
19
|
Scenario: use the example as a proc within the block passed to around()
|
20
20
|
Given a file named "example_spec.rb" with:
|
21
|
-
"""
|
21
|
+
"""ruby
|
22
22
|
class Database
|
23
23
|
def self.transaction
|
24
24
|
puts "open transaction"
|
@@ -47,7 +47,7 @@ Feature: around hooks
|
|
47
47
|
|
48
48
|
Scenario: invoke the example using run()
|
49
49
|
Given a file named "example_spec.rb" with:
|
50
|
-
"""
|
50
|
+
"""ruby
|
51
51
|
describe "around hook" do
|
52
52
|
around(:each) do |example|
|
53
53
|
puts "around each before"
|
@@ -70,7 +70,7 @@ Feature: around hooks
|
|
70
70
|
|
71
71
|
Scenario: access the example metadata
|
72
72
|
Given a file named "example_spec.rb" with:
|
73
|
-
"""
|
73
|
+
"""ruby
|
74
74
|
describe "something" do
|
75
75
|
around(:each) do |example|
|
76
76
|
puts example.metadata[:foo]
|
@@ -86,7 +86,7 @@ Feature: around hooks
|
|
86
86
|
|
87
87
|
Scenario: define a global around hook
|
88
88
|
Given a file named "example_spec.rb" with:
|
89
|
-
"""
|
89
|
+
"""ruby
|
90
90
|
RSpec.configure do |c|
|
91
91
|
c.around(:each) do |example|
|
92
92
|
puts "around each before"
|
@@ -111,7 +111,7 @@ Feature: around hooks
|
|
111
111
|
|
112
112
|
Scenario: before/after(:each) hooks are wrapped by the around hook
|
113
113
|
Given a file named "example_spec.rb" with:
|
114
|
-
"""
|
114
|
+
"""ruby
|
115
115
|
describe "around filter" do
|
116
116
|
around(:each) do |example|
|
117
117
|
puts "around each before"
|
@@ -144,7 +144,7 @@ Feature: around hooks
|
|
144
144
|
|
145
145
|
Scenario: before/after(:all) hooks are NOT wrapped by the around hook
|
146
146
|
Given a file named "example_spec.rb" with:
|
147
|
-
"""
|
147
|
+
"""ruby
|
148
148
|
describe "around filter" do
|
149
149
|
around(:each) do |example|
|
150
150
|
puts "around each before"
|
@@ -177,7 +177,7 @@ Feature: around hooks
|
|
177
177
|
|
178
178
|
Scenario: examples run by an around block are run in the configured context
|
179
179
|
Given a file named "example_spec.rb" with:
|
180
|
-
"""
|
180
|
+
"""ruby
|
181
181
|
module IncludedInConfigureBlock
|
182
182
|
def included_in_configure_block; true; end
|
183
183
|
end
|
@@ -201,7 +201,7 @@ Feature: around hooks
|
|
201
201
|
|
202
202
|
Scenario: implicitly pending examples are detected as Not yet implemented
|
203
203
|
Given a file named "example_spec.rb" with:
|
204
|
-
"""
|
204
|
+
"""ruby
|
205
205
|
describe "implicit pending example" do
|
206
206
|
around(:each) do |example|
|
207
207
|
example.run
|
@@ -222,7 +222,7 @@ Feature: around hooks
|
|
222
222
|
|
223
223
|
Scenario: explicitly pending examples are detected as pending
|
224
224
|
Given a file named "example_spec.rb" with:
|
225
|
-
"""
|
225
|
+
"""ruby
|
226
226
|
describe "explicit pending example" do
|
227
227
|
around(:each) do |example|
|
228
228
|
example.run
|
@@ -243,7 +243,7 @@ Feature: around hooks
|
|
243
243
|
|
244
244
|
Scenario: multiple around hooks in the same scope
|
245
245
|
Given a file named "example_spec.rb" with:
|
246
|
-
"""
|
246
|
+
"""ruby
|
247
247
|
describe "if there are multiple around hooks in the same scope" do
|
248
248
|
around(:each) do |example|
|
249
249
|
puts "first around hook before"
|
@@ -276,7 +276,7 @@ Feature: around hooks
|
|
276
276
|
|
277
277
|
Scenario: around hooks in multiple scopes
|
278
278
|
Given a file named "example_spec.rb" with:
|
279
|
-
"""
|
279
|
+
"""ruby
|
280
280
|
describe "if there are around hooks in an outer scope" do
|
281
281
|
around(:each) do |example|
|
282
282
|
puts "first outermost around hook before"
|
@@ -21,9 +21,13 @@ Feature: before and after hooks
|
|
21
21
|
`before` and `after` hooks can be defined directly in the example groups they
|
22
22
|
should run in, or in a global RSpec.configure block.
|
23
23
|
|
24
|
+
Setting instance variables are not supported in `before(:suite)`.
|
25
|
+
|
26
|
+
Mocks are only supported in `before(:each)`.
|
27
|
+
|
24
28
|
Scenario: define before(:each) block
|
25
29
|
Given a file named "before_each_spec.rb" with:
|
26
|
-
"""
|
30
|
+
"""ruby
|
27
31
|
require "rspec/expectations"
|
28
32
|
|
29
33
|
class Thing
|
@@ -57,7 +61,7 @@ Feature: before and after hooks
|
|
57
61
|
|
58
62
|
Scenario: define before(:all) block in example group
|
59
63
|
Given a file named "before_all_spec.rb" with:
|
60
|
-
"""
|
64
|
+
"""ruby
|
61
65
|
require "rspec/expectations"
|
62
66
|
|
63
67
|
class Thing
|
@@ -94,7 +98,7 @@ Feature: before and after hooks
|
|
94
98
|
|
95
99
|
Scenario: failure in before(:all) block
|
96
100
|
Given a file named "before_all_spec.rb" with:
|
97
|
-
"""
|
101
|
+
"""ruby
|
98
102
|
describe "an error in before(:all)" do
|
99
103
|
before(:all) do
|
100
104
|
raise "oops"
|
@@ -149,7 +153,7 @@ Feature: before and after hooks
|
|
149
153
|
|
150
154
|
Scenario: failure in after(:all) block
|
151
155
|
Given a file named "after_all_spec.rb" with:
|
152
|
-
"""
|
156
|
+
"""ruby
|
153
157
|
describe "an error in after(:all)" do
|
154
158
|
after(:all) do
|
155
159
|
raise StandardError.new("Boom!")
|
@@ -172,7 +176,7 @@ Feature: before and after hooks
|
|
172
176
|
|
173
177
|
Scenario: define before and after blocks in configuration
|
174
178
|
Given a file named "befores_in_configuration_spec.rb" with:
|
175
|
-
"""
|
179
|
+
"""ruby
|
176
180
|
require "rspec/expectations"
|
177
181
|
|
178
182
|
RSpec.configure do |config|
|
@@ -202,7 +206,7 @@ Feature: before and after hooks
|
|
202
206
|
|
203
207
|
Scenario: before/after blocks are run in order
|
204
208
|
Given a file named "ensure_block_order_spec.rb" with:
|
205
|
-
"""
|
209
|
+
"""ruby
|
206
210
|
require "rspec/expectations"
|
207
211
|
|
208
212
|
describe "before and after callbacks" do
|
@@ -238,7 +242,7 @@ Feature: before and after hooks
|
|
238
242
|
|
239
243
|
Scenario: before/after blocks defined in config are run in order
|
240
244
|
Given a file named "configuration_spec.rb" with:
|
241
|
-
"""
|
245
|
+
"""ruby
|
242
246
|
require "rspec/expectations"
|
243
247
|
|
244
248
|
RSpec.configure do |config|
|
@@ -285,7 +289,7 @@ Feature: before and after hooks
|
|
285
289
|
|
286
290
|
Scenario: before/after all blocks are run once
|
287
291
|
Given a file named "before_and_after_all_spec.rb" with:
|
288
|
-
"""
|
292
|
+
"""ruby
|
289
293
|
describe "before and after callbacks" do
|
290
294
|
before(:all) do
|
291
295
|
puts "outer before all"
|
@@ -343,7 +347,7 @@ Feature: before and after hooks
|
|
343
347
|
|
344
348
|
Scenario: nested examples have access to state set in outer before(:all)
|
345
349
|
Given a file named "before_all_spec.rb" with:
|
346
|
-
"""
|
350
|
+
"""ruby
|
347
351
|
describe "something" do
|
348
352
|
before :all do
|
349
353
|
@value = 123
|
@@ -373,7 +377,7 @@ Feature: before and after hooks
|
|
373
377
|
|
374
378
|
Scenario: before/after all blocks have access to state
|
375
379
|
Given a file named "before_and_after_all_spec.rb" with:
|
376
|
-
"""
|
380
|
+
"""ruby
|
377
381
|
describe "before and after callbacks" do
|
378
382
|
before(:all) do
|
379
383
|
@outer_state = "set in outer before all"
|
@@ -408,7 +412,7 @@ Feature: before and after hooks
|
|
408
412
|
|
409
413
|
Scenario: exception in before(:each) is captured and reported as failure
|
410
414
|
Given a file named "error_in_before_each_spec.rb" with:
|
411
|
-
"""
|
415
|
+
"""ruby
|
412
416
|
describe "error in before(:each)" do
|
413
417
|
before(:each) do
|
414
418
|
raise "this error"
|
@@ -17,7 +17,7 @@ Feature: filters
|
|
17
17
|
|
18
18
|
Scenario: filter `before(:each)` hooks using arbitrary metadata
|
19
19
|
Given a file named "filter_before_each_hooks_spec.rb" with:
|
20
|
-
"""
|
20
|
+
"""ruby
|
21
21
|
RSpec.configure do |config|
|
22
22
|
config.before(:each, :foo => :bar) do
|
23
23
|
invoked_hooks << :before_each_foo_bar
|
@@ -49,7 +49,7 @@ Feature: filters
|
|
49
49
|
|
50
50
|
Scenario: filter `after(:each)` hooks using arbitrary metadata
|
51
51
|
Given a file named "filter_after_each_hooks_spec.rb" with:
|
52
|
-
"""
|
52
|
+
"""ruby
|
53
53
|
RSpec.configure do |config|
|
54
54
|
config.after(:each, :foo => :bar) do
|
55
55
|
raise "boom!"
|
@@ -79,7 +79,7 @@ Feature: filters
|
|
79
79
|
|
80
80
|
Scenario: filter around(:each) hooks using arbitrary metadata
|
81
81
|
Given a file named "filter_around_each_hooks_spec.rb" with:
|
82
|
-
"""
|
82
|
+
"""ruby
|
83
83
|
RSpec.configure do |config|
|
84
84
|
config.around(:each, :foo => :bar) do |example|
|
85
85
|
order << :before_around_each_foo_bar
|
@@ -115,7 +115,7 @@ Feature: filters
|
|
115
115
|
|
116
116
|
Scenario: filter before(:all) hooks using arbitrary metadata
|
117
117
|
Given a file named "filter_before_all_hooks_spec.rb" with:
|
118
|
-
"""
|
118
|
+
"""ruby
|
119
119
|
RSpec.configure do |config|
|
120
120
|
config.before(:all, :foo => :bar) { @hook = :before_all_foo_bar }
|
121
121
|
end
|
@@ -151,7 +151,7 @@ Feature: filters
|
|
151
151
|
|
152
152
|
Scenario: filter after(:all) hooks using arbitrary metadata
|
153
153
|
Given a file named "filter_after_all_hooks_spec.rb" with:
|
154
|
-
"""
|
154
|
+
"""ruby
|
155
155
|
example_msgs = []
|
156
156
|
|
157
157
|
RSpec.configure do |config|
|
@@ -195,7 +195,7 @@ Feature: filters
|
|
195
195
|
|
196
196
|
Scenario: Use symbols as metadata
|
197
197
|
Given a file named "less_verbose_metadata_filter.rb" with:
|
198
|
-
"""
|
198
|
+
"""ruby
|
199
199
|
RSpec.configure do |c|
|
200
200
|
c.treat_symbols_as_metadata_keys_with_true_values = true
|
201
201
|
c.before(:each, :before_each) { puts "before each" }
|
@@ -5,7 +5,7 @@ Feature: current example
|
|
5
5
|
|
6
6
|
Scenario: access the example object from within an example
|
7
7
|
Given a file named "spec/example_spec.rb" with:
|
8
|
-
"""
|
8
|
+
"""ruby
|
9
9
|
describe "an example" do
|
10
10
|
it "knows itself as example" do
|
11
11
|
example.description.should eq("knows itself as example")
|
@@ -23,7 +23,7 @@ Feature: User-defined metadata
|
|
23
23
|
|
24
24
|
Scenario: define group metadata using a hash
|
25
25
|
Given a file named "define_group_metadata_with_hash_spec.rb" with:
|
26
|
-
"""
|
26
|
+
"""ruby
|
27
27
|
describe "a group with user-defined metadata", :foo => 17 do
|
28
28
|
it 'has access to the metadata in the example' do
|
29
29
|
example.metadata[:foo].should eq(17)
|
@@ -49,7 +49,7 @@ Feature: User-defined metadata
|
|
49
49
|
|
50
50
|
Scenario: define example metadata using a hash
|
51
51
|
Given a file named "define_example_metadata_with_hash_spec.rb" with:
|
52
|
-
"""
|
52
|
+
"""ruby
|
53
53
|
describe "a group with no user-defined metadata" do
|
54
54
|
it 'has an example with metadata', :foo => 17 do
|
55
55
|
example.metadata[:foo].should eq(17)
|
@@ -68,7 +68,7 @@ Feature: User-defined metadata
|
|
68
68
|
|
69
69
|
Scenario: override user-defined metadata
|
70
70
|
Given a file named "override_metadata_spec.rb" with:
|
71
|
-
"""
|
71
|
+
"""ruby
|
72
72
|
describe "a group with user-defined metadata", :foo => 'bar' do
|
73
73
|
it 'can be overridden by an example', :foo => 'bazz' do
|
74
74
|
example.metadata[:foo].should == 'bazz'
|
@@ -86,7 +86,7 @@ Feature: User-defined metadata
|
|
86
86
|
|
87
87
|
Scenario: less verbose metadata
|
88
88
|
Given a file named "less_verbose_metadata_spec.rb" with:
|
89
|
-
"""
|
89
|
+
"""ruby
|
90
90
|
RSpec.configure do |c|
|
91
91
|
c.treat_symbols_as_metadata_keys_with_true_values = true
|
92
92
|
end
|
@@ -6,20 +6,20 @@ Feature: mock with an alternative framework
|
|
6
6
|
|
7
7
|
A mock framework adapter must expose three methods:
|
8
8
|
|
9
|
-
* setup_mocks_for_rspec
|
9
|
+
* `setup_mocks_for_rspec`
|
10
10
|
* called before each example is run
|
11
|
-
* verify_mocks_for_rspec
|
11
|
+
* `verify_mocks_for_rspec`
|
12
12
|
* called after each example is run
|
13
13
|
* this is where message expectation failures should result in an error with
|
14
14
|
the appropriate failure message
|
15
|
-
* teardown_mocks_for_rspec
|
16
|
-
* called after verify_mocks_for_rspec
|
15
|
+
* `teardown_mocks_for_rspec`
|
16
|
+
* called after `verify_mocks_for_rspec`
|
17
17
|
* use this to clean up resources, restore objects to earlier state, etc
|
18
18
|
* guaranteed to run even if there are failures
|
19
19
|
|
20
20
|
Scenario: Mock with alternate framework
|
21
21
|
Given a file named "expector.rb" with:
|
22
|
-
"""
|
22
|
+
"""ruby
|
23
23
|
class Expector
|
24
24
|
class << self
|
25
25
|
def expectors
|
@@ -80,7 +80,7 @@ Feature: mock with an alternative framework
|
|
80
80
|
"""
|
81
81
|
|
82
82
|
Given a file named "example_spec.rb" with:
|
83
|
-
"""
|
83
|
+
"""ruby
|
84
84
|
require File.expand_path("../expector", __FILE__)
|
85
85
|
|
86
86
|
RSpec.configure do |config|
|