Permalink
Browse files

targeted runs w/ files outside scope work

  • Loading branch information...
1 parent e9a9a79 commit c359e8b28bfff40ffa9bd88a3cd43ecf31db9751 @johnbintz johnbintz committed Jun 23, 2011
View
@@ -11,7 +11,7 @@
module Jasmine
class FilesList
- attr_reader :files, :filtered_files
+ attr_reader :files, :filtered_files, :spec_outside_scope
DEFAULT_FILES = [
File.join(Jasmine.root, "lib/jasmine.js"),
@@ -23,11 +23,16 @@ def initialize(options = {})
@options = options
@files = DEFAULT_FILES.dup
@filtered_files = @files.dup
+ @spec_outside_scope = false
use_config! if config?
@code_for_file = {}
end
+ def has_spec_outside_scope?
+ @spec_outside_scope
+ end
+
def use_spec?(file)
spec_filter.empty? || spec_filter.include?(file)
end
@@ -114,10 +119,12 @@ def use_config!
@files += found_files
- if searches == 'spec_files'
- found_files = found_files.find_all { |file| use_spec?(file) }
- end
- @filtered_files += found_files
+ @filtered_files += (if searches == 'spec_files'
+ @spec_outside_scope = ((spec_filter | found_files).sort != found_files.sort)
+ spec_filter || found_files
+ else
+ found_files
+ end)
end
end
end
@@ -58,7 +58,7 @@ def run
targets = Jasmine::TemplateWriter.write!(files_list)
run_targets = targets.dup
- run_targets.pop if !@options[:full_run] && files_list.filtered?
+ run_targets.pop if (!@options[:full_run] && files_list.filtered?) || files_list.has_spec_outside_scope?
system jasmine_command(run_targets)
status = $?.exitstatus
@@ -26,7 +26,7 @@
system %{bin/jasmine-headless-webkit -j spec/jasmine/success_with_error/success_with_error.yml --report #{report}}
$?.exitstatus.should == 1
- report.should be_a_report_containing(1, 0, false)
+ report.should be_a_report_containing(0, 0, false)
end
end
@@ -65,6 +65,13 @@
report.should be_a_report_containing(1, 0, false)
end
+
+ it "should use a file outside the normal test run and only run one" do
+ system %{bin/jasmine-headless-webkit -j spec/jasmine/filtered_success/filtered_success.yml --report #{report} ./spec/jasmine/filtered_success/success_other_file.js}
+ $?.exitstatus.should == 0
+
+ report.should be_a_report_containing(1, 0, false)
+ end
end
context "do both runs" do
@@ -0,0 +1,7 @@
+describe('outside success', function() {
+ it('should succeed', function() {
+ expect(true).toEqual(true);
+ });
+});
+
+
@@ -99,15 +99,28 @@
end
end
- let(:filter) { 'spec/one_spec.js' }
+ context 'filter with a file that is matchable' do
+ let(:filter) { [ File.expand_path('spec/one_spec.js') ] }
- it 'should return all files for files' do
- files_list.files.any? { |file| file['two_spec.js'] }.should be_true
- files_list.filtered?.should be_true
+ it 'should return all files for files' do
+ files_list.files.any? { |file| file['two_spec.js'] }.should be_true
+ files_list.filtered?.should be_true
+ files_list.should_not have_spec_outside_scope
+ end
+
+ it 'should return only filtered files for filtered_files' do
+ files_list.filtered_files.any? { |file| file['two_spec.js'] }.should be_false
+ files_list.should_not have_spec_outside_scope
+ end
end
- it 'should return only filtered files for filtered_files' do
- files_list.filtered_files.any? { |file| file['two_spec.js'] }.should be_false
+ context 'filter with a file that is not even there' do
+ let(:filter) { [ File.expand_path('spec/whatever.js') ] }
+
+ it 'should use the provided file' do
+ files_list.filtered_files.any? { |file| file['whatever.js'] }.should be_true
+ files_list.should have_spec_outside_scope
+ end
end
end
View
@@ -12,12 +12,20 @@
RSpec::Matchers.define :be_a_report_containing do |total, fails, used_console|
match do |filename|
- parts = File.read(filename).strip.split('/')
- parts.length.should == 4
+ parts(filename).length.should == 4
parts[0].should == total.to_s
parts[1].should == fails.to_s
parts[2].should == (used_console ? "T" : "F")
true
end
+
+ failure_message_for_should do |filename|
+ parts(filename)
+ "expected #{filename} to be a report containing (#{total}, #{fails}, #{used_console.inspect}), instead it contained (#{parts[0]}, #{parts[1]}, #{(parts[2] == "T").inspect})"
+ end
+
+ def parts(filename = nil)
+ @parts ||= File.read(filename).strip.split('/')
+ end
end

0 comments on commit c359e8b

Please sign in to comment.