-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6e8c448
commit 077d44f
Showing
6 changed files
with
174 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,10 @@ | ||
default: -r features/support -r features/environments/plain.rb -r features/step_definitions features/plain | ||
selenium: -r features/support -r features/environments/enhanced.rb -r features/step_definitions features/enhanced | ||
autotest: -r features/support -r features/environments/plain.rb -r features/step_definitions --color --format pretty --tags ~@selenium | ||
autotest-all: -r features/support -r features/environments/plain.rb -r features/step_definitions --color --format progress --tags ~@selenium | ||
default: -r features/support -r features/environments/webrat.rb -r features/step_definitions features --tags ~@selenium | ||
selenium: -r features/support -r features/environments/selenium.rb -r features/step_definitions features --tags @selenium | ||
autotest: -r features/support -r features/environments/webrat.rb -r features/step_definitions --color --format pretty --tags ~@selenium | ||
autotest-all: -r features/support -r features/environments/webrat.rb -r features/step_definitions --color --format progress --tags ~@selenium | ||
|
||
kmb: -r features/support -r features/environments/webrat.rb -r features/step_definitions features --tags ~@selenium,@kmb | ||
kmbs: -r features/support -r features/environments/selenium.rb -r features/step_definitions features --tags @selenium,@kmb | ||
|
||
ksc: -r features/support -r features/environments/webrat.rb -r features/step_definitions features --tags @ksc | ||
kscs: -r features/support -r features/environments/selenium.rb -r features/step_definitions features --tags @selenium,@ksc |
48 changes: 48 additions & 0 deletions
48
cucumber_setup/templates/features/environments/selenium.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
require 'database_cleaner' | ||
require 'database_cleaner/cucumber' | ||
|
||
Webrat.configure do |config| | ||
config.mode = :selenium | ||
# Selenium defaults to using the selenium environment. Use the following to override this. | ||
config.application_environment = :test | ||
|
||
# config.application_address = "localhost" | ||
# config.application_port = "3001" | ||
|
||
#config.selenium_server_address = "localhost" | ||
#config.selenium_server_port = "4444" | ||
|
||
# config.selenium_browser_key = "*firefox" | ||
end | ||
|
||
# this is necessary to have webrat "wait_for" the response body to be available | ||
# when writing steps that match against the response body returned by selenium | ||
World(Webrat::Selenium::Matchers) | ||
|
||
# This is needed for cucumber/selenium tests | ||
Cucumber::Rails::World.use_transactional_fixtures = false | ||
|
||
DatabaseCleaner.strategy = :truncation | ||
|
||
Before do | ||
# truncate your tables here, since you can't use transactional fixtures* | ||
DatabaseCleaner.clean | ||
end | ||
|
||
# This is helpful when using the same cucumber steps with differing methods for selenium and normal webrat | ||
def selenium_env? | ||
true | ||
end | ||
|
||
class Webrat::SeleniumSession | ||
|
||
# Selenium version of request_path | ||
def request_path | ||
selenium.get_location.gsub("http://localhost:3001", "") | ||
end | ||
|
||
end | ||
|
||
# Make the request_path method available to the steps | ||
Webrat::Methods.delegate_to_session :request_path | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#Cucumber::Rails.use_transactional_fixtures | ||
#Cucumber::Rails.bypass_rescue # Comment out this line if you want Rails own error handling | ||
|
||
Webrat.configure do |config| | ||
config.mode = :rails | ||
end | ||
# (e.g. rescue_action_in_public / rescue_responses / rescue_from) | ||
|
||
|
||
Cucumber::Rails::World.use_transactional_fixtures = false | ||
require 'database_cleaner' | ||
After do | ||
# Truncate the data from the minerva_test database tables listed below | ||
ActiveRecord::Base.establish_connection('minerva_test') | ||
DatabaseCleaner.clean_with :truncation, {:only => %w[customer]} | ||
|
||
# Truncate all the data from the test database | ||
ActiveRecord::Base.establish_connection(ENV['RAILS_ENV']) | ||
DatabaseCleaner.clean_with :truncation | ||
end |
7 changes: 7 additions & 0 deletions
7
cucumber_setup/templates/features/step_definitions/selenium_steps.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
require File.expand_path(File.join(File.dirname(__FILE__), "..", "support", "paths")) | ||
|
||
Then /^I should see "([^\"]*)" in "([^\"]*)"$/ do |text, selector| | ||
selenium.wait_for_condition('selenium.browserbot.getCurrentWindow().jQuery.active == 0', $max_selenium_timeout) | ||
response_body.should have_tag(selector, /#{Regexp.escape(text)}/) | ||
end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters