File tree Expand file tree Collapse file tree 2 files changed +11
-2
lines changed Expand file tree Collapse file tree 2 files changed +11
-2
lines changed Original file line number Diff line number Diff line change @@ -43,7 +43,7 @@ def from(storage)
4343 def initialize ( bindings )
4444 @id = SecureRandom . hex ( 16 )
4545 @bindings = Array ( bindings )
46- @evaluator = Evaluator . new ( initial_binding )
46+ @evaluator = Evaluator . new ( application_binding || @bindings . first )
4747
4848 store_into_memory
4949 end
@@ -64,7 +64,7 @@ def switch_binding_to(index)
6464
6565 private
6666
67- def initial_binding
67+ def application_binding
6868 @bindings . find { |b | b . eval ( '__FILE__' ) . to_s . start_with? ( Rails . root . to_s ) }
6969 end
7070
Original file line number Diff line number Diff line change @@ -39,6 +39,15 @@ def initialize(line)
3939 assert_equal session . eval ( '__FILE__' ) , "=> \" #{ __FILE__ } \" \n "
4040 end
4141
42+ test 'use first binding if no application bindings' do
43+ binding = Object . new
44+ binding . expects ( :eval ) . with ( '__FILE__' ) . returns 'framework'
45+ binding . expects ( :eval ) . with ( 'called?' ) . returns 'yes'
46+
47+ session = Session . new ( binding )
48+ assert_equal session . eval ( 'called?' ) , "=> \" yes\" \n "
49+ end
50+
4251 test '#from can create session from a single binding' do
4352 saved_line , saved_binding = __LINE__ , binding
4453 Thread . current [ :__web_console_binding ] = saved_binding
You can’t perform that action at this time.
0 commit comments