Skip to content

Commit

Permalink
Move from Webrat to Capybara and make all features pass
Browse files Browse the repository at this point in the history
  • Loading branch information
Gabriela Rodríguez and Nicolás Sanguinetti committed Sep 1, 2010
1 parent b0f0562 commit 682dbcb
Show file tree
Hide file tree
Showing 14 changed files with 52 additions and 61 deletions.
5 changes: 3 additions & 2 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ group :test do
gem 'thoughtbot-shoulda', ">= 2.10.0", :require => 'shoulda'
gem 'rr', '>= 0.10.0'
gem 'machinist', ">= 1.0.6"
gem 'webrat', '>= 0.4.5'

gem 'capybara'
gem 'cucumber-rails'
gem 'database_cleaner', '>= 0.5.2', :require => 'database_cleaner'
gem 'database_cleaner'
end
24 changes: 18 additions & 6 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,13 @@ GEM
authlogic-oid (1.0.4)
authlogic
builder (2.1.2)
capybara (0.3.9)
culerity (>= 0.2.4)
mime-types (>= 1.16)
nokogiri (>= 1.3.3)
rack (>= 1.0.0)
rack-test (>= 0.5.4)
selenium-webdriver (>= 0.0.3)
crack (0.1.8)
cucumber (0.8.5)
builder (~> 2.1.2)
Expand All @@ -25,6 +32,7 @@ GEM
term-ansicolor (~> 1.0.4)
cucumber-rails (0.3.2)
cucumber (>= 0.8.0)
culerity (0.2.12)
curb (0.7.8)
daemons (1.1.0)
database_cleaner (0.5.2)
Expand All @@ -44,6 +52,8 @@ GEM
loofah (>= 0.3.1)
nokogiri (> 0.0.0)
sax-machine (>= 0.0.12)
ffi (0.6.3)
rake (>= 0.8.7)
frequency (0.1.5)
gherkin (2.1.5)
trollop (~> 1.16.2)
Expand All @@ -55,6 +65,7 @@ GEM
nokogiri (>= 1.3.3)
machinist (1.0.6)
mash (0.1.1)
mime-types (1.16)
nokogiri (1.4.3.1)
pg (0.9.0)
rack (1.1.0)
Expand All @@ -75,26 +86,28 @@ GEM
rack (>= 1.0.0)
rspec (>= 1.3.0)
ruby-openid (2.1.8)
rubyzip (0.9.4)
sax-machine (0.0.15)
nokogiri (> 0.0.0)
selenium-webdriver (0.0.28)
ffi (>= 0.6.1)
json_pure
rubyzip
term-ansicolor (1.0.5)
thoughtbot-shoulda (2.11.1)
trollop (1.16.2)
unindentable (0.0.3)
version_string (0.1.0)
webrat (0.7.1)
nokogiri (>= 1.2.0)
rack (>= 1.0)
rack-test (>= 0.5.3)

PLATFORMS
ruby

DEPENDENCIES
authlogic (>= 2.1.1)
authlogic-oid (>= 1.0.4)
capybara
cucumber-rails
database_cleaner (>= 0.5.2)
database_cleaner
datacatalog (>= 0.4.14)
delayed_job (>= 1.8.4)
faker (>= 0.3.1)
Expand All @@ -112,4 +125,3 @@ DEPENDENCIES
ruby-openid (>= 2.1.7)
thoughtbot-shoulda (>= 2.10.0)
unindentable (>= 0.0.1)
webrat (>= 0.4.5)
1 change: 0 additions & 1 deletion config/environments/selenium.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
require Rails.root.to_s + "/lib/utilities"

