From bfbc9243c35979f84a31c7bb8897bc8976ea5a0d Mon Sep 17 00:00:00 2001 From: John Bintz Date: Fri, 20 Jan 2012 09:46:29 -0500 Subject: [PATCH] look sir, cucumbers --- .gitignore | 4 ++- Gemfile | 5 ++- Gemfile.lock | 33 ------------------- features/home_page.feature | 7 ++++ .../given/i_have_a_running_wordpress_site.rb | 3 ++ ...i_should_not_see_wordpress_installation.rb | 3 ++ .../then/i_should_see_a_wordpress_site.rb | 3 ++ features/step_definitions/when/i_visit.rb | 3 ++ features/support/env.rb | 19 +++++++++++ 9 files changed, 45 insertions(+), 35 deletions(-) delete mode 100644 Gemfile.lock create mode 100644 features/home_page.feature create mode 100644 features/step_definitions/given/i_have_a_running_wordpress_site.rb create mode 100644 features/step_definitions/then/i_should_not_see_wordpress_installation.rb create mode 100644 features/step_definitions/then/i_should_see_a_wordpress_site.rb create mode 100644 features/step_definitions/when/i_visit.rb create mode 100644 features/support/env.rb diff --git a/.gitignore b/.gitignore index 0f1fad3..efa8621 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,6 @@ .vagrant themes/* plugins/* -wordpress/* \ No newline at end of file +wordpress/* +Gemfile.lock + diff --git a/Gemfile b/Gemfile index bd7c437..bb93b34 100644 --- a/Gemfile +++ b/Gemfile @@ -1,4 +1,7 @@ # A sample Gemfile source "http://rubygems.org" -gem "vagrant" +gem "vagrant", '~> 0.8.0' +gem 'cucumber' +gem 'capybara-webkit' +gem 'rspec' diff --git a/Gemfile.lock b/Gemfile.lock deleted file mode 100644 index d700360..0000000 --- a/Gemfile.lock +++ /dev/null @@ -1,33 +0,0 @@ -GEM - remote: http://rubygems.org/ - specs: - abstract (1.0.0) - archive-tar-minitar (0.5.2) - erubis (2.6.6) - abstract (>= 1.0.0) - ffi (1.0.9) - i18n (0.5.0) - json (1.5.1) - mario (0.0.6) - net-scp (1.0.4) - net-ssh (>= 1.99.1) - net-ssh (2.1.4) - thor (0.14.6) - vagrant (0.7.5) - archive-tar-minitar (= 0.5.2) - erubis (~> 2.6.6) - i18n (~> 0.5.0) - json (~> 1.5.1) - mario (~> 0.0.6) - net-scp (~> 1.0.4) - net-ssh (~> 2.1.0) - thor (~> 0.14.6) - virtualbox (~> 0.8.3) - virtualbox (0.8.6) - ffi (~> 1.0) - -PLATFORMS - ruby - -DEPENDENCIES - vagrant diff --git a/features/home_page.feature b/features/home_page.feature new file mode 100644 index 0000000..ff80bc0 --- /dev/null +++ b/features/home_page.feature @@ -0,0 +1,7 @@ +Feature: Home Page + Scenario: Load the home page + Given I have a running WordPress site + When I visit the home page + Then I should not see a WordPress installation page + And I should see a WordPress site + diff --git a/features/step_definitions/given/i_have_a_running_wordpress_site.rb b/features/step_definitions/given/i_have_a_running_wordpress_site.rb new file mode 100644 index 0000000..6636211 --- /dev/null +++ b/features/step_definitions/given/i_have_a_running_wordpress_site.rb @@ -0,0 +1,3 @@ +Given /^I have a running WordPress site$/ do + ensure_vagrant_running +end diff --git a/features/step_definitions/then/i_should_not_see_wordpress_installation.rb b/features/step_definitions/then/i_should_not_see_wordpress_installation.rb new file mode 100644 index 0000000..1f93661 --- /dev/null +++ b/features/step_definitions/then/i_should_not_see_wordpress_installation.rb @@ -0,0 +1,3 @@ +Then /^I should not see a WordPress installation page$/ do + page.should_not have_css('link[href*="install.css"]') +end diff --git a/features/step_definitions/then/i_should_see_a_wordpress_site.rb b/features/step_definitions/then/i_should_see_a_wordpress_site.rb new file mode 100644 index 0000000..e8ef327 --- /dev/null +++ b/features/step_definitions/then/i_should_see_a_wordpress_site.rb @@ -0,0 +1,3 @@ +Then /^I should see a WordPress site$/ do + page.should have_css('meta[content*="WordPress"]') +end diff --git a/features/step_definitions/when/i_visit.rb b/features/step_definitions/when/i_visit.rb new file mode 100644 index 0000000..6171dda --- /dev/null +++ b/features/step_definitions/when/i_visit.rb @@ -0,0 +1,3 @@ +When /^I visit the home page$/ do + visit '/' +end diff --git a/features/support/env.rb b/features/support/env.rb new file mode 100644 index 0000000..b0ebaa4 --- /dev/null +++ b/features/support/env.rb @@ -0,0 +1,19 @@ +require 'capybara/cucumber' + +Capybara.app_host = 'http://localhost:8080/' + +require 'capybara-webkit' + +Capybara.default_driver = :webkit + +def ensure_vagrant_running + require 'vagrant' + + vm = Vagrant::Environment.new.primary_vm + if !vm.created? + raise StandardError.new("VM not created! Run `bundle exec vagrant up`.") + end + + vm.start +end +