Created
July 17, 2009 08:29
-
-
Save jnicklas/148947 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require("spec_helper.js"); | |
require("../../public/javascripts/add_data.js"); | |
Screw.Unit(function(){ | |
describe("AddData", function(){ | |
describe('adding rows', function() { | |
...snip... | |
}); | |
}); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "#{File.dirname(__FILE__)}/javascript_spec_helper" | |
run_javascript_spec(:add_data, "/data_points/new.html.erb") do | |
@current_user = User.make | |
@current_account = Account.make | |
@current_account.data_types << DataType.make(:name => 'Profit') | |
@current_account.data_types << DataType.make(:name => 'Revenue') | |
template.stub!(:current_user).and_return(@current_user) | |
template.stub!(:current_account).and_return(@current_account) | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "#{File.dirname(__FILE__)}/../spec_helper" | |
def run_javascript_spec(name, view, &setup) | |
plugin_prefix = "#{RAILS_ROOT}/vendor/plugins/blue-ridge" | |
rhino_command = "java -jar #{plugin_prefix}/lib/js.jar -w -debug" | |
test_runner_command = "#{rhino_command} #{plugin_prefix}/lib/test_runner.js" | |
html_layout = lambda { |body| | |
<<-HTML | |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> | |
<html xmlns="http://www.w3.org/1999/xhtml"> | |
<head> | |
<title>Application | JavaScript Testing Results</title> | |
<link rel="stylesheet" href="screw.css" type="text/css" charset="utf-8" /> | |
<script type="text/javascript" src="../../../vendor/plugins/blue-ridge/lib/blue-ridge.js"></script> | |
</head> | |
<body> | |
<!-- Put any HTML fixture elements here. --> | |
#{body} | |
</body> | |
</html> | |
HTML | |
} | |
describe view, :type => :view do | |
before(&setup) | |
it "should pass javascript tests" do | |
render | |
File.open(File.join(File.dirname(__FILE__), "fixtures/#{name}.html"), 'w') do |f| | |
f.write html_layout.call(response.body) | |
end | |
Dir.chdir(File.join(File.dirname(__FILE__))) do | |
puts "\n" | |
unless system("#{test_runner_command} #{name}_spec.js") | |
flunk "javascript test failure" | |
end | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment