Skip to content
Browse files

Add ability to configure paths to be added with -I

  • Loading branch information...
1 parent 943b91a commit a0e2afdb0852ca4457b58dfdca48838e9bcb7e94 @amiel amiel committed
Showing with 23 additions and 3 deletions.
  1. +3 −2 lib/guard/test/runner.rb
  2. +20 −1 spec/guard/test/runner_spec.rb
View
5 lib/guard/test/runner.rb
@@ -9,8 +9,9 @@ def initialize(options = {})
:bundler => File.exist?("#{Dir.pwd}/Gemfile"),
:rubygems => false,
:rvm => [],
+ :include => ['test'],
:drb => false,
- :cli => ""
+ :cli => "",
}.merge(options)
end
@@ -57,7 +58,7 @@ def test_unit_command(paths)
else
"ruby"
end
- cmd_parts << "-Itest"
+ cmd_parts << Array(@options[:include]).map { |path| "-I#{path}" }
cmd_parts << "-r bundler/setup" if bundler?
cmd_parts << "-rubygems" if rubygems?
View
21 spec/guard/test/runner_spec.rb
@@ -152,7 +152,7 @@
subject.run(["test/succeeding_test.rb"])
end
end
-
+
context "when the :rubygems option set to true (and :bundler to false) on initialize" do
subject do
runner = described_class.new(:bundler => false, :rubygems => true)
@@ -217,6 +217,25 @@
end
end
+ context "when the :include option is given" do
+ subject do
+ runner = described_class.new(:include => ['test', 'lib'])
+ runner
+ end
+
+ it "adds the appropriate -I options" do
+ subject.should_receive(:system).with(
+ "bundle exec " \
+ "ruby -Itest -Ilib -r bundler/setup " \
+ "-r #{@lib_path.join('guard/test/guard_test_runner')} " \
+ "-e \"%w[test/succeeding_test.rb].each { |p| load p }\" " \
+ "\"./test/succeeding_test.rb\" --use-color --runner=guard"
+ )
+
+ subject.run(["test/succeeding_test.rb"])
+ end
+ end
+
context "when the :cli option is given" do
subject do
runner = described_class.new(:cli => '--pretty')

0 comments on commit a0e2afd

Please sign in to comment.
Something went wrong with that request. Please try again.