Skip to content

Instantly share code, notes, and snippets.

@superchris
Created July 14, 2010 22:33
Show Gist options
  • Save superchris/476200 to your computer and use it in GitHub Desktop.
Save superchris/476200 to your computer and use it in GitHub Desktop.
require File.dirname(__FILE__) + '/../test_helper'
class JSpecTest < ActionController::IntegrationTest
include Capybara
def setup
@wait_time = Capybara.default_wait_time
Capybara.default_wait_time = 15
end
['outright.ledgerTest.js',
'outright.txnRendererTest.js',
'outright.txnTest.js',
'outright.txnRowTest.js',
'outright.userPreferenceTest.js',
'outright.mileageRateTest.js',
'outright.categoryFieldTest.js'].each do |jspec|
define_method "test_#{jspec.gsub(".", "_").gsub(/_js$/, "").underscore}" do
run_jspec(jspec)
end
end
def run_jspec(jspec_file)
# Demetertacular!!
page.driver.browser.navigate.to "file://#{Rails.root}/test/javascripts/spec.browser.html?test=#{jspec_file}"
assert page.has_css?(".failures")
assert_match /\s+0$/, page.locate(:css, ".failures").text, "#{jspec_file} failed."
# puts page.all(:css, ".fail").each {|failure| failure.text }
end
def teardown
Capybara.default_wait_time = @wait_time
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment