jasmine-headless-webkit/lib/jasmine/cli.rb

56 lines
1.3 KiB
Ruby
Raw Normal View History

2011-05-06 18:05:15 +00:00
module Jasmine
module CLI
DEFAULTS = {
'spec_files' => [ '**/*[sS]pec.js' ],
'helpers' => [ 'helpers/**/*.js' ],
'spec_dir' => 'spec/javascripts',
'src_dir' => nil,
2011-05-06 18:05:15 +00:00
'stylesheets' => [],
'src_files' => []
}
2011-05-10 13:25:55 +00:00
RUNNER = 'ext/jasmine-webkit-specrunner/jasmine-webkit-specrunner'
2011-05-09 19:52:11 +00:00
DEFAULTS_FILE = '.jasmine-headless-webkit'
2011-05-06 18:05:15 +00:00
def process_jasmine_config(overrides = {})
DEFAULTS.merge(overrides)
end
2011-05-09 19:52:11 +00:00
def read_defaults_file
File.readlines(DEFAULTS_FILE).collect { |line| line.strip.split(' ', 2) }.each(&@process_options)
end
def defaults_file?
File.file?(DEFAULTS_FILE)
end
2011-05-10 13:25:55 +00:00
2011-05-11 14:29:02 +00:00
def use_spec?(file)
@spec_filter.empty? || @spec_filter.include?(file)
end
2011-05-10 13:25:55 +00:00
def jasmine_html_template(files)
<<-HTML
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Jasmine Test Runner</title>
<script type="text/javascript">
2011-05-12 21:02:11 +00:00
window.console = { log: function(data) { JHW.log(JSON.stringify(data)); } };
2011-05-10 13:25:55 +00:00
</script>
2011-05-12 21:02:11 +00:00
#{files.join("\n")}
2011-05-10 13:25:55 +00:00
</head>
<body>
<script type="text/javascript">
2011-05-12 21:02:11 +00:00
jasmine.getEnv().addReporter(new jasmine.HeadlessReporter());
2011-05-10 13:25:55 +00:00
jasmine.getEnv().execute();
</script>
</body>
</html>
HTML
end
2011-05-06 18:05:15 +00:00
end
end