diff --git a/Gemfile b/Gemfile index 3d86773..cc85515 100644 --- a/Gemfile +++ b/Gemfile @@ -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 diff --git a/Gemfile.lock b/Gemfile.lock index 8897c2b..fbbf752 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -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) @@ -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) @@ -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) @@ -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) @@ -75,17 +86,18 @@ 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 @@ -93,8 +105,9 @@ PLATFORMS 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) @@ -112,4 +125,3 @@ DEPENDENCIES ruby-openid (>= 2.1.7) thoughtbot-shoulda (>= 2.10.0) unindentable (>= 0.0.1) - webrat (>= 0.4.5) diff --git a/config/environments/selenium.rb b/config/environments/selenium.rb index e567ede..14d4710 100644 --- a/config/environments/selenium.rb +++ b/config/environments/selenium.rb @@ -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 diff --git a/cucumber.yml b/cucumber.yml index 36f545f..8a09243 100644 --- a/cucumber.yml +++ b/cucumber.yml @@ -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 diff --git a/features/simulated/contact_us.feature b/features/simulated/contact_us.feature index 3b77603..ef75870 100644 --- a/features/simulated/contact_us.feature +++ b/features/simulated/contact_us.feature @@ -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" \ No newline at end of file + Then I should see "Your message has been received" diff --git a/features/simulated/generate_api_key.feature b/features/simulated/generate_api_key.feature index 7d62472..ccb6a6f 100644 --- a/features/simulated/generate_api_key.feature +++ b/features/simulated/generate_api_key.feature @@ -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" \ No newline at end of file + Then I should see "The API key has been deleted" diff --git a/features/simulated/sign_up.feature b/features/simulated/sign_up.feature index e2c0a89..e81e68c 100644 --- a/features/simulated/sign_up.feature +++ b/features/simulated/sign_up.feature @@ -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" - - - \ No newline at end of file diff --git a/features/step_definitions/api_keys_steps.rb b/features/step_definitions/api_keys_steps.rb index 4277092..74a50a3 100644 --- a/features/step_definitions/api_keys_steps.rb +++ b/features/step_definitions/api_keys_steps.rb @@ -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 diff --git a/features/step_definitions/contact_us_steps.rb b/features/step_definitions/contact_us_steps.rb new file mode 100644 index 0000000..08ac6dd --- /dev/null +++ b/features/step_definitions/contact_us_steps.rb @@ -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 diff --git a/features/step_definitions/webrat_steps.rb b/features/step_definitions/web_steps.rb similarity index 98% rename from features/step_definitions/webrat_steps.rb rename to features/step_definitions/web_steps.rb index fe602eb..0e368b3 100644 --- a/features/step_definitions/webrat_steps.rb +++ b/features/step_definitions/web_steps.rb @@ -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| diff --git a/features/support/env.rb b/features/support/env.rb index 62e5b76..c2b7683 100644 --- a/features/support/env.rb +++ b/features/support/env.rb @@ -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 @@ -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 @@ -26,3 +33,7 @@ def begin_open_id_authentication(identity_url, options = {}) DataCatalog::Source.destroy(s.id) end end + +After do + DatabaseCleaner.clean +end diff --git a/features/support/paths.rb b/features/support/paths.rb index bbc5f4b..743ecda 100644 --- a/features/support/paths.rb +++ b/features/support/paths.rb @@ -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: diff --git a/features/support/selenium.rb b/features/support/selenium.rb deleted file mode 100644 index 7eb13f5..0000000 --- a/features/support/selenium.rb +++ /dev/null @@ -1,20 +0,0 @@ -Webrat.configure do |config| - config.mode = :selenium - config.application_environment = :selenium -end - -ENV["RAILS_ENV"] ||= "selenium" - -World(Webrat::Selenium::Matchers) - -require 'database_cleaner' -require 'database_cleaner/cucumber' -DatabaseCleaner.strategy = :truncation - -Before do - DatabaseCleaner.start -end - -After do - DatabaseCleaner.clean -end \ No newline at end of file diff --git a/features/support/simulated.rb b/features/support/simulated.rb deleted file mode 100644 index 1f22e01..0000000 --- a/features/support/simulated.rb +++ /dev/null @@ -1,4 +0,0 @@ -Webrat.configure do |config| - config.mode = :rails -end -