config.cache_classes = true
config.action_controller.session = { :session_http_only => false }
config.whiny_nils = true
config.action_controller.consider_all_requests_local = true
config.action_controller.perform_caching = false
Expand Down
9 changes: 1 addition & 8 deletions cucumber.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1 @@
default: -i -r features/support/env.rb -r features/step_definitions -r features/support/simulated.rb -e selenium* features/simulated
selenium: -i -r features/support/env.rb -r features/step_definitions -r features/support/selenium.rb -e simulated.rb features/simulated features/selenium
signup: -i -r features/support/env.rb -r features/step_definitions -r features/support/simulated.rb -e selenium* -t @signup features/simulated
signin: -i -r features/support/env.rb -r features/step_definitions -r features/support/simulated.rb -e selenium* -t @signin features/simulated
users: -i -r features/support/env.rb -r features/step_definitions -r features/support/simulated.rb -e selenium* -t @users features/simulated
openid: -i -r features/support/env.rb -r features/step_definitions -r features/support/simulated.rb -e selenium* -t @openid features/simulated
keys: -i -r features/support/env.rb -r features/step_definitions -r features/support/simulated.rb -e selenium* -t @keys features/simulated
submissions: -i -r features/support/env.rb -r features/step_definitions -r features/support/simulated.rb -e selenium* -t @submissions features/simulated
default: -i -r features/support/env.rb -r features/step_definitions features/simulated
5 changes: 2 additions & 3 deletions features/simulated/contact_us.feature
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,11 @@ Feature: Contact Us
Scenario: View contact form as logged in user
Given I am signed in
When I go to the contact form
Then I should not see "Name"
And I should not see "Email"
Then I should not see fields for name or email

Scenario: Use contact form as logged in user
Given I am signed in
When I go to the contact form
And I fill in "Comments" with "Some message."
And I press "Submit"
Then I should see "Your message has been received"
Then I should see "Your message has been received"
3 changes: 2 additions & 1 deletion features/simulated/generate_api_key.feature
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,10 @@ Feature:
And I press "Update"
Then I should see "The API key has been updated"

@javascript
Scenario: Delete an existing API key
Given I am signed in
And I have an existing application key with "To make an awesome dataviz app" as its purpose
When I am on my profile page
And I choose to "Delete" that key
Then I should see "The API key has been deleted"
Then I should see "The API key has been deleted"
3 changes: 0 additions & 3 deletions features/simulated/sign_up.feature
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,3 @@ Feature: Sign up
Given I have signed up but not yet confirmed
When I click on the confirmation link
Then I should see "Your email address has been confirmed"



4 changes: 1 addition & 3 deletions features/step_definitions/api_keys_steps.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,5 @@
end

When /^I choose to "([^\"]*)" that key$/ do |action|
within "table#keys tr:nth-child(3)" do
click_link action
end
click_link action
end
4 changes: 4 additions & 0 deletions features/step_definitions/contact_us_steps.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Then /^I should not see fields for name or email$/ do
page.should_not have_css("#contact_submission_name")
page.should_not have_css("#contact_submission_email")
end
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,11 @@
end

Then /^I should see "([^\"]*)"$/ do |text|
response.should contain(text)
page.should have_content(text)
end

Then /^I should not see "([^\"]*)"$/ do |text|
response.should_not contain(text)
page.should_not have_content(text)
end

Then /^the "([^\"]*)" field should contain "([^\"]*)"$/ do |field, value|
Expand Down
15 changes: 13 additions & 2 deletions features/support/env.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,13 @@
require File.expand_path(File.dirname(__FILE__) + '/../../config/environment')
require 'cucumber/rails/world'
require 'cucumber/formatter/unicode'
require 'webrat'
require 'capybara/rails'
require 'capybara/cucumber'
require 'cucumber/rails/rspec'
require 'webrat/core/matchers'
require 'database_cleaner'
require 'database_cleaner/cucumber'

DatabaseCleaner.strategy = :truncation

ActionController::Base.class_eval do

Expand All @@ -18,6 +22,9 @@ def begin_open_id_authentication(identity_url, options = {})
end

Before do
DatabaseCleaner.start

# Remove all the users and sources from the local API
DataCatalog::User.all.each do |u|
DataCatalog::User.destroy(u.id) unless u.name == "Primary Admin"
end
Expand All @@ -26,3 +33,7 @@ def begin_open_id_authentication(identity_url, options = {})
DataCatalog::Source.destroy(s.id)
end
end

After do
DatabaseCleaner.clean
end
12 changes: 6 additions & 6 deletions features/support/paths.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,17 @@ def path_to(page_name)
when /the homepage/
'/'
when /sign up/
'signup'
'/signup'
when /sign in/
'signin'
'/signin'
when /sign out/
'signout'
'/signout'
when /my profile/
'profile'
'/profile/'
when /the contact form/
'contact'
'/contact'
when /the data source suggestion form/
'suggest'
'/suggest'

# Add more mappings here.
# Here is a more fancy example:
Expand Down
20 changes: 0 additions & 20 deletions features/support/selenium.rb

This file was deleted.

4 changes: 0 additions & 4 deletions features/support/simulated.rb

This file was deleted.

0 comments on commit 682dbcb

Please sign in to comment.