Skip to content
This repository
  • 8 commits
  • 9 files changed
  • 0 comments
  • 2 contributors
Dec 07, 2011
Dave Copeland Fixes syntax error for 1.8.7
The only use of Aruba::Config::Hooks#execute was in `api.rb` and
that was passing a single value for the second argument.

So, I removed the splat in the arg and the call to
`instance_exec`.  Since none of this is documented, and no tests
broke, I'm going to assume this is OK, at least to get
a working version for 1.8.7.
db9f0b0
Dave Copeland added ree for travis 532029d
Matt Wynne mattwynne Merge pull request #95 from davetron5000/fix-1.8.7-syntax-error
Fix 1.8.7 syntax error
2833500
Dec 08, 2011
Matt Wynne mattwynne Add specs to describe how I want hooks to work cf0e197
Matt Wynne mattwynne Rename hook for clarity c6a6e17
Matt Wynne mattwynne Document hooks, closes #96 79735b3
Matt Wynne mattwynne Add history 7557153
Matt Wynne mattwynne Release 0.4.9 c34b4c5
1  .travis.yml
@@ -2,6 +2,7 @@ rvm:
2 2 - 1.9.3
3 3 - 1.9.2
4 4 - 1.8.7
  5 + - ree
5 6 # whitelist
6 7 branches:
7 8 only:
4 History.md
Source Rendered
... ... @@ -1,3 +1,7 @@
  1 +## [v0.4.9](https://github.com/cucumber/aruba/compare/v0.4.8...v0.4.9)
  2 +* Rename before_run hook to before_cmd (Matt Wynne)
  3 +* Fix 1.8.7 compatibility (#95 Dave Copeland)
  4 +
1 5 ## [v0.4.8](https://github.com/cucumber/aruba/compare/v0.4.7...v0.4.8)
2 6
3 7 * Add before_run hook (Matt Wynne)
12 README.md
Source Rendered
@@ -75,6 +75,18 @@ To get more information on what Aruba is doing, use these tags:
75 75 * `@announce-env` - See environment variables set by Aruba
76 76 * `@announce` - Does all of the above
77 77
  78 +### Adding Hooks
  79 +
  80 +You can hook into Aruba's lifecycle just before it runs a command:
  81 +
  82 +```
  83 +Aruba.configure do |config|
  84 + config.before_cmd do |cmd|
  85 + puts "About to run '#{cmd}'
  86 + end
  87 +end
  88 +```
  89 +
78 90 #### Keep files around with `@no-clobber`
79 91
80 92 Aruba clobbers all files in its working directory before each scenario. -Unless you tag it with `@no-clobber`
6 Rakefile
@@ -12,4 +12,8 @@ Cucumber::Rake::Task.new do |t|
12 12 t.cucumber_opts = opts
13 13 end
14 14
15   -task :default => :cucumber
  15 +task :spec do
  16 + sh('rspec --color')
  17 +end
  18 +
  19 +task :default => [:spec, :cucumber]
2  aruba.gemspec
@@ -2,7 +2,7 @@
2 2
3 3 Gem::Specification.new do |s|
4 4 s.name = 'aruba'
5   - s.version = '0.4.8'
  5 + s.version = '0.4.9'
6 6 s.authors = ["Aslak Hellesøy", "David Chelimsky", "Mike Sassak", "Matt Wynne"]
7 7 s.description = 'CLI Steps for Cucumber, hand-crafted for you in Aruba'
8 8 s.summary = "aruba-#{s.version}"
6 features/before_run_hooks.feature → features/before_cmd_hooks.feature
... ... @@ -1,4 +1,4 @@
1   -Feature: before_run hooks
  1 +Feature: before_cmd hooks
2 2
3 3 You can configure Aruba to run blocks of code before it runs
4 4 each command.
@@ -12,7 +12,7 @@ Feature: before_run hooks
12 12 require 'aruba/api'
13 13
14 14 Aruba.configure do |config|
15   - config.before_run do |cmd|
  15 + config.before_cmd do |cmd|
16 16 puts "about to run `#{cmd}`"
17 17 end
18 18 end
@@ -36,7 +36,7 @@ Feature: before_run hooks
36 36 require 'aruba/api'
37 37
38 38 Aruba.configure do |config|
39   - config.before_run do |cmd|
  39 + config.before_cmd do |cmd|
40 40 puts "I can see @your_context=#{@your_context}"
41 41 end
42 42 end
4 lib/aruba/api.rb
@@ -258,8 +258,8 @@ def run(cmd)
258 258 cmd = detect_ruby(cmd)
259 259
260 260 in_current_dir do
261   - Aruba.config.hooks.execute(:before_run, cmd, self)
262   -
  261 + Aruba.config.hooks.execute(:before_cmd, self, cmd)
  262 +
263 263 announce_or_puts("$ cd #{Dir.pwd}") if @announce_dir
264 264 announce_or_puts("$ #{cmd}") if @announce_cmd
265 265
8 lib/aruba/config.rb
@@ -7,8 +7,8 @@ def initialize
7 7 end
8 8
9 9 # Register a hook to be called before Aruba runs a command
10   - def before_run(&block)
11   - @hooks.append(:before_run, block)
  10 + def before_cmd(&block)
  11 + @hooks.append(:before_cmd, block)
12 12 end
13 13 end
14 14
@@ -24,7 +24,7 @@ def append(label, block)
24 24 @store[label] << block
25 25 end
26 26
27   - def execute(label, *args, context)
  27 + def execute(label, context, *args)
28 28 @store[label].each do |block|
29 29 context.instance_exec(*args, &block)
30 30 end
@@ -41,4 +41,4 @@ def configure
41 41 end
42 42
43 43 self.config = Config.new
44   -end
  44 +end
18 spec/aruba/hooks_spec.rb
... ... @@ -0,0 +1,18 @@
  1 +require 'aruba/config'
  2 +
  3 +describe Aruba::Hooks do
  4 + it 'executes a stored hook' do
  5 + hook_was_run = false
  6 + subject.append :hook_label, lambda { hook_was_run = true }
  7 + subject.execute :hook_label, self
  8 + hook_was_run.should be_true
  9 + end
  10 +
  11 + it 'executes a stored hook that takes multiple arguments' do
  12 + hook_values = []
  13 + subject.append :hook_label, lambda { |a,b,c| hook_values = [a,b,c] }
  14 + subject.execute :hook_label, self, 1, 2, 3
  15 + hook_values.should == [1,2,3]
  16 + end
  17 +
  18 +end

No commit comments for this range

Something went wrong with that request. Please try again.