Skip to content
This repository was archived by the owner on Nov 30, 2024. It is now read-only.

Add a spec for interrupt trapping in Runner #2096

Closed
wants to merge 47 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
9bac617
Add a spec for interrupt trapping in Runner
myrridin Oct 22, 2015
93c2a89
Add before_register hook to RSpec World
bootstraponline Oct 20, 2015
d9dae7d
Add example_group.remove_example and example_group.add_example
bootstraponline Oct 21, 2015
7b4edeb
Add duplicate_with for RSpec Example
bootstraponline Oct 23, 2015
a234238
Changelog for #2098
JonRowe Oct 23, 2015
50f2a85
Fix Example duplicate_with
bootstraponline Oct 24, 2015
cd7080e
Use optimized relative requires in rake_task.rb
myronmarston Oct 26, 2015
2dfee87
changelog for 2094
JonRowe Oct 22, 2015
8a83f40
changelog for #2095
JonRowe Oct 26, 2015
b7a1d96
Don't reset before_context_ivars in reset_memoized
bootstraponline Oct 27, 2015
b956b97
Fix rake_task.rb coverage
bootstraponline Oct 27, 2015
d542953
Rename SnippetExtractor to HtmlSnippetExtractor
yujinakayama Oct 15, 2015
5cd764d
Introduce Source, Source::Node, Source::Token and Source::Location
yujinakayama Oct 15, 2015
d281b57
Remove redundant indentations
yujinakayama Oct 15, 2015
28b7655
Simplify handling of linefeed and indentation in ExceptionPresenter
yujinakayama Oct 15, 2015
acfafaf
Refactor handling of the first line of exception report
yujinakayama Oct 15, 2015
b45d62a
Extract multiline failure expression by parsing Ruby source
yujinakayama Oct 15, 2015
fd08d5d
Allow limiting count of displayed failed lines
yujinakayama Oct 15, 2015
9061158
Insert blank line between snippet and error except when both are oneline
yujinakayama Oct 15, 2015
f9b65df
Load exception presentation sub-system lazily
yujinakayama Oct 23, 2015
54de02f
Add changelog entries
yujinakayama Oct 27, 2015
f79dcca
Make OptionParser handle fail-fast parameters
jackscotti Aug 15, 2015
b045b68
Make Reporter aware of required failures
Oct 7, 2015
bfa0144
Make ExampleGroup stop running examples when appropriate
jackscotti Aug 15, 2015
a5a4088
Update fail_fast description in configuration.rb
jackscotti Aug 15, 2015
aa08ec2
Update fail-fast integration tests
jackscotti Aug 15, 2015
039736a
Silence ruby 2.2 warnings
Oct 30, 2015
d7ead23
Handle syntax error in Ripper
yujinakayama Oct 27, 2015
a33e634
Followups from #2065.
myronmarston Nov 1, 2015
a419b82
Implement syntax highlighting.
myronmarston Oct 25, 2015
3de6e63
Turn a #map into #each where the return value is unused
leocassarani Nov 9, 2015
3786f9e
remove coreray warning
JonRowe Nov 12, 2015
960bf1b
Update changelog for v3.4.0 [ci skip]
myronmarston Nov 12, 2015
cafcc3f
Release v3.4.0
myronmarston Nov 12, 2015
a276f7c
Bump version to 3.5.0.pre [ci skip]
myronmarston Nov 12, 2015
a909580
Use a relish url that isn’t version-specific.
myronmarston Nov 12, 2015
4f46aeb
Make wording more accurate.
myronmarston Nov 13, 2015
59d1a0f
pin nokogiri version for travis
JonRowe Nov 17, 2015
d1b824b
Fix `BacktraceFormatter` to handle `nil` backtraces.
myronmarston Nov 18, 2015
5602c84
Forwardport 3.4.1 release notes.
myronmarston Nov 19, 2015
269a506
unpin nokogiri
JonRowe Nov 30, 2015
44cbc51
unpin nokogiri properly
JonRowe Nov 30, 2015
e9c37ab
restrict 1.6.6.4
JonRowe Nov 30, 2015
a138972
Updated common markdown files (from rspec-dev) [ci skip]
JonRowe Dec 7, 2015
fcf0cf0
prevent possible infinite recursion
JonRowe Dec 7, 2015
24fb155
improve recursion detection
JonRowe Dec 8, 2015
e537d91
Add `currently_executing_a_context_hook?` to ExampleGroup
Dec 10, 2015
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion BUILD_DETAIL.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<!---
This file was generated on 2015-07-27T23:49:06-07:00 from the rspec-dev repo.
This file was generated on 2015-12-07T22:01:00+11:00 from the rspec-dev repo.
DO NOT modify it by hand as your changes will get lost the next time it is generated.
-->

