Aruba の Hooks 周りについてまとめます。
Aruba は Before / After の Hook を持っています。
サンプル
require 'spec_helper'
Aruba.configure do |config|
config.before :command do |cmd|
puts "before the run of '#{cmd.commandline}'"
end
config.after :command do |cmd|
puts "after the run of '#{cmd.commandline}'"
end
end
RSpec.describe 'Hooks', :type => :aruba do
before(:each) { run_simple 'echo hoge' }
it { expect(last_command_started.stdout.chomp).to eq 'hoge' }
end
- 実行結果
$ rspec -fd -c ./spec/configuration//home_directory_spec.rb
before the run of 'echo hoge'
after the run of 'echo hoge'
.
Finished in 0.02064 seconds (files took 0.32232 seconds to load)
1 example, 0 failures