<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array">
    <added>
      <filename>test/fixtures/selenium.yml</filename>
    </added>
  </added>
  <modified type="array">
    <modified>
      <diff>@@ -1,5 +1,5 @@
 require 'selenium_on_rails_config'
-envs = SeleniumOnRailsConfig.new.get :environments
+envs = SeleniumOnRailsConfig.get :environments
 
 if envs.include? RAILS_ENV
   #initialize the plugin</diff>
      <filename>init.rb</filename>
    </modified>
    <modified>
      <diff>@@ -5,7 +5,7 @@ class SeleniumController &lt; ActionController::Base
   include SeleniumOnRails::Renderer
   
   def initialize
-    @config = SeleniumOnRailsConfig.new
+    @result_dir = SeleniumOnRailsConfig.get(:result_dir)
   end
   
   def setup
@@ -65,9 +65,9 @@ class SeleniumController &lt; ActionController::Base
   end
 
   def record_table
-    return nil unless result_dir = @config.get(:result_dir)
+    return nil unless @result_dir
 
-    cur_result_dir = File.join(result_dir, (params[:logFile] || &quot;default&quot;).sub(/\.yml$/, ''))
+    cur_result_dir = File.join(@result_dir, (params[:logFile] || &quot;default&quot;).sub(/\.yml$/, ''))
     FileUtils.mkdir_p(cur_result_dir)
     File.open(&quot;#{cur_result_dir}/index.html&quot;, &quot;wb&quot;) do |f|
       f.write &lt;&lt;EOS</diff>
      <filename>lib/controllers/selenium_controller.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,16 +1,16 @@
-class SwitchEnvironmentController &lt; ActionController::Base
-  def index
-    readme_path = File.expand_path File.join(File.dirname(__FILE__), '..', 'README')
-    render :status =&gt; 500, :locals =&gt; {:readme_path =&gt; readme_path }, :inline =&gt; &lt;&lt;END
-&lt;p&gt;
-  Selenium on Rails is only activated for &lt;%= SeleniumOnRailsConfig.new.get(:environments).join ', ' %&gt;
-  environment&lt;%= SeleniumOnRailsConfig.get(:environments).size &gt; 1 ? 's' : '' %&gt; (you're running
-  &lt;%= RAILS_ENV %&gt;).
-&lt;/p&gt;
-&lt;p&gt;
-  Start your server in a different environment or see &lt;tt&gt;&lt;%= readme_path %&gt;&lt;/tt&gt; 
-  for information regarding how to change this behavior.
-&lt;/p&gt;
-END
-  end
+class SwitchEnvironmentController &lt; ActionController::Base
+  def index
+    readme_path = File.expand_path File.join(File.dirname(__FILE__), '..', 'README')
+    render :status =&gt; 500, :locals =&gt; {:readme_path =&gt; readme_path }, :inline =&gt; &lt;&lt;END
+&lt;p&gt;
+  Selenium on Rails is only activated for &lt;%= SeleniumOnRailsConfig.get(:environments).join ', ' %&gt;
+  environment&lt;%= SeleniumOnRailsConfig.get(:environments).size &gt; 1 ? 's' : '' %&gt; (you're running
+  &lt;%= RAILS_ENV %&gt;).
+&lt;/p&gt;
+&lt;p&gt;
+  Start your server in a different environment or see &lt;tt&gt;&lt;%= readme_path %&gt;&lt;/tt&gt; 
+  for information regarding how to change this behavior.
+&lt;/p&gt;
+END
+  end
 end
\ No newline at end of file</diff>
      <filename>lib/controllers/switch_environment_controller.rb</filename>
    </modified>
    <modified>
      <diff>@@ -5,8 +5,8 @@ require 'net/http'
 require 'tempfile'
 
 
-def c(var, default = nil) SeleniumOnRailsConfig.new.get var, default end
-def c_b(var, default = nil) SeleniumOnRailsConfig.new.get(var, default) { yield } end
+def c(var, default = nil) SeleniumOnRailsConfig.get var, default end
+def c_b(var, default = nil) SeleniumOnRailsConfig.get(var, default) { yield } end
 
 BROWSERS =              c :browsers, {}
 REUSE_EXISTING_SERVER = c :reuse_existing_server, true</diff>
      <filename>lib/selenium_on_rails/acceptance_test_runner.rb</filename>
    </modified>
    <modified>
      <diff>@@ -42,7 +42,7 @@ module SeleniumOnRails
     private ###############################################
 
     def find_selenium_path
-      sel_dirs = @config.get :selenium_path do
+      sel_dirs = SeleniumOnRailsConfig.get :selenium_path do
         File.expand_path(File.dirname(__FILE__) + '/../../selenium-core')
       end
 </diff>
      <filename>lib/selenium_on_rails/paths.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,26 +1,27 @@
-require 'yaml'
-
-class SeleniumOnRailsConfig
-  attr_accessor :configs
-  
-  def initialize
-    @defaults = {:environments =&gt; ['test']}
-    initialize_configs
-  end
-  
-  def get var, default = nil
-    value = @configs[var.to_s]
-    value ||= @defaults[var]
-    value ||= default
-    value ||= yield if block_given?
-    value
-  end
-  
-  def initialize_configs
-    @configs = {}
-    files = [File.expand_path(File.dirname(__FILE__) + '/../config.yml')]
-    files &lt;&lt; File.join(RAILS_ROOT, 'config', 'selenium.yml')
-    files.each { |file| @configs = YAML.load_file(file) if File.exist?(file) }
-  end
-
-end
\ No newline at end of file
+require 'yaml'
+
+class SeleniumOnRailsConfig
+  @@defaults = {:environments =&gt; ['test']}
+  def self.get var, default = nil
+    value = configs[var.to_s]
+    value ||= @@defaults[var]
+    value ||= default
+    value ||= yield if block_given?
+    value
+  end
+
+  private
+    def self.configs
+      @@configs ||= nil
+      unless @@configs
+        files = [File.expand_path(File.dirname(__FILE__) + '/../config.yml')]
+        files &lt;&lt; File.join(RAILS_ROOT, 'config', 'selenium.yml')
+        files.each do |file|
+          @@configs = YAML.load(ERB.new(IO.read(file)).result) if File.exist?(file)
+        end
+        @@configs ||= {}
+      end
+      @@configs
+    end
+
+end</diff>
      <filename>lib/selenium_on_rails_config.rb</filename>
    </modified>
    <modified>
      <diff>@@ -26,7 +26,7 @@ EOS
   end
   
   def test_record_with_result
-    @controller.config.configs[&quot;result_dir&quot;] = @result_dir
+    @controller.instance_variable_set(:@result_dir, @result_dir)
     
     post :record, :suite =&gt; @suite, &quot;testTable.1&quot; =&gt; &quot;&lt;table&gt;&lt;/table&gt;&quot;, &quot;testTable.2&quot; =&gt; &quot;&lt;table&gt;&lt;/table&gt;&quot;
     </diff>
      <filename>test/selenium_controller_test.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,21 +1,46 @@
 require File.dirname(__FILE__) + '/test_helper'
 require 'mocha'
 
+class SeleniumOnRailsConfig
+  def self.reset_config
+    @@configs = nil
+  end
+end
+
 class SeleniumOnRailsConfigTest &lt; Test::Unit::TestCase
   
-  def test_config_file_in_config_directory
-    File.stubs(:expand_path).returns(&quot;temporary&quot;)
-    File.expects(:exist?).with(&quot;temporary&quot;).returns(false)
-    File.expects(:exist?).with(File.join(RAILS_ROOT, 'config', 'selenium.yml')).returns(true)
-    YAML.expects(:load_file).with(File.join(RAILS_ROOT, 'config', 'selenium.yml')).returns({:fake =&gt; &quot;hash&quot;})
-    
-    assert_equal({:fake =&gt; &quot;hash&quot;}, SeleniumOnRailsConfig.new.configs)
+  def setup
+    SeleniumOnRailsConfig.reset_config
+    @selenium_file = File.join(RAILS_ROOT, 'config', 'selenium.yml')
+    @config_file = File.expand_path(File.dirname(__FILE__) + '/../config.yml')
+    @selenium_content = File.read(File.dirname(__FILE__) + '/fixtures/selenium.yml')
+    @config_content = File.read(File.dirname(__FILE__) + '/fixtures/config.yml')
+  end
+  
+  def test_get_when_config_yml_and_selenium_yaml_not_exists
+    File.expects(:exist?).with(@selenium_file).returns(false)
+    File.expects(:exist?).with(@config_file).returns(false)
+    IO.expects(:read).with(@config_file).never
+    IO.expects(:read).with(@selenium_file).never
+    assert_equal [&quot;test&quot;], SeleniumOnRailsConfig.get(:environments)
   end
   
-  def test_setting_config_manually
-    config = SeleniumOnRailsConfig.new
-    config.configs[&quot;test&quot;] = &quot;result&quot;
-    
-    assert_equal(&quot;result&quot;, config.configs[&quot;test&quot;])
+  def test_get_when_config_yml_not_exists_but_selenium_yaml_exists
+    File.expects(:exist?).with(@selenium_file).returns(true)
+    File.expects(:exist?).with(@config_file).returns(false)
+    IO.expects(:read).with(@config_file).never
+    IO.expects(:read).with(@selenium_file).returns(@selenium_content)
+    assert_equal [&quot;test_cache&quot;], SeleniumOnRailsConfig.get(:environments)
+    assert_equal({&quot;firefox&quot;=&gt;&quot;script/openfirefox&quot;}, SeleniumOnRailsConfig.get(:browsers))
   end
+
+  def test_get_when_config_yml_exists_but_selenium_yaml_not
+    File.expects(:exist?).with(@selenium_file).returns(false)
+    File.expects(:exist?).with(@config_file).returns(true)
+    IO.expects(:read).with(@config_file).returns(@config_content)
+    IO.expects(:read).with(@selenium_file).never
+    assert_equal [&quot;test&quot;], SeleniumOnRailsConfig.get(:environments)
+    assert_equal({&quot;firefox&quot;=&gt;&quot;script/openfirefox&quot;}, SeleniumOnRailsConfig.get(:browsers))
+  end
+  
 end
\ No newline at end of file</diff>
      <filename>test/selenium_on_rails_config_test.rb</filename>
    </modified>
    <modified>
      <diff>@@ -10,11 +10,8 @@ class SwitchEnvironmentControllerTest &lt; Test::Unit::TestCase
   end
   
   def test_index
-    SeleniumOnRailsConfig.expects(:new).returns(@config)
-    @config.expects(:get).with(:environments).returns(&quot;hello dolly&quot;)
-    
+    SeleniumOnRailsConfig.expects(:get).with(:environments).returns(&quot;hello dolly&quot;)
     get :index
-    
     assert @response.body.include?('hello dolly')
   end
 end
\ No newline at end of file</diff>
      <filename>test/switch_environment_controller_test.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>bdba02d90a3192aec13439a412dcdf3a594ef281</id>
    </parent>
  </parents>
  <author>
    <name>eric@8thlight.com</name>
    <email>eric@8thlight.com@9274398c-e119-0410-8437-aa71ef7847aa</email>
  </author>
  <url>http://github.com/paytonrules/selenium-on-rails/commit/c037be2bbef0beeae44e1003e138f41c07e50a2d</url>
  <id>c037be2bbef0beeae44e1003e138f41c07e50a2d</id>
  <committed-date>2009-03-07T15:37:00-08:00</committed-date>
  <authored-date>2009-03-07T15:37:00-08:00</authored-date>
  <message>Now you can use Ruby to configure you config.yml like in Rails fixtures.

Example:

host: &lt;%=`hostname`.gsub(/\n/, '')%&gt;
port_start: 4000
port_end: 4001
max_browser_duration: 1440


git-svn-id: https://svn.openqa.org/svn/selenium-on-rails/selenium-on-rails@122 9274398c-e119-0410-8437-aa71ef7847aa</message>
  <tree>c2f02165e4d2a5f9d8c0d663cfdd1e25ee2aac50</tree>
  <committer>
    <name>eric@8thlight.com</name>
    <email>eric@8thlight.com@9274398c-e119-0410-8437-aa71ef7847aa</email>
  </committer>
</commit>
