Permalink
Browse files

Reflect on tags, rather than hardcoding

This means that drivers don't have to add their
own cucumber tags anymore.
  • Loading branch information...
1 parent ac658dd commit 04360cc2918338564a17971f8691f79bbc9172c9 @jnicklas jnicklas committed Feb 24, 2011
Showing with 9 additions and 15 deletions.
  1. +9 −15 lib/capybara/cucumber.rb
View
@@ -1,4 +1,5 @@
require 'capybara'
+
require 'capybara/dsl'
require 'capybara/rspec/matchers'
@@ -9,24 +10,17 @@
Capybara.reset_sessions!
end
-Before('@javascript') do
+Before '@javascript' do
Capybara.current_driver = Capybara.javascript_driver
end
-Before('@selenium') do
- Capybara.current_driver = :selenium
-end
-
-Before('@celerity') do
- Capybara.current_driver = :celerity
-end
-
-Before('@culerity') do
- Capybara.current_driver = :culerity
-end
-
-Before('@rack_test') do
- Capybara.current_driver = :rack_test
+Before do |scenario|
+ scenario.source_tag_names.each do |tag|
+ driver_name = tag.sub(/^@/, '').to_sym
+ if Capybara.drivers.has_key?(driver_name)
+ Capybara.current_driver = driver_name
+ end
+ end
end
After do

1 comment on commit 04360cc

Slick!

Please sign in to comment.