File: railtie_spec.rb

package info (click to toggle)
ruby-pry-rails 0.3.9-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye
  • size: 320 kB
  • sloc: ruby: 844; makefile: 4
file content (41 lines) | stat: -rw-r--r-- 906 bytes parent folder | download
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
40
41
# encoding: UTF-8

require 'spec_helper'

if (Rails::VERSION::MAJOR == 5 && Rails::VERSION::MINOR >= 1) ||
    Rails::VERSION::MAJOR >= 6
  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
    # Yes, I know this is horrible.
    begin
      $called_start = false
      real_pry = Pry

      silence_warnings do
        ::Pry = Class.new do
          def self.start(*)
            $called_start = true
          end
        end
      end

      Rails::Console.start(Rails.application)

      assert $called_start
    ensure
      silence_warnings do
        ::Pry = real_pry
      end
    end

    %w(app helper reload!).each do |helper|
      TOPLEVEL_BINDING.eval("respond_to?(:#{helper}, true)").must_equal true
    end
  end
end