| 1 |
Feature: Using `skip` with examples |
| 2 |
|
| 3 |
RSpec offers a number of ways to indicate that an example should be skipped |
| 4 |
and not executed. |
| 5 |
|
| 6 |
Scenario: No implementation provided |
| 7 |
Given a file named "example_without_block_spec.rb" with: |
| 8 |
"""ruby |
| 9 |
RSpec.describe "an example" do |
| 10 |
it "is a skipped example" |
| 11 |
end |
| 12 |
""" |
| 13 |
When I run `rspec example_without_block_spec.rb` |
| 14 |
Then the exit status should be 0 |
| 15 |
And the output should contain "1 example, 0 failures, 1 pending" |
| 16 |
And the output should contain "Not yet implemented" |
| 17 |
And the output should contain "example_without_block_spec.rb:2" |
| 18 |
|
| 19 |
Scenario: Skipping using `skip` |
| 20 |
Given a file named "skipped_spec.rb" with: |
| 21 |
"""ruby |
| 22 |
RSpec.describe "an example" do |
| 23 |
skip "is skipped" do |
| 24 |
end |
| 25 |
end |
| 26 |
""" |
| 27 |
When I run `rspec skipped_spec.rb` |
| 28 |
Then the exit status should be 0 |
| 29 |
And the output should contain "1 example, 0 failures, 1 pending" |
| 30 |
And the output should contain: |
| 31 |
""" |
| 32 |
Pending: (Failures listed here are expected and do not affect your suite's status) |
| 33 |
|
| 34 |
1) an example is skipped |
| 35 |
# No reason given |
| 36 |
# ./skipped_spec.rb:2 |
| 37 |
""" |
| 38 |
|
| 39 |
Scenario: Skipping using `skip` inside an example |
| 40 |
Given a file named "skipped_spec.rb" with: |
| 41 |
"""ruby |
| 42 |
RSpec.describe "an example" do |
| 43 |
it "is skipped" do |
| 44 |
skip |
| 45 |
end |
| 46 |
end |
| 47 |
""" |
| 48 |
When I run `rspec skipped_spec.rb` |
| 49 |
Then the exit status should be 0 |
| 50 |
And the output should contain "1 example, 0 failures, 1 pending" |
| 51 |
And the output should contain: |
| 52 |
""" |
| 53 |
Pending: (Failures listed here are expected and do not affect your suite's status) |
| 54 |
|
| 55 |
1) an example is skipped |
| 56 |
# No reason given |
| 57 |
# ./skipped_spec.rb:2 |
| 58 |
""" |
| 59 |
|
| 60 |
Scenario: Temporarily skipping by prefixing `it`, `specify`, or `example` with an x |
| 61 |
Given a file named "temporarily_skipped_spec.rb" with: |
| 62 |
"""ruby |
| 63 |
RSpec.describe "an example" do |
| 64 |
xit "is skipped using xit" do |
| 65 |
end |
| 66 |
|
| 67 |
xspecify "is skipped using xspecify" do |
| 68 |
end |
| 69 |
|
| 70 |
xexample "is skipped using xexample" do |
| 71 |
end |
| 72 |
end |
| 73 |
""" |
| 74 |
When I run `rspec temporarily_skipped_spec.rb` |
| 75 |
Then the exit status should be 0 |
| 76 |
And the output should contain "3 examples, 0 failures, 3 pending" |
| 77 |
And the output should contain: |
| 78 |
""" |
| 79 |
Pending: (Failures listed here are expected and do not affect your suite's status) |
| 80 |
|
| 81 |
1) an example is skipped using xit |
| 82 |
# Temporarily skipped with xit |
| 83 |
# ./temporarily_skipped_spec.rb:2 |
| 84 |
|
| 85 |
2) an example is skipped using xspecify |
| 86 |
# Temporarily skipped with xspecify |
| 87 |
# ./temporarily_skipped_spec.rb:5 |
| 88 |
|
| 89 |
3) an example is skipped using xexample |
| 90 |
# Temporarily skipped with xexample |
| 91 |
# ./temporarily_skipped_spec.rb:8 |
| 92 |
""" |
| 93 |
|
| 94 |
Scenario: Skipping using metadata |
| 95 |
Given a file named "skipped_spec.rb" with: |
| 96 |
"""ruby |
| 97 |
RSpec.describe "an example" do |
| 98 |
example "is skipped", :skip => true do |
| 99 |
end |
| 100 |
end |
| 101 |
""" |
| 102 |
When I run `rspec skipped_spec.rb` |
| 103 |
Then the exit status should be 0 |
| 104 |
And the output should contain "1 example, 0 failures, 1 pending" |
| 105 |
And the output should contain: |
| 106 |
""" |
| 107 |
Pending: (Failures listed here are expected and do not affect your suite's status) |
| 108 |
|
| 109 |
1) an example is skipped |
| 110 |
# No reason given |
| 111 |
# ./skipped_spec.rb:2 |
| 112 |
""" |
| 113 |
|
| 114 |
Scenario: Skipping using metadata with a reason |
| 115 |
Given a file named "skipped_with_reason_spec.rb" with: |
| 116 |
"""ruby |
| 117 |
RSpec.describe "an example" do |
| 118 |
example "is skipped", :skip => "waiting for planets to align" do |
| 119 |
raise "this line is never executed" |
| 120 |
end |
| 121 |
end |
| 122 |
""" |
| 123 |
When I run `rspec skipped_with_reason_spec.rb` |
| 124 |
Then the exit status should be 0 |
| 125 |
And the output should contain "1 example, 0 failures, 1 pending" |
| 126 |
And the output should contain: |
| 127 |
""" |
| 128 |
Pending: (Failures listed here are expected and do not affect your suite's status) |
| 129 |
|
| 130 |
1) an example is skipped |
| 131 |
# waiting for planets to align |
| 132 |
# ./skipped_with_reason_spec.rb:2 |
| 133 |
""" |