1
0
Fork 0
mirror of https://github.com/pry/pry-rails.git synced 2022-11-09 12:36:03 -05:00

Fix compatibility of specs with Mongoid and Rails 5.1

- Mongoid needs to be loaded before Rails initializes

 - Rails 5.1 changed the necessary requires to invoke `console`
This commit is contained in:
Ryan Fitzgerald 2017-05-05 23:36:41 -07:00
parent 2533b68c67
commit be97a215a4
3 changed files with 20 additions and 6 deletions

View file

@ -23,7 +23,13 @@ end
desc 'Start the Rails console'
task :console => :development_env do
require 'rails/commands/console'
if (Rails::VERSION::MAJOR == 5 && Rails::VERSION::MINOR >= 1)
require 'rails/command'
require 'rails/commands/console/console_command'
else
require 'rails/commands/console'
end
Rails::Console.start(Rails.application)
end

View file

@ -4,6 +4,11 @@ require 'active_support/core_ext'
require 'pry-rails'
begin
require 'mongoid'
rescue LoadError # Mongoid doesn't support Rails 3.0
end
# Initialize our test app
class TestApp < Rails::Application
@ -58,9 +63,7 @@ class Pokemon < ActiveRecord::Base
has_many :beers, :through => :hacker
end
begin
require 'mongoid'
if defined?(Mongoid)
class Artist
include Mongoid::Document
@ -75,5 +78,4 @@ begin
field :name, :type => String
embedded_in :artist
end
rescue LoadError # Mongoid doesn't support Rails 3.0
end

View file

@ -1,7 +1,13 @@
# encoding: UTF-8
require 'spec_helper'
require 'rails/commands/console'
if (Rails::VERSION::MAJOR == 5 && Rails::VERSION::MINOR >= 1)
require 'rails/command'
require 'rails/commands/console/console_command'
else
require 'rails/commands/console'
end
describe PryRails::Railtie do
it 'should start Pry instead of IRB and make the helpers available' do