spec/testrbl_spec.rb in testrbl-0.5.1 vs spec/testrbl_spec.rb in testrbl-0.5.2
- old
+ new
@@ -1,14 +1,11 @@
require 'spec_helper'
+require 'tmpdir'
describe Testrbl do
around do |example|
- run "rm -rf tmp && mkdir tmp"
- Dir.chdir "tmp" do
- example.call
- end
- #run "rm -rf tmp"
+ Dir.mktmpdir { |dir| Dir.chdir(dir, &example) }
end
def run(cmd, options={})
result = `#{cmd} 2>&1`
raise "FAILED #{cmd} --> #{result}" if $?.success? != !options[:fail]
@@ -67,9 +64,35 @@
it "can use -I test for line execution" do
result = testrbl "-I test a_test.rb:6"
result.should include "ABC\n"
result.should include "XXX LOADED\n"
result.should_not include "BCD"
+ end
+ end
+
+ context "--seed" do
+ before do
+ 2.times do |i|
+ write "#{i}_test.rb", <<-RUBY
+ require 'minitest/autorun'
+
+ class Xxx#{i} < Minitest::Test
+ def test_xxx
+ puts 'ABC'
+ end
+ end
+ RUBY
+ end
+ end
+
+ it "seeds a single file" do
+ result = testrbl "0_test.rb:6 --seed 1234"
+ result.should include "1234"
+ end
+
+ it "seeds multiple files" do
+ result = Bundler.with_clean_env { testrbl "0_test.rb 1_test.rb --seed 1234" } # adding --seed triggers minitest to be loaded in a weird way and then the second version is loaded via bundler :/
+ result.should include "1234"
end
end
context "def test_" do
before do