<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -153,6 +153,9 @@ module Merb
         Merb::Config.parse_args(argv)
       end
 
+      # Keep information that we run inside IRB to guard it against overriding in init.rb
+      @running_irb = Merb::Config[:adapter] == 'irb'
+
       Merb::Config[:log_stream] = STDOUT
       
       Merb.environment = Merb::Config[:environment]
@@ -785,6 +788,11 @@ module Merb
     def run_later(&amp;blk)
       Merb::Dispatcher.work_queue &lt;&lt; blk
     end
+
+    # :api: private
+    def running_irb?
+      @running_irb
+    end
   end
 end
 </diff>
      <filename>merb-core/lib/merb-core.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1323,6 +1323,8 @@ class Merb::BootLoader::ChooseAdapter &lt; Merb::BootLoader
   #
   # :api: plugin
   def self.run
+    # Check if we running in IRB if so run IRB adapter
+    Merb::Config[:adapter] = 'irb' if Merb.running_irb?
     Merb.adapter = Merb::Rack::Adapter.get(Merb::Config[:adapter])
   end
 end</diff>
      <filename>merb-core/lib/merb-core/bootloader.rb</filename>
    </modified>
    <modified>
      <diff>@@ -31,4 +31,11 @@ describe &quot;The BootLoader&quot; do
     Merb::BootLoader.subclasses.index(&quot;Merb::BootLoader::BeforeTest&quot;).should == idx - 1
   end
   
-end
\ No newline at end of file
+  describe Merb::BootLoader::ChooseAdapter do
+    it &quot;should check if we're running irb and if so set irb as adapter&quot; do
+      Merb.stub!(:running_irb?).and_return(true)
+      Merb::BootLoader::ChooseAdapter.run
+      Merb::Config[:adapter].should eql 'irb'
+    end
+  end
+end</diff>
      <filename>merb-core/spec/public/boot_loader/boot_loader_spec.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,46 +1,62 @@
 require File.expand_path(File.join(File.dirname(__FILE__), &quot;..&quot;, &quot;..&quot;, &quot;spec_helper&quot;))
-startup_merb
 
-describe &quot;Merb.env helpers&quot; do
-  before(:all) do
-    @orig_env = Merb.environment
-  end
-  after(:all) do
-    Merb.environment = @orig_env
-  end
-  
-  it &quot;should pickup the environment from env&quot; do
-    %w(development test production staging demo).each do |e|
-      Merb.environment = e
-      Merb.env.should == e
+describe &quot;Merb&quot; do
+
+  describe &quot;Merb.environment, Merb.env helpers&quot; do
+    before(:all) do
+      startup_merb
+      @orig_env = Merb.environment
     end
-  end
-  
-  it &quot;should correctly answer the question about which env it's in with symbol or string&quot; do
-    %w(development test production staging demo custom).each do |e|
-      Merb.environment = e
-      Merb.env?(e).should be true
-      Merb.env?(e.to_sym).should be_true
+    after(:all) do
+      Merb.environment = @orig_env
     end
-  end
-  
-  it &quot;should answer false if asked for an environment that is not current&quot; do
-    %w(development test production staging demo custom).each do |e|
-      Merb.environment = e
-      Merb.env?(:not_it).should be_false
+
+    it &quot;should pickup the environment from env&quot; do
+      %w(development test production staging demo).each do |e|
+        Merb.environment = e
+        Merb.env.should == e
+      end
+    end
+
+    it &quot;should correctly answer the question about which env it's in with symbol or string&quot; do
+      %w(development test production staging demo custom).each do |e|
+        Merb.environment = e
+        Merb.env?(e).should be true
+        Merb.env?(e.to_sym).should be_true
+      end
+    end
+
+    it &quot;should answer false if asked for an environment that is not current&quot; do
+      %w(development test production staging demo custom).each do |e|
+        Merb.environment = e
+        Merb.env?(:not_it).should be_false
+      end
+    end
+
+    it &quot;should allow an environment to merge another environments settings&quot; do
+      %w(development test production staging demo custom).each do |e|
+
+        Merb.environment = e
+        Merb.start_environment
+        Merb.merge_env &quot;some_other_env&quot;
+        Merb.environment_info.nil?.should be_false
+        Merb.environment_info[:merged_envs].first.should == &quot;some_other_env&quot;
+      end
     end
   end
-  
-  it &quot;should allow an environment to merge another environments settings&quot; do
-    %w(development test production staging demo custom).each do |e|
 
-      Merb.environment = e
-      Merb.start_environment
-      Merb.merge_env &quot;some_other_env&quot;
-      Merb.environment_info.nil?.should be_false
-      Merb.environment_info[:merged_envs].first.should == &quot;some_other_env&quot;
+  describe &quot;#runnig_irb?&quot; do
+    it &quot;should be false if running different adapter than irb&quot; do
+      startup_merb
+      Merb.running_irb?.should be_false
+    end
+
+    %w{-i --irb-console}.each do |option|
+      it &quot;should be true if merb is run with CLI option #{option}&quot; do
+        Merb::Server.stub!(:start)
+        Merb.start([option])
+        Merb.running_irb?.should be_true
+      end
     end
   end
-  
-  
-end
\ No newline at end of file
+end</diff>
      <filename>merb-core/spec/public/core/merb_core_spec.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>95aed998c937a59e017349d5b2eb9f4e3075605d</id>
    </parent>
  </parents>
  <author>
    <name>Pavel Kunc</name>
    <email>pavel.kunc@gmail.com</email>
  </author>
  <url>http://github.com/wycats/merb/commit/a6014acc93fc68d9687ad7151976129332bbab09</url>
  <id>a6014acc93fc68d9687ad7151976129332bbab09</id>
  <committed-date>2009-10-24T08:25:24-07:00</committed-date>
  <authored-date>2009-10-23T15:39:33-07:00</authored-date>
  <message>[merb-core] Make CLI -i, --irb-console to take precedence over config
in init.rb.

This change allows you to have default adapter set in the init.rb and
still if you want to run Merb in IRB you can do it. Currently you can't
because setting adapter in init.rb override the config value from ARGV
parsing.

[#1262 state:resolved]</message>
  <tree>0a212e2a1098d5014099044fedf7f5dba1defcb0</tree>
  <committer>
    <name>Pavel Kunc</name>
    <email>pavel.kunc@gmail.com</email>
  </committer>
</commit>
