Skip to content

Commit

Permalink
Use the Capybara.default_selector instead of hard coding :css into th…
Browse files Browse the repository at this point in the history
…e web_steps.
  • Loading branch information
Rob Holland committed Dec 2, 2009
1 parent 6e44cc4 commit 0c49450
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
6 changes: 6 additions & 0 deletions generators/cucumber/templates/capybara_env.rb
Expand Up @@ -18,3 +18,9 @@
# would prevent the drivers from working. Capybara uses DatabaseCleaner to
# wipe the database before each Scenario instead of using transactions.
Cucumber::Rails::World.use_transactional_fixtures = false

# Capybara defaults to XPATH selectors rather than Webrat's default of CSS. In
# order to ease the transition to Capybara we set the default here. If you'd
# prefer to use XPATH just remove this line and adjust any selectors in your
# steps to use the XPATH syntax.
Capybara.default_selector = :css
12 changes: 6 additions & 6 deletions generators/cucumber/templates/web_steps/capybara_steps.rb
Expand Up @@ -21,8 +21,8 @@
click_link(link)
end

When /^(?:|I )follow "([^\"]*)" within "([^\"]*)"$/ do |link, parent|
within(parent, :css) do
When /^(?:|I )follow "([^\"]*)" within "([^\"]*)"$/ do |link, selector|
within(selector) do
click_link(link)
end
end
Expand Down Expand Up @@ -128,7 +128,7 @@
end

Then /^(?:|I )should see "([^\"]*)" within "([^\"]*)"$/ do |text, selector|
within(selector, :css) do |content|
within(selector) do |content|
if defined?(Spec::Rails::Matchers)
content.should have_content(text)
else
Expand All @@ -147,7 +147,7 @@
end

Then /^(?:|I )should see \/([^\/]*)\/ within "([^\"]*)"$/ do |regexp, selector|
within(selector, :css) do |content|
within(selector) do |content|
regexp = Regexp.new(regexp)
if defined?(Spec::Rails::Matchers)
content.should have_xpath('//*', :text => regexp)
Expand All @@ -166,7 +166,7 @@
end

Then /^(?:|I )should not see "([^\"]*)" within "([^\"]*)"$/ do |text, selector|
within(selector, :css) do |content|
within(selector) do |content|
if defined?(Spec::Rails::Matchers)
content.should_not have_content(text)
else
Expand All @@ -185,7 +185,7 @@
end

Then /^(?:|I )should not see \/([^\/]*)\/ within "([^\"]*)"$/ do |regexp, selector|
within(selector, :css) do |content|
within(selector) do |content|
regexp = Regexp.new(regexp)
if defined?(Spec::Rails::Matchers)
content.should_not have_xpath('//*', :text => regexp)
Expand Down

0 comments on commit 0c49450

Please sign in to comment.