Skip to content

Commit

Permalink
pass RAILS root directory as an argument
Browse files Browse the repository at this point in the history
  • Loading branch information
Yves Le Douaron committed Feb 1, 2017
1 parent ca89df6 commit d959ca3
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
14 changes: 9 additions & 5 deletions bin/consistency_fail
Original file line number Diff line number Diff line change
@@ -1,17 +1,21 @@
#!/usr/bin/env ruby

base_dir = File.join(Dir.pwd, ARGV.first.to_s)
puts "\nWarning! You are going out of current directory, ruby version may be wrong and some gems may be missing.\n" unless File.realpath(base_dir).start_with?(Dir.pwd)

begin
require File.join(Dir.pwd, "config", "boot")
rescue LoadError => e

require File.join(base_dir, 'config', 'boot')
rescue LoadError
puts "\nUh-oh! You must be in the root directory of a Rails project.\n"
raise
end

require 'active_record'
require File.join(Dir.pwd, "config", "environment")
require File.join(base_dir, 'config', 'environment')

$:<< File.join(File.dirname(__FILE__), "..", "lib")
require "consistency_fail"
$:<< File.join(File.dirname(__FILE__), '..', 'lib')
require 'consistency_fail'

if ConsistencyFail.run
exit 0
Expand Down
4 changes: 2 additions & 2 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

Bundler.require(:default, :test)

Dir['./spec/support/**/*.rb'].each { |file| require file }
Dir['./spec/support/**/*.rb'].sort.each { |file| require file }

RSpec.configure do |config|
config.around do |example|
Expand All @@ -11,4 +11,4 @@
raise ActiveRecord::Rollback
end
end
end
end

0 comments on commit d959ca3

Please sign in to comment.