Skip to content

Commit

Permalink
Make all uses of pending consistent.
Browse files Browse the repository at this point in the history
* Execute pending examples and mark as failed if they succeed.
* Removed pending with a block.
* Introduce `skip` method and metadata for old pending behaviour.

This is a backwards-incompatible change.

Implements #1208.
  • Loading branch information
xaviershay committed Feb 9, 2014
1 parent 940ffa1 commit db63959
Show file tree
Hide file tree
Showing 30 changed files with 767 additions and 748 deletions.
13 changes: 13 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,19 @@ Breaking Changes for 3.0.0:
* Remove support for deprecated `--configure` CLI option. (Myron Marston)
* Remove support for deprecated `RSpec::Core::RakeTask#spec_opts=`.
(Myron Marston)
* An example group level `pending` block or `:pending` metadata now executes
the example and cause a failure if it passes, otherwise it will be pending if
it fails. The old "never run" behaviour is still used for `xexample`, `xit`,
and `xspecify`, or via a new `skip` method or `:skip` metadata option.
(Xavier Shay)
* After calling `pending` inside an example, the remainder of the example will
now be run. If it passes a failure is raised, otherwise the example is marked
pending. The old "never run" behaviour is provided a by a new `skip` method.
(Xavier Shay)
* Pending blocks inside an example have been removed as a feature with no
direct replacement. Either use `skip`, or `pending` with no block.
(Xavier Shay)
* Remove `show_failures_in_pending_blocks` configuration option. (Xavier Shay)

Enhancements:

Expand Down
2 changes: 1 addition & 1 deletion features/command_line/format_option.feature
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ Feature: --format option
end
it "does something that is pending", :pending => true do
expect(5).to be > 3
expect(5).to be < 3
end
end
"""
Expand Down
61 changes: 0 additions & 61 deletions features/configuration/show_failures_in_pending_blocks.feature

This file was deleted.

1 change: 1 addition & 0 deletions features/hooks/around_hooks.feature
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,7 @@ Feature: around hooks
it "should be detected as pending" do
pending
fail
end
end
"""
Expand Down
24 changes: 11 additions & 13 deletions features/mock_framework_integration/use_flexmock.feature
Original file line number Diff line number Diff line change
Expand Up @@ -37,40 +37,38 @@ Feature: mock with flexmock
When I run `rspec example_spec.rb`
Then the output should contain "1 example, 1 failure"

Scenario: failing message expectation in pending block (remains pending)
Scenario: failing message expectation in pending example (remains pending)
Given a file named "example_spec.rb" with:
"""ruby
RSpec.configure do |config|
config.mock_framework = :flexmock
end
describe "failed message expectation in a pending block" do
describe "failed message expectation in a pending example" do
it "is listed as pending" do
pending do
receiver = flexmock('receiver')
receiver.should_receive(:message).once
end
pending
receiver = flexmock('receiver')
receiver.should_receive(:message).once
end
end
"""
When I run `rspec example_spec.rb`
Then the output should contain "1 example, 0 failures, 1 pending"
And the exit status should be 0

Scenario: passing message expectation in pending block (fails)
Scenario: passing message expectation in pending example (fails)
Given a file named "example_spec.rb" with:
"""ruby
RSpec.configure do |config|
config.mock_framework = :flexmock
end
describe "passing message expectation in a pending block" do
describe "passing message expectation in a pending example" do
it "fails with FIXED" do
pending do
receiver = flexmock('receiver')
receiver.should_receive(:message).once
receiver.message
end
pending
receiver = flexmock('receiver')
receiver.should_receive(:message).once
receiver.message
end
end
"""
Expand Down
24 changes: 11 additions & 13 deletions features/mock_framework_integration/use_mocha.feature
Original file line number Diff line number Diff line change
Expand Up @@ -37,40 +37,38 @@ Feature: mock with mocha
When I run `rspec example_spec.rb`
Then the output should contain "1 example, 1 failure"

