Skip to content
This repository has been archived by the owner on Dec 5, 2023. It is now read-only.

Commit

Permalink
only run the provided specs
Browse files Browse the repository at this point in the history
  • Loading branch information
johnbintz committed May 11, 2011
1 parent cf5cd24 commit b2571b4
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 2 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ Let me know via a message or in the Issues section if it works on your setup and

## Usage

jasmine-headless-webkit [options]
jasmine-headless-webkit [options] [list of spec files to run]

Current supported options:

Expand All @@ -42,6 +42,8 @@ Current supported options:
* `--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`)*

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.

### CoffeeScript Support
Expand Down
8 changes: 7 additions & 1 deletion bin/jasmine-headless-webkit
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ options = {
read_defaults_file if defaults_file?
opts.each(&@process_options)

@spec_filter = ARGV.dup

data = YAML.load_file(options[:jasmine_config])

if !File.file?(File.join(gem_dir, RUNNER))
Expand All @@ -70,7 +72,11 @@ files += [ [ 'src_files', 'src_dir' ], [ 'stylesheets', 'src_dir' ], [ 'helpers'
data[searches].collect do |search|
path = search
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
Expand Down
4 changes: 4 additions & 0 deletions lib/jasmine/cli.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ def defaults_file?
File.file?(DEFAULTS_FILE)
end

def use_spec?(file)
@spec_filter.empty? || @spec_filter.include?(file)
end

def jasmine_html_template(files)
<<-HTML
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
Expand Down
28 changes: 28 additions & 0 deletions spec/lib/jasmine/cli_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,32 @@
found.should be_true
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

0 comments on commit b2571b4

Please sign in to comment.