Module: RSpecConsole::Pry

Defined in:
lib/rspec-console/pry.rb

Class Method Summary collapse

Class Method Details

.rspec_command(cmd) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/rspec-console/pry.rb', line 8

def self.rspec_command(cmd)
  cmd.create_command "rspec", "Runs specs; to silence ActiveRecord output use SILENCE_AR=true" do
    group "Testing"

    def process(*args)
      with_ar_silenced { RSpecConsole::Runner.run(args) }
    end

    def with_ar_silenced(&block)
      return block.call unless defined?(ActiveRecord) && ENV['SILENCE_AR']
      begin
        old_logger, ActiveRecord::Base.logger = ActiveRecord::Base.logger, nil
        block.call
      ensure
        ActiveRecord::Base.logger = old_logger
      end
    end

    def complete(input)
      require 'bond'
      super + Bond::Rc.files(input.split(" ").last || '')
    end
  end
end

.setupObject



3
4
5
6
# File 'lib/rspec-console/pry.rb', line 3

def self.setup
  ::Pry::CommandSet.new(&method(:rspec_command))
  .tap { |cmd| ::Pry::Commands.import cmd }
end