Scenario: failing message expectation in pending block (remains pending)
Scenario: failing message expectation in pending example (remains pending)
Given a file named "example_spec.rb" with:
"""ruby
RSpec.configure do |config|
config.mock_framework = :mocha
end
describe "failed message expectation in a pending block" do
describe "failed message expectation in a pending example" do
it "is listed as pending" do
pending do
receiver = mock('receiver')
receiver.expects(:message).once
end
pending
receiver = mock('receiver')
receiver.expects(:message).once
end
end
"""
When I run `rspec example_spec.rb`
Then the output should contain "1 example, 0 failures, 1 pending"
And the exit status should be 0

Scenario: passing message expectation in pending block (fails)
Scenario: passing message expectation in pending example (fails)
Given a file named "example_spec.rb" with:
"""ruby
RSpec.configure do |config|
config.mock_framework = :mocha
end
describe "passing message expectation in a pending block" do
describe "passing message expectation in a pending example" do
it "fails with FIXED" do
pending do
receiver = mock('receiver')
receiver.expects(:message).once
receiver.message
end
pending
receiver = mock('receiver')
receiver.expects(:message).once
receiver.message
end
end
"""
Expand Down
24 changes: 11 additions & 13 deletions features/mock_framework_integration/use_rr.feature
Original file line number Diff line number Diff line change
Expand Up @@ -37,40 +37,38 @@ Feature: mock with rr
When I run `rspec example_spec.rb`
Then the output should contain "1 example, 1 failure"

Scenario: failing message expectation in pending block (remains pending)
Scenario: failing message expectation in pending example (remains pending)
Given a file named "example_spec.rb" with:
"""ruby
RSpec.configure do |config|
config.mock_framework = :rr
end
describe "failed message expectation in a pending block" do
describe "failed message expectation in a pending example" do
it "is listed as pending" do
pending do
receiver = Object.new
mock(receiver).message
end
pending
receiver = Object.new
mock(receiver).message
end
end
"""
When I run `rspec example_spec.rb`
Then the output should contain "1 example, 0 failures, 1 pending"
And the exit status should be 0

Scenario: passing message expectation in pending block (fails)
Scenario: passing message expectation in pending example (fails)
Given a file named "example_spec.rb" with:
"""ruby
RSpec.configure do |config|
config.mock_framework = :rr
end
describe "passing message expectation in a pending block" do
describe "passing message expectation in a pending example" do
it "fails with FIXED" do
pending do
receiver = Object.new
mock(receiver).message
receiver.message
end
pending
receiver = Object.new
mock(receiver).message
receiver.message
end
end
"""
Expand Down
24 changes: 11 additions & 13 deletions features/mock_framework_integration/use_rspec.feature
Original file line number Diff line number Diff line change
Expand Up @@ -38,40 +38,38 @@ Feature: mock with rspec
When I run `rspec example_spec.rb`
Then the output should contain "1 example, 1 failure"

Scenario: failing message expectation in pending block (remains pending)
Scenario: failing message expectation in pending example (remains pending)
Given a file named "example_spec.rb" with:
"""ruby
RSpec.configure do |config|
config.mock_framework = :rspec
end
describe "failed message expectation in a pending block" do
describe "failed message expectation in a pending example" do
it "is listed as pending" do
pending do
receiver = double('receiver')
expect(receiver).to receive(:message)
end
pending
receiver = double('receiver')
expect(receiver).to receive(:message)
end
end
"""
When I run `rspec example_spec.rb`
Then the output should contain "1 example, 0 failures, 1 pending"
And the exit status should be 0

Scenario: passing message expectation in pending block (fails)
Scenario: passing message expectation in pending example (fails)
Given a file named "example_spec.rb" with:
"""ruby
RSpec.configure do |config|
config.mock_framework = :rspec
end
describe "passing message expectation in a pending block" do
describe "passing message expectation in a pending example" do
it "fails with FIXED" do
pending do
receiver = double('receiver')
expect(receiver).to receive(:message)
receiver.message
end
pending
receiver = double('receiver')
expect(receiver).to receive(:message)
receiver.message
end
end
"""
Expand Down
Loading

0 comments on commit db63959

Please sign in to comment.