This repository has been archived by the owner on Mar 1, 2019. It is now read-only.
forked from cucumber/aruba
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathusage.feature
159 lines (134 loc) · 4.51 KB
/
usage.feature
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
Feature: Usage of configuration
You can configure `aruba` in two ways:
1. Using `Aruba.configure`-block
2. Using `aruba.config.<option> = <value>`
The first (1.) should be used to set defaults for ALL your tests. It changes
values on loadtime. The latter (2.) should be used to change options only for
specific tests during runtime. `aruba.config` contains the runtime
configuration of aruba which is reset to the loadtime configuration before
each test is run.
Background:
Given I use a fixture named "cli-app"
And an executable named "bin/aruba-test-cli" with:
"""bash
#!/bin/bash
trap "exit 128" SIGTERM SIGINT
sleep $*
"""
Scenario: Setting default values for option for RSpec
Given a file named "spec/support/aruba.rb" with:
"""ruby
require 'aruba/rspec'
Aruba.configure do |config|
config.exit_timeout = 1
end
"""
And a file named "spec/usage_configuration_spec.rb" with:
"""ruby
require 'spec_helper'
RSpec.describe 'Run command', :type => :aruba do
context 'when fast command' do
before(:each) { run('cli 0') }
it { expect(last_command_started).to be_successfully_executed }
end
context 'when slow command' do
before(:each) { run('cli 2') }
it { expect(last_command_started).not_to be_successfully_executed }
end
end
"""
When I run `rspec`
Then the specs should all pass
Scenario: Setting option during runtime for RSpec
Maybe there are some long running tests, which need longer. You may not
want to set the default timeout for all commands to the maximum value only
to prevent those commands from failing.
Given a file named "spec/support/aruba.rb" with:
"""ruby
require 'aruba/rspec'
Aruba.configure do |config|
config.exit_timeout = 1
end
"""
And a file named "spec/support/hooks.rb" with:
"""ruby
RSpec.configure do |config|
config.before :each do |example|
next unless example.metadata.key? :slow_command
aruba.config.exit_timeout = 5
end
end
"""
And a file named "spec/usage_configuration_spec.rb" with:
"""ruby
require 'spec_helper'
RSpec.describe 'Run command', :type => :aruba do
context 'when fast command' do
before(:each) { run('cli 0') }
it { expect(last_command_started).to be_successfully_executed }
end
context 'when slow command and this is known by the developer', :slow_command => true do
before(:each) { run('cli 2') }
it { expect(last_command_started).to be_successfully_executed }
end
context 'when slow command, but this might be a failure' do
before(:each) { run('cli 2') }
it { expect(last_command_started).not_to be_successfully_executed }
end
end
"""
When I run `rspec`
Then the specs should all pass
Scenario: Setting default values for option for Cucumber
Given a file named "features/support/aruba.rb" with:
"""ruby
require 'aruba/cucumber'
Aruba.configure do |config|
config.exit_timeout = 1
end
"""
And a file named "features/run.feature" with:
"""
Feature: Run it
Scenario: Fast command
When I run `cli 0`
Then the exit status should be 0
Scenario: Slow command
When I run `cli 2`
Then the exit status should be 128
"""
When I run `cucumber`
Then the features should all pass
Scenario: Setting option during runtime for Cucumber
Maybe there are some long running tests, which need longer. You may not
want to set the default timeout for all commands to the maximum value only
to prevent those commands from failing.
Given a file named "features/support/aruba.rb" with:
"""ruby
require 'aruba/cucumber'
Aruba.configure do |config|
config.exit_timeout = 1
end
"""
And a file named "features/support/hooks.rb" with:
"""ruby
Before '@slow-command' do
aruba.config.exit_timeout = 5
end
"""
And a file named "features/usage_configuration.feature" with:
"""
Feature: Run it
Scenario: Fast command
When I run `cli 0`
Then the exit status should be 0
@slow-command
Scenario: Slow command known by the developer
When I run `cli 2`
Then the exit status should be 0
Scenario: Slow command which might be a failure
When I run `cli 3`
Then the exit status should be 128
"""
When I run `cucumber`
Then the features should all pass