Expand Down
55 changes: 36 additions & 19 deletions CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<!---
This file was generated on 2015-07-27T23:49:06-07:00 from the rspec-dev repo.
This file was generated on 2015-12-07T22:01:00+11:00 from the rspec-dev repo.
DO NOT modify it by hand as your changes will get lost the next time it is generated.
-->

Expand All @@ -10,33 +10,50 @@ values contributions from anyone, the RSpec project has adopted the
following code of conduct. All contributors and participants (including
maintainers!) are expected to abide by its terms.

As contributors and maintainers of this project, we pledge to respect all
people who contribute through reporting issues, posting feature requests,
updating documentation, submitting pull requests or patches, and other
activities.
As contributors and maintainers of this project, and in the interest of
fostering an open and welcoming community, we pledge to respect all people who
contribute through reporting issues, posting feature requests, updating
documentation, submitting pull requests or patches, and other activities.

We are committed to making participation in this project a harassment-free
experience for everyone, regardless of level of experience, gender, gender
identity and expression, sexual orientation, disability, personal appearance,
body size, race, ethnicity, age, religion or similar personal characteristic.
body size, race, ethnicity, age, religion, or nationality.

Examples of unacceptable behavior by participants include, but are not limited
to, the use of sexual language or imagery, derogatory comments or personal
attacks, trolling, public or private harassment, insults, or other
unprofessional conduct.
Examples of unacceptable behavior by participants include:

* The use of sexualized language or imagery
* Personal attacks
* Trolling or insulting/derogatory comments
* Public or private harassment
* Publishing other's private information, such as physical or electronic
addresses, without explicit permission
* Other unethical or unprofessional conduct

Project maintainers have the right and responsibility to remove, edit, or
reject comments, commits, code, wiki edits, issues, and other contributions
that are not aligned to this Code of Conduct. Project maintainers who do not
follow the Code of Conduct may be removed from the project team.
that are not aligned to this Code of Conduct, or to ban temporarily or
permanently any contributor for other behaviors that they deem inappropriate,
threatening, offensive, or harmful.

By adopting this Code of Conduct, project maintainers commit themselves to
fairly and consistently applying these principles to every aspect of managing
this project. Project maintainers who do not follow or enforce the Code of
Conduct may be permanently removed from the project team.

This code of conduct applies both within project spaces and in public spaces
This Code of Conduct applies both within project spaces and in public spaces
when an individual is representing the project or its community.

Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported by opening an issue or contacting one or more of the project
maintainers.

