Merge pull request #1473 from AndrewKvalheim/overridable-console

Move IRB initialization into a dedicated method.
This commit is contained in:
Thomas Reynolds 2015-02-25 23:08:03 -08:00
commit d60cd3a044
2 changed files with 20 additions and 1 deletions

View file

@ -0,0 +1,10 @@
Feature: Console
Scenario: Enter and exit the console
Given I run `middleman console` interactively
When I type "puts 'Hello from the console.'"
And I type "exit"
Then it should pass with:
"""
Hello from the console.
"""

View file

@ -34,10 +34,19 @@ module Middleman::Cli
# TODO: get file watcher / reload! working in console # TODO: get file watcher / reload! working in console
interact_with @app
end
private
# Start an interactive console in the context of the provided object.
# @param [Object] context
# @return [void]
def interact_with(context)
IRB.setup nil IRB.setup nil
IRB.conf[:MAIN_CONTEXT] = IRB::Irb.new.context IRB.conf[:MAIN_CONTEXT] = IRB::Irb.new.context
require 'irb/ext/multi-irb' require 'irb/ext/multi-irb'
IRB.irb nil, @app IRB.irb nil, context
end end
end end
end end