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
/
command.feature
77 lines (63 loc) · 1.86 KB
/
command.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
Feature: before_cmd hooks
You can configure Aruba to run blocks of code before it runs
each command.
The command will be passed to the block.
You can hook into Aruba's lifecycle just before it runs a command and after it has run the command:
```ruby
require_relative 'aruba'
Aruba.configure do |config|
config.before :command do |cmd|
puts "About to run '#{cmd}'"
end
end
```
Background:
Given I use a fixture named "cli-app"
Scenario: Run a simple command with a "before(:command)"-hook
Given a file named "spec/support/hooks.rb" with:
"""
require_relative 'aruba'
Aruba.configure do |config|
config.before :command do |cmd|
puts "before the run of `#{cmd.commandline}`"
end
end
"""
And a file named "spec/hook_spec.rb" with:
"""
require 'spec_helper'
RSpec.describe 'Hooks', :type => :aruba do
before(:each) { run_simple 'echo running' }
it { expect(last_command_started.stdout.chomp).to eq 'running' }
end
"""
When I run `rspec`
Then the specs should all pass
And the output should contain:
"""
before the run of `echo running`
"""
Scenario: Run a simple command with a "before(:cmd)"-hook (deprecated)
Given a file named "spec/support/hooks.rb" with:
"""
require_relative 'aruba'
Aruba.configure do |config|
config.before :cmd do |cmd|
puts "before the run of `#{cmd}`"
end
end
"""
And a file named "spec/hook_spec.rb" with:
"""
require 'spec_helper'
RSpec.describe 'Hooks', :type => :aruba do
before(:each) { run_simple 'echo running' }
it { expect(last_command_started.stdout.chomp).to eq 'running' }
end
"""
When I run `rspec`
Then the specs should all pass
And the output should contain:
"""
before the run of `echo running`
"""