only run the provided specs
This commit is contained in:
parent
cf5cd24d1b
commit
b2571b4e3e
@ -33,7 +33,7 @@ Let me know via a message or in the Issues section if it works on your setup and
|
|||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
jasmine-headless-webkit [options]
|
jasmine-headless-webkit [options] [list of spec files to run]
|
||||||
|
|
||||||
Current supported options:
|
Current supported options:
|
||||||
|
|
||||||
@ -42,6 +42,8 @@ Current supported options:
|
|||||||
* `--keep` preserves the temporary HTML document if an error occurs in testing
|
* `--keep` preserves the temporary HTML document if an error occurs in testing
|
||||||
* `-j`/`--jasmine-config` sets the `jasmine.yml` file to load *(defaults to `spec/javascripts/support/jasmine.yml`)*
|
* `-j`/`--jasmine-config` sets the `jasmine.yml` file to load *(defaults to `spec/javascripts/support/jasmine.yml`)*
|
||||||
|
|
||||||
|
If provided, only the requested spec files will be executed. Otherwise, all matching specs will be run.
|
||||||
|
|
||||||
These options can also be placed into a `.jasmine-headless-webkit` file in your project root.
|
These options can also be placed into a `.jasmine-headless-webkit` file in your project root.
|
||||||
|
|
||||||
### CoffeeScript Support
|
### CoffeeScript Support
|
||||||
|
@ -51,6 +51,8 @@ options = {
|
|||||||
read_defaults_file if defaults_file?
|
read_defaults_file if defaults_file?
|
||||||
opts.each(&@process_options)
|
opts.each(&@process_options)
|
||||||
|
|
||||||
|
@spec_filter = ARGV.dup
|
||||||
|
|
||||||
data = YAML.load_file(options[:jasmine_config])
|
data = YAML.load_file(options[:jasmine_config])
|
||||||
|
|
||||||
if !File.file?(File.join(gem_dir, RUNNER))
|
if !File.file?(File.join(gem_dir, RUNNER))
|
||||||
@ -70,7 +72,11 @@ files += [ [ 'src_files', 'src_dir' ], [ 'stylesheets', 'src_dir' ], [ 'helpers'
|
|||||||
data[searches].collect do |search|
|
data[searches].collect do |search|
|
||||||
path = search
|
path = search
|
||||||
path = File.join(data[root], path) if data[root]
|
path = File.join(data[root], path) if data[root]
|
||||||
Dir[path]
|
files = Dir[path]
|
||||||
|
if searches == 'spec_files'
|
||||||
|
files = files.find_all { |file| use_spec?(file) }
|
||||||
|
end
|
||||||
|
files
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -24,6 +24,10 @@ module Jasmine
|
|||||||
File.file?(DEFAULTS_FILE)
|
File.file?(DEFAULTS_FILE)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def use_spec?(file)
|
||||||
|
@spec_filter.empty? || @spec_filter.include?(file)
|
||||||
|
end
|
||||||
|
|
||||||
def jasmine_html_template(files)
|
def jasmine_html_template(files)
|
||||||
<<-HTML
|
<<-HTML
|
||||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||||||
|
@ -59,4 +59,32 @@ describe Jasmine::CLI do
|
|||||||
found.should be_true
|
found.should be_true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe '#use_spec?' do
|
||||||
|
let(:spec_file) { 'my/spec.js' }
|
||||||
|
|
||||||
|
context 'no filter provided' do
|
||||||
|
before do
|
||||||
|
@spec_filter = []
|
||||||
|
end
|
||||||
|
|
||||||
|
it "should allow the spec" do
|
||||||
|
use_spec?(spec_file).should be_true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'filter provided' do
|
||||||
|
before do
|
||||||
|
@spec_filter = [ spec_file ]
|
||||||
|
end
|
||||||
|
|
||||||
|
it "should use the spec" do
|
||||||
|
use_spec?(spec_file).should be_true
|
||||||
|
end
|
||||||
|
|
||||||
|
it "should not use the spec" do
|
||||||
|
use_spec?('other/file').should be_false
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user