rspactor 0.6.4 → 0.7.0.beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/LICENSE +2 -2
- data/README.rdoc +62 -15
- data/bin/rspactor +10 -9
- data/ext/fsevent/extconf.rb +28 -0
- data/ext/fsevent/fsevent_watch.c +44 -0
- data/images/failed.png +0 -0
- data/images/success.png +0 -0
- data/lib/growl/growl_formatter.rb +35 -0
- data/lib/rspactor/inspector.rb +36 -102
- data/lib/rspactor/interactor.rb +24 -92
- data/lib/rspactor/listener.rb +33 -62
- data/lib/rspactor/runner.rb +33 -173
- data/lib/rspactor/ui.rb +37 -0
- data/lib/rspactor/version.rb +3 -0
- data/lib/rspactor.rb +26 -7
- metadata +79 -46
- data/.gitignore +0 -21
- data/.rspactor +0 -0
- data/Rakefile +0 -50
- data/VERSION +0 -1
- data/lib/cucumber_growler.rb +0 -61
- data/lib/rspactor/growl.rb +0 -14
- data/lib/rspactor/spork.rb +0 -60
- data/lib/rspec_growler.rb +0 -24
- data/rspactor.gemspec +0 -70
- data/spec/inspector_spec.rb +0 -131
- data/spec/listener_spec.rb +0 -39
- data/spec/runner_spec.rb +0 -265
data/lib/rspactor/spork.rb
DELETED
@@ -1,60 +0,0 @@
|
|
1
|
-
require 'rspactor'
|
2
|
-
require 'socket'
|
3
|
-
|
4
|
-
module RSpactor
|
5
|
-
class Spork
|
6
|
-
RSPEC_PORT = 8989
|
7
|
-
CUCUMBER_PORT = 8990
|
8
|
-
|
9
|
-
attr_accessor :use_cucumber
|
10
|
-
|
11
|
-
def initialize(runner)
|
12
|
-
@use_cucumber = runner.cucumber?
|
13
|
-
end
|
14
|
-
|
15
|
-
def start
|
16
|
-
execute(:start)
|
17
|
-
end
|
18
|
-
|
19
|
-
def reload
|
20
|
-
execute(:reload)
|
21
|
-
end
|
22
|
-
|
23
|
-
private
|
24
|
-
|
25
|
-
def execute(start_or_reload)
|
26
|
-
action_message = (start_or_reload == :start) ? "Starting" : "Reloading"
|
27
|
-
message = "** #{action_message} Spork for rspec"
|
28
|
-
message += " & cucumber" if use_cucumber
|
29
|
-
kill_and_launch(message)
|
30
|
-
end
|
31
|
-
|
32
|
-
def kill_and_launch(message)
|
33
|
-
Interactor.ticker_msg message do
|
34
|
-
|
35
|
-
system("kill $(ps aux | awk '/spork/&&!/awk/{print $2;}') >/dev/null 2>&1")
|
36
|
-
|
37
|
-
system("spork >/dev/null 2>&1 < /dev/null &")
|
38
|
-
wait_for('RSpec', RSPEC_PORT)
|
39
|
-
|
40
|
-
if use_cucumber
|
41
|
-
system("spork cu >/dev/null 2>&1 < /dev/null &")
|
42
|
-
wait_for('Cucumber', CUCUMBER_PORT)
|
43
|
-
end
|
44
|
-
end
|
45
|
-
end
|
46
|
-
|
47
|
-
def wait_for(sporker, port)
|
48
|
-
15.times do
|
49
|
-
begin
|
50
|
-
TCPSocket.new('localhost', port).close
|
51
|
-
rescue Errno::ECONNREFUSED
|
52
|
-
sleep(1)
|
53
|
-
next
|
54
|
-
end
|
55
|
-
return true
|
56
|
-
end
|
57
|
-
raise "could not load spork for #{sporker}; make sure you can use it manually first"
|
58
|
-
end
|
59
|
-
end
|
60
|
-
end
|
data/lib/rspec_growler.rb
DELETED
@@ -1,24 +0,0 @@
|
|
1
|
-
require 'spec/runner/formatter/base_formatter'
|
2
|
-
require File.dirname(__FILE__) + '/rspactor/growl'
|
3
|
-
|
4
|
-
class RSpecGrowler < Spec::Runner::Formatter::BaseFormatter
|
5
|
-
include RSpactor::Growl
|
6
|
-
|
7
|
-
def dump_summary(duration, total, failures, pending)
|
8
|
-
icon = if failures > 0
|
9
|
-
'failed'
|
10
|
-
elsif pending > 0
|
11
|
-
'pending'
|
12
|
-
else
|
13
|
-
'success'
|
14
|
-
end
|
15
|
-
|
16
|
-
# image_path = File.dirname(__FILE__) + "/../images/#{icon}.png"
|
17
|
-
message = "#{total} examples, #{failures} failures"
|
18
|
-
if pending > 0
|
19
|
-
message << " (#{pending} pending)"
|
20
|
-
end
|
21
|
-
|
22
|
-
notify "Spec Results", message, icon
|
23
|
-
end
|
24
|
-
end
|
data/rspactor.gemspec
DELETED
@@ -1,70 +0,0 @@
|
|
1
|
-
# Generated by jeweler
|
2
|
-
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
-
# Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
|
4
|
-
# -*- encoding: utf-8 -*-
|
5
|
-
|
6
|
-
Gem::Specification.new do |s|
|
7
|
-
s.name = %q{rspactor}
|
8
|
-
s.version = "0.6.4"
|
9
|
-
|
10
|
-
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
-
s.authors = ["Mislav Marohni\304\207", "Andreas Wolff", "Pelle Braendgaard", "Thibaud Guillaume-Gentil"]
|
12
|
-
s.date = %q{2010-06-04}
|
13
|
-
s.default_executable = %q{rspactor}
|
14
|
-
s.description = %q{RSpactor is a command line tool to automatically run your changed specs & cucumber features (much like autotest).}
|
15
|
-
s.email = %q{thibaud@thibaud.me}
|
16
|
-
s.executables = ["rspactor"]
|
17
|
-
s.extra_rdoc_files = [
|
18
|
-
"LICENSE",
|
19
|
-
"README.rdoc"
|
20
|
-
]
|
21
|
-
s.files = [
|
22
|
-
".gitignore",
|
23
|
-
".rspactor",
|
24
|
-
"LICENSE",
|
25
|
-
"README.rdoc",
|
26
|
-
"Rakefile",
|
27
|
-
"VERSION",
|
28
|
-
"bin/rspactor",
|
29
|
-
"images/failed.png",
|
30
|
-
"images/pending.png",
|
31
|
-
"images/success.png",
|
32
|
-
"lib/cucumber_growler.rb",
|
33
|
-
"lib/rspactor.rb",
|
34
|
-
"lib/rspactor/growl.rb",
|
35
|
-
"lib/rspactor/inspector.rb",
|
36
|
-
"lib/rspactor/interactor.rb",
|
37
|
-
"lib/rspactor/listener.rb",
|
38
|
-
"lib/rspactor/runner.rb",
|
39
|
-
"lib/rspactor/spork.rb",
|
40
|
-
"lib/rspec_growler.rb",
|
41
|
-
"rspactor.gemspec",
|
42
|
-
"spec/inspector_spec.rb",
|
43
|
-
"spec/listener_spec.rb",
|
44
|
-
"spec/runner_spec.rb"
|
45
|
-
]
|
46
|
-
s.homepage = %q{http://github.com/thibaudgg/rspactor}
|
47
|
-
s.rdoc_options = ["--charset=UTF-8"]
|
48
|
-
s.require_paths = ["lib"]
|
49
|
-
s.rubygems_version = %q{1.3.6}
|
50
|
-
s.summary = %q{RSpactor is a command line tool to automatically run your changed specs & cucumber features.}
|
51
|
-
s.test_files = [
|
52
|
-
"spec/inspector_spec.rb",
|
53
|
-
"spec/listener_spec.rb",
|
54
|
-
"spec/runner_spec.rb"
|
55
|
-
]
|
56
|
-
|
57
|
-
if s.respond_to? :specification_version then
|
58
|
-
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
59
|
-
s.specification_version = 3
|
60
|
-
|
61
|
-
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
62
|
-
s.add_development_dependency(%q<rspec>, [">= 1.2.9"])
|
63
|
-
else
|
64
|
-
s.add_dependency(%q<rspec>, [">= 1.2.9"])
|
65
|
-
end
|
66
|
-
else
|
67
|
-
s.add_dependency(%q<rspec>, [">= 1.2.9"])
|
68
|
-
end
|
69
|
-
end
|
70
|
-
|
data/spec/inspector_spec.rb
DELETED
@@ -1,131 +0,0 @@
|
|
1
|
-
require 'rspactor/inspector'
|
2
|
-
|
3
|
-
describe RSpactor::Inspector do
|
4
|
-
before(:all) do
|
5
|
-
options = { :view => true, :spork? => false }
|
6
|
-
@inspector = described_class.new(mock('Runner', :dir => '/project', :options => options))
|
7
|
-
end
|
8
|
-
|
9
|
-
def translate(file)
|
10
|
-
@inspector.translate(file)
|
11
|
-
end
|
12
|
-
|
13
|
-
describe "#translate" do
|
14
|
-
it "should consider all controllers when application_controller changes" do
|
15
|
-
translate('/project/app/controllers/application_controller.rb').should == ['/project/spec/controllers']
|
16
|
-
translate('/project/app/controllers/application.rb').should == ['/project/spec/controllers']
|
17
|
-
end
|
18
|
-
|
19
|
-
it "should translate files under 'app/' directory" do
|
20
|
-
translate('/project/app/controllers/foo_controller.rb').should ==
|
21
|
-
['/project/spec/controllers/foo_controller_spec.rb']
|
22
|
-
end
|
23
|
-
|
24
|
-
it "should translate templates" do
|
25
|
-
translate('/project/app/views/foo/bar.erb').should == ['/project/spec/views/foo/bar.erb_spec.rb']
|
26
|
-
translate('/project/app/views/foo/bar.html.haml').should ==
|
27
|
-
['/project/spec/views/foo/bar.html.haml_spec.rb', '/project/spec/views/foo/bar.html_spec.rb']
|
28
|
-
end
|
29
|
-
|
30
|
-
it "should consider all views when application_helper changes" do
|
31
|
-
translate('/project/app/helpers/application_helper.rb').should == ['/project/spec/helpers', '/project/spec/views']
|
32
|
-
end
|
33
|
-
|
34
|
-
it "should consider related templates when a helper changes" do
|
35
|
-
translate('/project/app/helpers/foo_helper.rb').should ==
|
36
|
-
['/project/spec/helpers/foo_helper_spec.rb', '/project/spec/views/foo']
|
37
|
-
end
|
38
|
-
|
39
|
-
it "should translate files under deep 'lib/' directory" do
|
40
|
-
translate('/project/lib/awesum/rox.rb').should ==
|
41
|
-
['/project/spec/lib/awesum/rox_spec.rb', '/project/spec/awesum/rox_spec.rb', '/project/spec/rox_spec.rb']
|
42
|
-
end
|
43
|
-
|
44
|
-
it "should translate files under shallow 'lib/' directory" do
|
45
|
-
translate('lib/runner.rb').should == ['/project/spec/lib/runner_spec.rb', '/project/spec/runner_spec.rb']
|
46
|
-
end
|
47
|
-
|
48
|
-
it "should handle relative paths" do
|
49
|
-
translate('foo.rb').should == ['/project/spec/foo_spec.rb']
|
50
|
-
end
|
51
|
-
|
52
|
-
it "should handle files without extension" do
|
53
|
-
translate('foo').should == ['/project/spec/foo_spec.rb']
|
54
|
-
end
|
55
|
-
|
56
|
-
it "should consider all controllers, helpers and views when routes.rb changes" do
|
57
|
-
translate('config/routes.rb').should == ['/project/spec/controllers', '/project/spec/helpers', '/project/spec/routing', '/project/spec/views']
|
58
|
-
end
|
59
|
-
|
60
|
-
it "should consider all models when config/database.yml changes" do
|
61
|
-
translate('config/database.yml').should == ['/project/spec/models']
|
62
|
-
end
|
63
|
-
|
64
|
-
it "should consider all models when db/schema.rb changes" do
|
65
|
-
translate('db/schema.rb').should == ['/project/spec/models']
|
66
|
-
end
|
67
|
-
|
68
|
-
it "should consider all models when spec/factories.rb changes" do
|
69
|
-
translate('spec/factories.rb').should == ['/project/spec/models']
|
70
|
-
end
|
71
|
-
|
72
|
-
it "should consider related model when its observer changes" do
|
73
|
-
translate('app/models/user_observer.rb').should == ['/project/spec/models/user_observer_spec.rb', '/project/spec/models/user_spec.rb']
|
74
|
-
end
|
75
|
-
|
76
|
-
it "should consider all specs when spec_helper changes" do
|
77
|
-
translate('spec/spec_helper.rb').should == ['spork', '/project/spec']
|
78
|
-
end
|
79
|
-
|
80
|
-
it "should consider all specs when code under spec/shared/ changes" do
|
81
|
-
translate('spec/shared/foo.rb').should == ['/project/spec']
|
82
|
-
end
|
83
|
-
|
84
|
-
it "should consider all specs when app configuration changes" do
|
85
|
-
translate('config/environment.rb').should == ['spork', '/project/spec']
|
86
|
-
translate('config/environments/test.rb').should == ['spork', '/project/spec']
|
87
|
-
translate('config/boot.rb').should == ['spork', '/project/spec']
|
88
|
-
end
|
89
|
-
|
90
|
-
it "should consider cucumber when a features file change" do
|
91
|
-
translate('features/login.feature').should == ['cucumber']
|
92
|
-
translate('features/steps/webrat_steps.rb').should == ['cucumber']
|
93
|
-
translate('features/support/env.rb').should == ['cucumber', 'spork']
|
94
|
-
end
|
95
|
-
|
96
|
-
end
|
97
|
-
|
98
|
-
describe "#determine_files" do
|
99
|
-
def determine(file)
|
100
|
-
@inspector.determine_files(file)
|
101
|
-
end
|
102
|
-
|
103
|
-
it "should filter out files that don't exist on the filesystem" do
|
104
|
-
@inspector.should_receive(:translate).with('foo').and_return(%w(valid_spec.rb invalid_spec.rb))
|
105
|
-
File.should_receive(:exists?).with('valid_spec.rb').and_return(true)
|
106
|
-
File.should_receive(:exists?).with('invalid_spec.rb').and_return(false)
|
107
|
-
determine('foo').should == ['valid_spec.rb']
|
108
|
-
end
|
109
|
-
|
110
|
-
it "should filter out files in subdirectories that are already on the list" do
|
111
|
-
@inspector.should_receive(:translate).with('foo').and_return(%w(
|
112
|
-
spec/foo_spec.rb
|
113
|
-
spec/views/moo/bar_spec.rb
|
114
|
-
spec/views/baa/boo_spec.rb
|
115
|
-
spec/models/baz_spec.rb
|
116
|
-
spec/controllers/moo_spec.rb
|
117
|
-
spec/models
|
118
|
-
spec/controllers
|
119
|
-
spec/views/baa
|
120
|
-
))
|
121
|
-
File.stub!(:exists?).and_return(true)
|
122
|
-
determine('foo').should == %w(
|
123
|
-
spec/foo_spec.rb
|
124
|
-
spec/views/moo/bar_spec.rb
|
125
|
-
spec/models
|
126
|
-
spec/controllers
|
127
|
-
spec/views/baa
|
128
|
-
)
|
129
|
-
end
|
130
|
-
end
|
131
|
-
end
|
data/spec/listener_spec.rb
DELETED
@@ -1,39 +0,0 @@
|
|
1
|
-
require 'rspactor/listener'
|
2
|
-
|
3
|
-
describe RSpactor::Listener do
|
4
|
-
before(:all) do
|
5
|
-
@listener = described_class.new(%w(rb erb haml))
|
6
|
-
end
|
7
|
-
|
8
|
-
it "should be timestamped" do
|
9
|
-
@listener.last_check.should be_instance_of(Time)
|
10
|
-
end
|
11
|
-
|
12
|
-
it "should not ignore regular directories" do
|
13
|
-
@listener.ignore_path?('/project/foo/bar').should_not be
|
14
|
-
end
|
15
|
-
|
16
|
-
it "should ignore .git directories" do
|
17
|
-
@listener.ignore_path?('/project/.git/index').should be
|
18
|
-
end
|
19
|
-
|
20
|
-
it "should ignore dotfiles" do
|
21
|
-
@listener.ignore_file?('/project/.foo').should be
|
22
|
-
end
|
23
|
-
|
24
|
-
it "should not ignore files in directories which start with a dot" do
|
25
|
-
@listener.ignore_file?('/project/.foo/bar.rb').should be_false
|
26
|
-
end
|
27
|
-
|
28
|
-
it "should not ignore files without extension" do
|
29
|
-
@listener.ignore_file?('/project/foo.rb').should be_false
|
30
|
-
end
|
31
|
-
|
32
|
-
it "should ignore files without extension" do
|
33
|
-
@listener.ignore_file?('/project/foo').should be
|
34
|
-
end
|
35
|
-
|
36
|
-
it "should ignore files with extensions that don't match those specified" do
|
37
|
-
@listener.ignore_file?('/project/foo.bar').should be
|
38
|
-
end
|
39
|
-
end
|
data/spec/runner_spec.rb
DELETED
@@ -1,265 +0,0 @@
|
|
1
|
-
require 'rspactor/runner'
|
2
|
-
|
3
|
-
describe RSpactor::Runner do
|
4
|
-
|
5
|
-
described_class.class_eval do
|
6
|
-
def run_command(cmd)
|
7
|
-
# never shell out in tests
|
8
|
-
cmd
|
9
|
-
end
|
10
|
-
end
|
11
|
-
|
12
|
-
def with_env(name, value)
|
13
|
-
old_value = ENV[name]
|
14
|
-
ENV[name] = value
|
15
|
-
begin
|
16
|
-
yield
|
17
|
-
ensure
|
18
|
-
ENV[name] = old_value
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
def capture_stderr(io = StringIO.new)
|
23
|
-
@old_stderr, $stderr = $stderr, io
|
24
|
-
begin; yield ensure; restore_stderr; end if block_given?
|
25
|
-
end
|
26
|
-
|
27
|
-
def restore_stderr
|
28
|
-
$stderr = @old_stderr
|
29
|
-
end
|
30
|
-
|
31
|
-
def capture_stdout(io = StringIO.new)
|
32
|
-
@old_stdout, $stdout = $stdout, io
|
33
|
-
begin; yield ensure; restore_stdout; end if block_given?
|
34
|
-
end
|
35
|
-
|
36
|
-
def restore_stdout
|
37
|
-
$stdout = @old_stdout
|
38
|
-
end
|
39
|
-
|
40
|
-
it 'should use the current directory to run in' do
|
41
|
-
mock_instance = mock('RunnerInstance')
|
42
|
-
mock_instance.stub!(:start)
|
43
|
-
RSpactor::Runner.should_receive(:new).with(Dir.pwd, {}).and_return(mock_instance)
|
44
|
-
RSpactor::Runner.start
|
45
|
-
end
|
46
|
-
|
47
|
-
it 'should take an optional directory to run in' do
|
48
|
-
mock_instance = mock('RunnerInstance')
|
49
|
-
mock_instance.stub!(:start)
|
50
|
-
RSpactor::Runner.should_receive(:new).with('/tmp/mu', {}).and_return(mock_instance)
|
51
|
-
RSpactor::Runner.start(:run_in => '/tmp/mu')
|
52
|
-
end
|
53
|
-
|
54
|
-
describe "start" do
|
55
|
-
before(:each) do
|
56
|
-
@runner = described_class.new('/my/path')
|
57
|
-
capture_stdout
|
58
|
-
end
|
59
|
-
|
60
|
-
after(:each) do
|
61
|
-
restore_stdout
|
62
|
-
end
|
63
|
-
|
64
|
-
def setup
|
65
|
-
@runner.start
|
66
|
-
end
|
67
|
-
|
68
|
-
context "Interactor" do
|
69
|
-
before(:each) do
|
70
|
-
@runner.stub!(:load_dotfile)
|
71
|
-
@runner.stub!(:start_listener)
|
72
|
-
@interactor = mock('Interactor')
|
73
|
-
@interactor.should_receive(:start_termination_handler)
|
74
|
-
RSpactor::Interactor.should_receive(:new).and_return(@interactor)
|
75
|
-
end
|
76
|
-
|
77
|
-
it "should start Interactor" do
|
78
|
-
@interactor.should_receive(:wait_for_enter_key).with(instance_of(String), 2, false)
|
79
|
-
setup
|
80
|
-
end
|
81
|
-
|
82
|
-
it "should run all specs if Interactor isn't interrupted" do
|
83
|
-
@interactor.should_receive(:wait_for_enter_key).and_return(nil)
|
84
|
-
@runner.should_receive(:run_spec_command).with('/my/path/spec')
|
85
|
-
setup
|
86
|
-
end
|
87
|
-
|
88
|
-
it "should skip running all specs if Interactor is interrupted" do
|
89
|
-
@interactor.should_receive(:wait_for_enter_key).and_return(true)
|
90
|
-
@runner.should_not_receive(:run_spec_command)
|
91
|
-
setup
|
92
|
-
end
|
93
|
-
|
94
|
-
it "should skip running all specs if --skip is used" do
|
95
|
-
@runner.options[:skip] = true
|
96
|
-
@runner.should_not_receive(:run_spec_command)
|
97
|
-
setup
|
98
|
-
end
|
99
|
-
end
|
100
|
-
|
101
|
-
it "should initialize Inspector" do
|
102
|
-
@runner.stub!(:load_dotfile)
|
103
|
-
@runner.stub!(:start_interactor)
|
104
|
-
RSpactor::Inspector.should_receive(:new)
|
105
|
-
RSpactor::Listener.stub!(:new).and_return(mock('Listener').as_null_object)
|
106
|
-
setup
|
107
|
-
end
|
108
|
-
|
109
|
-
context "Listener" do
|
110
|
-
before(:each) do
|
111
|
-
@runner.stub!(:load_dotfile)
|
112
|
-
@runner.stub!(:start_interactor)
|
113
|
-
@inspector = mock("Inspector")
|
114
|
-
RSpactor::Inspector.stub!(:new).and_return(@inspector)
|
115
|
-
@listener = mock('Listener')
|
116
|
-
end
|
117
|
-
|
118
|
-
it "should run Listener" do
|
119
|
-
@listener.should_receive(:run).with('/my/path')
|
120
|
-
RSpactor::Listener.should_receive(:new).with(instance_of(Array)).and_return(@listener)
|
121
|
-
setup
|
122
|
-
end
|
123
|
-
end
|
124
|
-
|
125
|
-
it "should output 'watching' message on start" do
|
126
|
-
@runner.stub!(:load_dotfile)
|
127
|
-
@runner.stub!(:start_interactor)
|
128
|
-
@runner.stub!(:start_listener)
|
129
|
-
setup
|
130
|
-
$stdout.string.chomp.should == "** RSpactor, now watching at '/my/path'"
|
131
|
-
end
|
132
|
-
|
133
|
-
context "dotfile" do
|
134
|
-
before(:each) do
|
135
|
-
@runner.stub!(:start_interactor)
|
136
|
-
@runner.stub!(:start_listener)
|
137
|
-
end
|
138
|
-
|
139
|
-
it "should load dotfile if found" do
|
140
|
-
with_env('HOME', '/home/moo') do
|
141
|
-
File.should_receive(:exists?).with('/home/moo/.rspactor').and_return(true)
|
142
|
-
Kernel.should_receive(:load).with('/home/moo/.rspactor')
|
143
|
-
setup
|
144
|
-
end
|
145
|
-
end
|
146
|
-
|
147
|
-
it "should continue even if the dotfile raised errors" do
|
148
|
-
with_env('HOME', '/home/moo') do
|
149
|
-
File.should_receive(:exists?).and_return(true)
|
150
|
-
Kernel.should_receive(:load).with('/home/moo/.rspactor').and_raise(ArgumentError)
|
151
|
-
capture_stderr do
|
152
|
-
lambda { setup }.should_not raise_error
|
153
|
-
$stderr.string.split("\n").should include('Error while loading /home/moo/.rspactor: ArgumentError')
|
154
|
-
end
|
155
|
-
end
|
156
|
-
end
|
157
|
-
end
|
158
|
-
end
|
159
|
-
|
160
|
-
describe "#run_spec_command" do
|
161
|
-
before(:each) do
|
162
|
-
@runner = described_class.new('/my/path')
|
163
|
-
end
|
164
|
-
|
165
|
-
def with_rubyopt(string, &block)
|
166
|
-
with_env('RUBYOPT', string, &block)
|
167
|
-
end
|
168
|
-
|
169
|
-
def run(paths)
|
170
|
-
@runner.run_spec_command(paths)
|
171
|
-
end
|
172
|
-
|
173
|
-
it "should exit if the paths argument is empty" do
|
174
|
-
@runner.should_not_receive(:run_command)
|
175
|
-
run([])
|
176
|
-
end
|
177
|
-
|
178
|
-
it "should specify runner spec runner with joined paths" do
|
179
|
-
run(%w(foo bar)).should include(' spec foo bar ')
|
180
|
-
end
|
181
|
-
|
182
|
-
it "should specify default options: --color" do
|
183
|
-
run('foo').should include(' --color')
|
184
|
-
end
|
185
|
-
|
186
|
-
it "should setup RUBYOPT environment variable" do
|
187
|
-
with_rubyopt(nil) do
|
188
|
-
run('foo').should include("RUBYOPT='-Ilib:spec' ")
|
189
|
-
end
|
190
|
-
end
|
191
|
-
|
192
|
-
it "should concat existing RUBYOPTs" do
|
193
|
-
with_rubyopt('-rubygems -w') do
|
194
|
-
run('foo').should include("RUBYOPT='-Ilib:spec -rubygems -w' ")
|
195
|
-
end
|
196
|
-
end
|
197
|
-
|
198
|
-
it "should include growl formatter" do
|
199
|
-
run('foo').should include(' --format RSpecGrowler:STDOUT')
|
200
|
-
end
|
201
|
-
|
202
|
-
it "should include 'progress' formatter" do
|
203
|
-
run('foo').should include(' -f progress')
|
204
|
-
end
|
205
|
-
|
206
|
-
it "should not include 'progress' formatter if there already are 2 or more formatters" do
|
207
|
-
@runner.should_receive(:spec_formatter_opts).and_return('-f foo --format bar')
|
208
|
-
run('foo').should_not include('--format progress')
|
209
|
-
end
|
210
|
-
|
211
|
-
it "should save status of last run" do
|
212
|
-
@runner.should_receive(:run_command).twice.and_return(true, false)
|
213
|
-
run('foo')
|
214
|
-
@runner.last_run_failed?.should be_false
|
215
|
-
run('bar')
|
216
|
-
@runner.last_run_failed?.should be_true
|
217
|
-
run([])
|
218
|
-
@runner.last_run_failed?.should be_false
|
219
|
-
end
|
220
|
-
end
|
221
|
-
|
222
|
-
describe "#changed_files" do
|
223
|
-
before(:each) do
|
224
|
-
@runner = described_class.new('.')
|
225
|
-
@runner.stub!(:inspector).and_return(mock("Inspector"))
|
226
|
-
end
|
227
|
-
|
228
|
-
def set_inspector_expectation(file, ret)
|
229
|
-
@runner.inspector.should_receive(:determine_files).with(file).and_return(ret)
|
230
|
-
end
|
231
|
-
|
232
|
-
it "should find and run spec files" do
|
233
|
-
set_inspector_expectation('moo.rb', ['spec/moo_spec.rb'])
|
234
|
-
set_inspector_expectation('views/baz.haml', [])
|
235
|
-
set_inspector_expectation('config/bar.yml', ['spec/bar_spec.rb', 'spec/bar_stuff_spec.rb'])
|
236
|
-
|
237
|
-
expected = %w(spec/moo_spec.rb spec/bar_spec.rb spec/bar_stuff_spec.rb)
|
238
|
-
@runner.should_receive(:run_spec_command).with(expected)
|
239
|
-
|
240
|
-
capture_stdout do
|
241
|
-
@runner.stub!(:dir)
|
242
|
-
@runner.send(:changed_files, %w(moo.rb views/baz.haml config/bar.yml))
|
243
|
-
$stdout.string.split("\n").should == expected
|
244
|
-
end
|
245
|
-
end
|
246
|
-
|
247
|
-
it "should run the full suite after a run succeded when the previous one failed" do
|
248
|
-
@runner.inspector.stub!(:determine_files).and_return(['spec/foo_spec.rb'], ['spec/bar_spec.rb'])
|
249
|
-
@runner.stub!(:options).and_return({ :retry_failed => true })
|
250
|
-
|
251
|
-
capture_stdout do
|
252
|
-
@runner.stub!(:run_spec_command)
|
253
|
-
@runner.should_receive(:last_run_failed?).and_return(true, false)
|
254
|
-
@runner.should_receive(:run_all_specs)
|
255
|
-
@runner.send(:changed_files, %w(moo.rb))
|
256
|
-
end
|
257
|
-
end
|
258
|
-
end
|
259
|
-
|
260
|
-
it "should have Runner in global namespace for backwards compatibility" do
|
261
|
-
defined?(::Runner).should be_true
|
262
|
-
::Runner.should == described_class
|
263
|
-
end
|
264
|
-
|
265
|
-
end
|