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

Commit 7531704

Browse files
committed
Convert ordering markdown to feature
1 parent a665896 commit 7531704

File tree

2 files changed

+93
-32
lines changed

2 files changed

+93
-32
lines changed

features/command_line/order.feature

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
Feature: Using the `--order` option
2+
3+
Use the `--order` option to tell RSpec how to order the files, groups, and
4+
examples. The available ordering schemes are `defined` and `rand`.
5+
6+
`defined` is the default, which executes groups and examples in the order they
7+
are defined as the spec files are loaded, with the caveat that each group
8+
runs its examples before running its nested example groups, even if the
9+
nested groups are defined before the examples.
10+
11+
Use `rand` to randomize the order of groups and examples within the groups.
12+
Nested groups are always run from top-level to bottom-level in order to avoid
13+
executing `before(:context)` and `after(:context)` hooks more than once, but the
14+
order of groups at each level is randomized.
15+
16+
With `rand` you can also specify a seed.
17+
18+
Use `recently-modified` to run the most recently modified files first. You can
19+
combine it with `--only-failures` to find the most recent failing specs. Note
20+
that `recently-modified` and `rand` are mutually exclusive.
21+
22+
** Example usage **
23+
24+
The `defined` option is only necessary when you have `--order rand` stored in a
25+
config file (e.g. `.rspec`) and you want to override it from the command line.
26+
27+
<pre><code class="bash">--order defined
28+
--order rand
29+
--order rand:123
30+
--seed 123 # same as --order rand:123
31+
--order recently-modified
32+
</code></pre>
33+
34+
Scenario: Default order is `defined`
35+
Given a file named "example_spec.rb" with:
36+
"""ruby
37+
RSpec.describe "something" do
38+
it "does something" do
39+
end
40+
41+
it "in order" do
42+
end
43+
end
44+
"""
45+
When I run `rspec example_spec.rb --format documentation`
46+
Then the output should contain:
47+
"""
48+
something
49+
does something
50+
in order
51+
"""
52+
53+
Scenario: Order can be psuedo randomised (seed used here to fix the ordering for tests)
54+
Given a file named "example_spec.rb" with:
55+
"""ruby
56+
RSpec.describe "something" do
57+
it "does something" do
58+
end
59+
60+
it "in order" do
61+
end
62+
end
63+
"""
64+
When I run `rspec example_spec.rb --format documentation --order rand:123`
65+
Then the output should contain:
66+
"""
67+
something
68+
in order
69+
does something
70+
"""
71+
72+
Scenario: Override order to `defined` when another order is set
73+
Given a file named "example_spec.rb" with:
74+
"""ruby
75+
RSpec.configure do |config|
76+
config.order = :random
77+
config.seed = 123
78+
end
79+
RSpec.describe "something" do
80+
it "does something" do
81+
end
82+
83+
it "in order" do
84+
end
85+
end
86+
"""
87+
When I run `rspec example_spec.rb --format documentation --order defined`
88+
Then the output should contain:
89+
"""
90+
something
91+
does something
92+
in order
93+
"""

features/command_line/order.md

Lines changed: 0 additions & 32 deletions
This file was deleted.

0 commit comments

Comments
 (0)