This Code of Conduct is adapted from the [Contributor
Covenant](http://contributor-covenant.org), version 1.1.0, available at
[http://contributor-covenant.org/version/1/1/0/](http://contributor-covenant.org/version/1/1/0/)
reported by contacting one of the project maintainers listed at
http://rspec.info/about/. All complaints will be reviewed and investigated
and will result in a response that is deemed necessary and appropriate to the
circumstances. Maintainers are obligated to maintain confidentiality with
regard to the reporter of an incident.

This Code of Conduct is adapted from the [Contributor Covenant][homepage],
version 1.3.0, available at
[http://contributor-covenant.org/version/1/3/0/][version]

[homepage]: http://contributor-covenant.org
[version]: http://contributor-covenant.org/version/1/3/0/
4 changes: 2 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<!---
This file was generated on 2015-07-27T23:49:06-07:00 from the rspec-dev repo.
This file was generated on 2015-12-07T22:01:00+11:00 from the rspec-dev repo.
DO NOT modify it by hand as your changes will get lost the next time it is generated.
-->

# Contributing

RSpec is a community-driven project that has benefited from improvements from over over *500* contributors.
RSpec is a community-driven project that has benefited from improvements from over *500* contributors.
We welcome contributions from *everyone*. While contributing, please follow the project [code of conduct](CODE_OF_CONDUCT.md), so that everyone can be included.

If you'd like to help make RSpec better, here are some ways you can contribute:
Expand Down
31 changes: 29 additions & 2 deletions Changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
### 3.4.0 Development
[Full Changelog](http://github.com/rspec/rspec-core/compare/v3.3.2...master)
### 3.4.1 / 2015-11-18
[Full Changelog](http://github.com/rspec/rspec-core/compare/v3.4.0...v3.4.1)

Bug Fixes:

* Fix backtrace formatter to handle backtraces that are `nil`.
(Myron Marston, #2118)

### 3.4.0 / 2015-11-11
[Full Changelog](http://github.com/rspec/rspec-core/compare/v3.3.2...v3.4.0)

Enhancements:

Expand Down Expand Up @@ -38,6 +46,23 @@ Enhancements:
line from backtrace" messages. (Myron Marston, #2088)
* Add support for `:extra_failure_lines` example metadata that will
be appended to the failure output. (bootstraponline, #2092).
* Add `RSpec::Core::Example#duplicate_with` to produce new examples
with cloned metadata. (bootstraponline, #2098)
* Add `RSpec::Core::Configuration#on_example_group_definition` to register
hooks to be invoked when example groups are created. (bootstraponline, #2094)
* Add `add_example` and `remove_example` to `RSpec::Core::ExampleGroup` to
allow manipulating an example groups examples. (bootstraponline, #2095)
* Display multiline failure source lines in failure output when Ripper is
available (MRI >= 1.9.2, and JRuby >= 1.7.5 && < 9.0.0.0.rc1).
(Yuji Nakayama, #2083)
* Add `max_displayed_failure_line_count` configuration option
(defaults to 10). (Yuji Nakayama, #2083)
* Enhance `fail_fast` option so it can take a number (e.g. `--fail-fast=3`)
to force the run to abort after the specified number of failures.
(Jack Scotti, #2065)
* Syntax highlight the failure snippets in text formatters when `color`
is enabled and the `coderay` gem is installed on a POSIX system.
(Myron Marston, #2109)

Bug Fixes:

Expand All @@ -47,6 +72,8 @@ Bug Fixes:
* Fix regression in 3.3 that caused spec file names with square brackets in
them (such as `1[]_spec.rb`) to not be loaded properly. (Myron Marston, #2041)
* Fix output encoding issue caused by ASCII literal on 1.9.3 (Jon Rowe, #2072)
* Fix requires in `rspec/core/rake_task.rb` to avoid double requires
seen by some users. (Myron Marston, #2101)

### 3.3.2 / 2015-07-15
[Full Changelog](http://github.com/rspec/rspec-core/compare/v3.3.1...v3.3.2)
Expand Down
2 changes: 1 addition & 1 deletion DEVELOPMENT.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<!---
This file was generated on 2015-07-27T23:49:06-07:00 from the rspec-dev repo.
This file was generated on 2015-12-07T22:01:00+11:00 from the rspec-dev repo.
DO NOT modify it by hand as your changes will get lost the next time it is generated.
-->

Expand Down
25 changes: 21 additions & 4 deletions features/command_line/fail_fast.feature
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,29 @@ Feature: `--fail-fast` option
Use the `--fail-fast` option to tell RSpec to stop running the test suite on
the first failed test.

You may also specify `--no-fail-fast` to turn it off (default behaviour).
You may add a parameter to tell RSpec to stop running the test suite after N
failed tests, for example: `--fail-fast=3`.

You can also specify `--no-fail-fast` to turn it off (default behaviour).

Background:
Given a file named "fail_fast_spec.rb" with:
"""ruby
RSpec.describe "fail fast" do
it "passing test" do; end
it "failing test" do
it "1st failing test" do
fail
end
it "2nd failing test" do
fail
end
it "3rd failing test" do
fail
end
it "this should not be run" do; end
it "4th failing test" do
fail
end
it "passing test" do; end
end
"""

Expand All @@ -22,6 +34,11 @@ Feature: `--fail-fast` option
Then the output should contain ".F"
Then the output should not contain ".F."

Scenario: Using `--fail-fast=3`
When I run `rspec . --fail-fast=3`
Then the output should contain ".FFF"
Then the output should not contain ".FFFF."

Scenario: Using `--no-fail-fast`
When I run `rspec . --no-fail-fast`
Then the output should contain ".F."
Then the output should contain ".FFFF."
54 changes: 42 additions & 12 deletions features/configuration/fail_fast.feature
Original file line number Diff line number Diff line change
@@ -1,19 +1,13 @@
Feature: fail fast

Use the `fail_fast` option to tell RSpec to abort the run on first failure:
Use the `fail_fast` option to tell RSpec to abort the run after N failures:

```ruby
RSpec.configure { |c| c.fail_fast = true }
```

Background:
Scenario: `fail_fast` with no failures (runs all examples)
Given a file named "spec/spec_helper.rb" with:
"""ruby
RSpec.configure {|c| c.fail_fast = true}
RSpec.configure {|c| c.fail_fast = 1}
"""

Scenario: `fail_fast` with no failures (runs all examples)
Given a file named "spec/example_spec.rb" with:
And a file named "spec/example_spec.rb" with:
"""ruby
RSpec.describe "something" do
it "passes" do
Expand All @@ -27,7 +21,11 @@ Feature: fail fast
Then the examples should all pass

Scenario: `fail_fast` with first example failing (only runs the one example)
Given a file named "spec/example_spec.rb" with:
Given a file named "spec/spec_helper.rb" with:
"""ruby
RSpec.configure {|c| c.fail_fast = 1}
"""
And a file named "spec/example_spec.rb" with:
"""ruby
require "spec_helper"
RSpec.describe "something" do
Expand All @@ -43,7 +41,11 @@ Feature: fail fast
Then the output should contain "1 example, 1 failure"

Scenario: `fail_fast` with multiple files, second example failing (only runs the first two examples)
Given a file named "spec/example_1_spec.rb" with:
Given a file named "spec/spec_helper.rb" with:
"""ruby
RSpec.configure {|c| c.fail_fast = 1}
"""
And a file named "spec/example_1_spec.rb" with:
"""ruby
require "spec_helper"
RSpec.describe "something" do
Expand Down Expand Up @@ -77,3 +79,31 @@ Feature: fail fast
"""
When I run `rspec spec`
Then the output should contain "2 examples, 1 failure"


Scenario: `fail_fast 2` with 1st and 3rd examples failing (only runs the first 3 examples)
Given a file named "spec/spec_helper.rb" with:
"""ruby
RSpec.configure {|c| c.fail_fast = 2}
"""
And a file named "spec/example_spec.rb" with:
"""ruby
require "spec_helper"
RSpec.describe "something" do
it "fails once" do
fail
end

it "passes once" do
end

it "fails twice" do
fail
end

it "passes" do
end
end
"""
When I run `rspec spec/example_spec.rb -fd`
Then the output should contain "3 examples, 2 failures"
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Feature: Aggregating Failures

RSpec::Expectations provides [`aggregate_failures`](/rspec/rspec-expectations/v/3-4/docs/aggregating-failures), an API that allows you to group a set of expectations and see all the failures at once, rather than it aborting on the first failure. RSpec::Core improves on this feature in a couple of ways:
RSpec::Expectations provides [`aggregate_failures`](https://relishapp.com/rspec/rspec-expectations/docs/aggregating-failures), an API that allows you to group a set of expectations and see all the failures at once, rather than it aborting on the first failure. RSpec::Core improves on this feature in a couple of ways:

* RSpec::Core provides much better failure output, adding code snippets and backtraces to the sub-failures, just like it does for any normal failure.
* RSpec::Core provides [metadata](../metadata/user-defined-metadata) integration for this feature. Each example that is tagged with `:aggregate_failures` will be wrapped in an `aggregate_failures` block. You can also use `config.define_derived_metadata` to apply this to every example automatically.
Expand Down
1 change: 1 addition & 0 deletions lib/rspec/core/backtrace_formatter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ def filter_gem(gem_name)
end

def format_backtrace(backtrace, options={})
return [] unless backtrace
return backtrace if options[:full_backtrace] || backtrace.empty?

backtrace.map { |l| backtrace_line(l) }.compact.
Expand Down
20 changes: 19 additions & 1 deletion lib/rspec/core/configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,8 @@ def only_failures_but_not_configured?
end

# @macro add_setting
# Clean up and exit after the first failure (default: `false`).
# If specified, indicates the number of failures required before cleaning
# up and exit (default: `nil`).
add_setting :fail_fast

# @macro add_setting
Expand Down Expand Up @@ -332,6 +333,11 @@ def treat_symbols_as_metadata_keys_with_true_values=(_value)
# Currently this will place a mutex around memoized values such as let blocks.
add_setting :threadsafe

# @macro add_setting
# Maximum count of failed source lines to display in the failure reports.
# (default `10`).
add_setting :max_displayed_failure_line_count

# @private
add_setting :tty
# @private
Expand Down Expand Up @@ -387,6 +393,7 @@ def initialize
@libs = []
@derived_metadata_blocks = FilterableItemRepository::QueryOptimized.new(:any?)
@threadsafe = true
@max_displayed_failure_line_count = 10

define_built_in_hooks
end
Expand Down Expand Up @@ -1684,6 +1691,17 @@ def hooks
@hooks ||= HookCollections.new(self, FilterableItemRepository::QueryOptimized)
end

# Invokes block before defining an example group
def on_example_group_definition(&block)
on_example_group_definition_callbacks << block
end

# @api private
# Returns an array of blocks to call before defining an example group
def on_example_group_definition_callbacks
@on_example_group_definition_callbacks ||= []
end

private

def handle_suite_hook(args, collection, append_or_prepend, hook_type, block)
Expand Down
18 changes: 18 additions & 0 deletions lib/rspec/core/example.rb
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,24 @@ def self.parse_id(id)
id.match(/\A(.*?)(?:\[([\d\s:,]+)\])?\z/).captures
end

# Duplicates the example and overrides metadata with the provided
# hash.
#
# @param metadata_overrides [Hash] the hash to override the example metadata
# @return [Example] a duplicate of the example with modified metadata
def duplicate_with(metadata_overrides={})
new_metadata = metadata.clone.merge(metadata_overrides)

RSpec::Core::Metadata::RESERVED_KEYS.each do |reserved_key|
new_metadata.delete reserved_key
end

# don't clone the example group because the new example
# must belong to the same example group (not a clone).
Example.new(example_group, description.clone,
new_metadata, new_metadata[:block])
end

# @attr_reader
#
# Returns the first exception raised in the context of running this
Expand Down
Loading