Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: cucumber/aruba
...
head fork: cucumber/aruba
Checking mergeability… Don't worry, you can still create the pull request.
  • 8 commits
  • 9 files changed
  • 0 commit comments
  • 2 contributors
Commits on 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
Commits on Dec 08, 2011
@mattwynne mattwynne Merge pull request #95 from davetron5000/fix-1.8.7-syntax-error
Fix 1.8.7 syntax error
2833500
@mattwynne mattwynne Add specs to describe how I want hooks to work
cf0e197
@mattwynne mattwynne Rename hook for clarity
c6a6e17
@mattwynne mattwynne Document hooks, closes #96
79735b3
@mattwynne mattwynne Add history
7557153
@mattwynne mattwynne Release 0.4.9
c34b4c5
View
1  .travis.yml
@@ -2,6 +2,7 @@ rvm:
- 1.9.3
- 1.9.2
- 1.8.7
+ - ree
# whitelist
branches:
only:
View
4 History.md
@@ -1,3 +1,7 @@
+## [v0.4.9](https://github.com/cucumber/aruba/compare/v0.4.8...v0.4.9)
+* Rename before_run hook to before_cmd (Matt Wynne)
+* Fix 1.8.7 compatibility (#95 Dave Copeland)
+
## [v0.4.8](https://github.com/cucumber/aruba/compare/v0.4.7...v0.4.8)
* Add before_run hook (Matt Wynne)
View
12 README.md
@@ -75,6 +75,18 @@ To get more information on what Aruba is doing, use these tags:
* `@announce-env` - See environment variables set by Aruba
* `@announce` - Does all of the above
+### Adding Hooks
+
+You can hook into Aruba's lifecycle just before it runs a command:
+
+```
+Aruba.configure do |config|
+ config.before_cmd do |cmd|
+ puts "About to run '#{cmd}'
+ end
+end
+```
+
#### Keep files around with `@no-clobber`
Aruba clobbers all files in its working directory before each scenario. -Unless you tag it with `@no-clobber`
View
6 Rakefile
@@ -12,4 +12,8 @@ Cucumber::Rake::Task.new do |t|
t.cucumber_opts = opts
end
-task :default => :cucumber
+task :spec do
+ sh('rspec --color')
+end
+
+task :default => [:spec, :cucumber]
View
2  aruba.gemspec
@@ -2,7 +2,7 @@
Gem::Specification.new do |s|
s.name = 'aruba'
- s.version = '0.4.8'
+ s.version = '0.4.9'
s.authors = ["Aslak Hellesøy", "David Chelimsky", "Mike Sassak", "Matt Wynne"]
s.description = 'CLI Steps for Cucumber, hand-crafted for you in Aruba'
s.summary = "aruba-#{s.version}"
View
6 features/before_run_hooks.feature → features/before_cmd_hooks.feature
@@ -1,4 +1,4 @@
-Feature: before_run hooks
+Feature: before_cmd hooks
You can configure Aruba to run blocks of code before it runs
each command.
@@ -12,7 +12,7 @@ Feature: before_run hooks
require 'aruba/api'
Aruba.configure do |config|
- config.before_run do |cmd|
+ config.before_cmd do |cmd|
puts "about to run `#{cmd}`"
end
end
@@ -36,7 +36,7 @@ Feature: before_run hooks
require 'aruba/api'
Aruba.configure do |config|
- config.before_run do |cmd|
+ config.before_cmd do |cmd|
puts "I can see @your_context=#{@your_context}"
end
end
View
4 lib/aruba/api.rb
@@ -258,8 +258,8 @@ def run(cmd)
cmd = detect_ruby(cmd)
in_current_dir do
- Aruba.config.hooks.execute(:before_run, cmd, self)
-
+ Aruba.config.hooks.execute(:before_cmd, self, cmd)
+
announce_or_puts("$ cd #{Dir.pwd}") if @announce_dir
announce_or_puts("$ #{cmd}") if @announce_cmd
View
8 lib/aruba/config.rb
@@ -7,8 +7,8 @@ def initialize
end
# Register a hook to be called before Aruba runs a command
- def before_run(&block)
- @hooks.append(:before_run, block)
+ def before_cmd(&block)
+ @hooks.append(:before_cmd, block)
end
end
@@ -24,7 +24,7 @@ def append(label, block)
@store[label] << block
end
- def execute(label, *args, context)
+ def execute(label, context, *args)
@store[label].each do |block|
context.instance_exec(*args, &block)
end
@@ -41,4 +41,4 @@ def configure
end
self.config = Config.new
-end
+end
View
18 spec/aruba/hooks_spec.rb
@@ -0,0 +1,18 @@
+require 'aruba/config'
+
+describe Aruba::Hooks do
+ it 'executes a stored hook' do
+ hook_was_run = false
+ subject.append :hook_label, lambda { hook_was_run = true }
+ subject.execute :hook_label, self
+ hook_was_run.should be_true
+ end
+
+ it 'executes a stored hook that takes multiple arguments' do
+ hook_values = []
+ subject.append :hook_label, lambda { |a,b,c| hook_values = [a,b,c] }
+ subject.execute :hook_label, self, 1, 2, 3
+ hook_values.should == [1,2,3]
+ end
+
+end

No commit comments for this range

Something went wrong with that request. Please try again.