forked from grosser/parallel_tests
-
Notifications
You must be signed in to change notification settings - Fork 0
/
rails_spec.rb
39 lines (35 loc) · 1.25 KB
/
rails_spec.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
require 'spec_helper'
describe 'rails' do
def sh(command, options={})
result = ''
IO.popen(options.fetch(:environment, {}), command, err: [:child, :out]) do |io|
result = io.read
end
raise "FAILED #{command}\n#{result}" if $?.success? == !!options[:fail]
result
end
%w(rails51 rails52).each do |rails|
it "can create and run #{rails}" do
if RUBY_PLATFORM == "java"
skip 'rails fixtures are not set up for java'
end
Dir.chdir("spec/fixtures/#{rails}") do
Bundler.with_clean_env do
# unset travis things
ENV.delete("RAILS_ENV")
ENV.delete("RACK_ENV")
sh "bundle config --local path vendor/bundle"
sh "bundle install"
sh "rm -rf db/*.sqlite3"
sh "bundle exec rake db:setup parallel:create --trace 2>&1"
# Also test the case where the DBs need to be dropped
sh "bundle exec rake parallel:drop parallel:create"
sh "bundle exec rake parallel:prepare"
sh "bundle exec rails runner User.create", environment: {'RAILS_ENV' => 'test'} # pollute the db
out = sh "bundle exec rake parallel:prepare parallel:test"
expect(out).to match(/ 2 (tests|runs)/)
end
end
end
end
end