spec/inspector_spec.rb in mislav-rspactor-0.3.2 vs spec/inspector_spec.rb in mislav-rspactor-0.3.3
- old
+ new
@@ -62,10 +62,14 @@
it "should consider all models when db/schema.rb changes" do
translate('db/schema.rb').should == ['spec/models']
end
+ it "should consider related model when its observer changes" do
+ translate('app/models/user_observer.rb').should == ['spec/models/user_observer_spec.rb', 'spec/models/user_spec.rb']
+ end
+
it "should consider all specs when spec_helper changes" do
translate('spec/spec_helper.rb').should == ['spec']
end
it "should consider all specs when code under spec/shared/ changes" do
@@ -74,8 +78,42 @@
it "should consider all specs when app configuration changes" do
translate('config/environment.rb').should == ['spec']
translate('config/environments/test.rb').should == ['spec']
translate('config/boot.rb').should == ['spec']
+ end
+ end
+
+ describe "#determine_spec_files" do
+ def determine(file)
+ @inspector.determine_spec_files(file)
+ end
+
+ it "should filter out files that don't exist on the filesystem" do
+ @inspector.should_receive(:translate).with('foo').and_return(%w(valid_spec.rb invalid_spec.rb))
+ File.should_receive(:exists?).with('valid_spec.rb').and_return(true)
+ File.should_receive(:exists?).with('invalid_spec.rb').and_return(false)
+ determine('foo').should == ['valid_spec.rb']
+ end
+
+ it "should filter out files in subdirectories that are already on the list" do
+ @inspector.should_receive(:translate).with('foo').and_return(%w(
+ spec/foo_spec.rb
+ spec/views/moo/bar_spec.rb
+ spec/views/baa/boo_spec.rb
+ spec/models/baz_spec.rb
+ spec/controllers/moo_spec.rb
+ spec/models
+ spec/controllers
+ spec/views/baa
+ ))
+ File.stub!(:exists?).and_return(true)
+ determine('foo').should == %w(
+ spec/foo_spec.rb
+ spec/views/moo/bar_spec.rb
+ spec/models
+ spec/controllers
+ spec/views/baa
+ )
end
end
end
\ No newline at end of file