Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Test framework.

  • Loading branch information...
commit c3553c0d2194d8d53f058b2b4c5a6771109c13d7 1 parent 24d8652
@jfirebaugh authored
View
5 Rakefile
@@ -1,2 +1,7 @@
require 'bundler'
+require 'cucumber/rake/task'
+
Bundler::GemHelper.install_tasks
+Cucumber::Rake::Task.new
+
+task :default => :cucumber
View
26 features/step_definitions/web_steps.rb
@@ -0,0 +1,26 @@
+require File.expand_path(File.join(File.dirname(__FILE__), "..", "support", "selectors"))
+
+module WithinHelpers
+ def with_scope(locator)
+ locator ? within(*selector_for(locator)) { yield } : yield
+ end
+end
+World(WithinHelpers)
+
+# Single-line step scoper
+When /^(.*) within ([^:]+)$/ do |step, parent|
+ with_scope(parent) { When step }
+end
+
+# Multi-line step scoper
+When /^(.*) within ([^:]+):$/ do |step, parent, table_or_string|
+ with_scope(parent) { When "#{step}:", table_or_string }
+end
+
+When /^I visit the (.+) page$/ do |page|
+ visit("/#{page}.html")
+end
+
+Then /^I should see "([^"]+)"$/ do |text|
+ page.should have_content(text)
+end
View
16 features/support/env.rb
@@ -0,0 +1,16 @@
+require 'bundler'
+Bundler.require
+
+require 'capybara/cucumber'
+require 'bermuda/cucumber'
+
+require 'rack/builder'
+require 'rack/file'
+require 'rack/directory'
+
+Capybara.configure do |config|
+ config.default_driver = :selenium
+ config.app = Rack::Builder.app do
+ run Rack::Directory.new "public"
+ end
+end
View
18 features/support/selectors.rb
@@ -0,0 +1,18 @@
+module HtmlSelectorsHelpers
+ # Maps a name to a selector. Used primarily by the
+ #
+ # When /^(.+) within (.+)$/ do |step, scope|
+ #
+ # step definitions in web_steps.rb
+ #
+ def selector_for(locator)
+ case locator
+
+ else
+ raise "Can't find mapping from \"#{locator}\" to a selector.\n" +
+ "Now, go and add a mapping in #{__FILE__}"
+ end
+ end
+end
+
+World(HtmlSelectorsHelpers)
Please sign in to comment.
Something went wrong with that request. Please try again.