<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array">
    <added>
      <filename>test/fixtures/config.yml</filename>
    </added>
    <added>
      <filename>test/fixtures/selenium.yml</filename>
    </added>
    <added>
      <filename>test/paths_test.rb</filename>
    </added>
    <added>
      <filename>test/test_builder_functions_authortest.rb</filename>
    </added>
  </added>
  <modified type="array">
    <modified>
      <diff>@@ -324,8 +324,9 @@ the Selenese format.
 * Jon Tirsen, http://jutopia.tirsen.com -- initial inspiration[http://wiki.rubyonrails.com/rails/pages/SeleniumIntegration]
 * Eric Kidd, http://www.randomhacks.net -- contribution of RSelenese
 * Jonas Bengston -- original creator
-* Marcos Tapajos -- Several useful features
+* Marcos Tapaj&#243;s http://www.improveit.com.br/en/company/tapajos -- Several useful features
 * Ryan Bates, http://railscasts.com -- Fixes for Rails 2.1
+* Nando Vieira, http://simplesideias.com.br
 
 == Information
 </diff>
      <filename>README</filename>
    </modified>
    <modified>
      <diff>@@ -12,6 +12,16 @@ Rake::TestTask.new(:test) do |t|
   t.verbose = true
 end
 
+desc 'Test the Selenium on Rails plugin, and run the _authortest.rb files, too'
+Rake::TestTask.new(:alltests) do |t|
+  t.libs &lt;&lt; 'lib'
+  # note: Both pattern and test_files are used, so the list of test files is
+  # the union of the two. 
+  t.pattern = 'test/**/*_test.rb'
+  t.test_files = FileList['test/**/*_authortest.rb']
+  t.verbose = true
+end
+
 desc 'Generate documentation for the Selenium on Rails plugin.'
 task :rdoc do
   rm_rf 'doc'
@@ -22,6 +32,7 @@ begin
   require 'rcov/rcovtask'
   Rcov::RcovTask.new do |t|
     t.test_files = FileList['test/*_test.rb']
+    t.rcov_opts = ['-x /site_ruby/ -x .*gems.* --rails']
   end
 rescue LoadError #if rcov isn't available, ignore
 end</diff>
      <filename>Rakefile</filename>
    </modified>
    <modified>
      <diff>@@ -1,3 +1,4 @@
+# Please read as our directions have changed:
 # Move this file to your rails apps config directory and rename it to selenium.yml in order to configure the plugin
 
 #
@@ -31,3 +32,6 @@ browsers:
 #multi_window: false
   
 #result_dir: 'c:\result' # the directory where the results will be stored after a test:acceptance run
+
+#fixtures_path: &lt;%= &quot;#{RAILS_ROOT}/spec/fixtures&quot; %&gt;
+#selenium_tests_path: &lt;%= &quot;#{RAILS_ROOT}/spec/selenium&quot; %&gt;
\ No newline at end of file</diff>
      <filename>config.yml.example</filename>
    </modified>
    <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,12 +5,12 @@ class SeleniumController &lt; ActionController::Base
   include SeleniumOnRails::Renderer
   
   def initialize
-    @config = SeleniumOnRailsConfig.new
+    @result_dir = SeleniumOnRailsConfig.get(:result_dir)
   end
   
   def setup
     unless params.has_key? :keep_session
-      reset_session
+      reset_session #  IS THIS WORKING!  NO THINK SO
       @session_wiped = true
     end
     @cleared_tables = clear_tables params[:clear_tables].to_s
@@ -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>@@ -2,7 +2,6 @@ require 'selenium_on_rails_config'
 
 module SeleniumOnRails
   module Paths
-    attr_accessor :config
     
     def selenium_path
       @@selenium_path ||= find_selenium_path
@@ -10,6 +9,7 @@ module SeleniumOnRails
     end
     
     def selenium_tests_path
+      return SeleniumOnRailsConfig.get(&quot;selenium_tests_path&quot;) if SeleniumOnRailsConfig.get(&quot;selenium_tests_path&quot;)
       File.expand_path(File.join(RAILS_ROOT, 'test/selenium'))
     end
     
@@ -25,6 +25,7 @@ module SeleniumOnRails
     end
     
     def fixtures_path
+      return SeleniumOnRailsConfig.get(&quot;fixtures_path&quot;) if SeleniumOnRailsConfig.get(&quot;fixtures_path&quot;)
       File.expand_path File.join(RAILS_ROOT, 'test/fixtures')
     end
     
@@ -42,7 +43,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,28 @@
-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'
+require 'erb'
+
+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>@@ -2,7 +2,9 @@ require File.dirname(__FILE__) + '/test_helper'
 
 class RendererTest &lt; Test::Unit::TestCase
   def setup
+    SeleniumOnRails::PartialsSupport.send(:include, SeleniumOnRails::PathsTestHelper)
     @controller = SeleniumController.new
+    @controller.extend(SeleniumOnRails::PathsTestHelper)
     ActionController::Routing::Routes.draw
     @request    = ActionController::TestRequest.new
     @response   = ActionController::TestResponse.new
@@ -20,8 +22,6 @@ END
   end
   
   def test_html
-    get :test_file, :testname =&gt; 'html.html'
-    assert_headers
     expected =&lt;&lt;END
 &lt;html&gt;&lt;head&gt;&lt;title&gt;test layout&lt;/title&gt;&lt;/head&gt;&lt;body&gt;
 &lt;p&gt;Testing plain HTML&lt;/p&gt;
@@ -32,8 +32,16 @@ END
 &lt;p&gt;and it works...&lt;/p&gt;
 &lt;/body&gt;&lt;/html&gt;
 END
+    File.open(test_path_for('html.html'), 'w+') { |index_file| index_file &lt;&lt; expected }
+    get :test_file, :testname =&gt; 'html.html'
+    assert_headers
+    
     assert_text_equal expected, @response.body
   end
+  
+  def test_path_for(name)
+    &quot;#{File.expand_path(File.dirname(__FILE__) + &quot;/../test_data&quot;)}/#{name}&quot;
+  end
     
   def test_rhtml
     get :test_file, :testname =&gt; 'rhtml.rhtml'</diff>
      <filename>test/renderer_test.rb</filename>
    </modified>
    <modified>
      <diff>@@ -9,8 +9,8 @@ class RSeleneseTest &lt; Test::Unit::TestCase
     create_rsel_file_from(input, &quot;html.rsel&quot;)
     
     @view = TestView.new
+    @view.extend(SeleniumOnRails::PathsTestHelper)
     @sel = SeleniumOnRails::RSelenese.new(@view) 
-    
     @sel.render ActionView::Template.new(test_path_for(&quot;html.rsel&quot;)), {'page_title' =&gt; page_title}
   end
   </diff>
      <filename>test/rselenese_test.rb</filename>
    </modified>
    <modified>
      <diff>@@ -4,6 +4,7 @@ class SeleneseTest &lt; Test::Unit::TestCase
   
   def setup
     @view = TestView.new
+    @view.extend(SeleniumOnRails::PathsTestHelper)
     @sel = SeleniumOnRails::Selenese.new(@view) 
   end
   </diff>
      <filename>test/selenese_test.rb</filename>
    </modified>
    <modified>
      <diff>@@ -5,6 +5,7 @@ class SeleniumControllerTest &lt; Test::Unit::TestCase
 
   def setup
     @controller = SeleniumController.new
+    @controller.extend(SeleniumOnRails::PathsTestHelper)
     ActionController::Routing::Routes.draw
     SeleniumController.any_instance.stubs(:layout_path).returns(false)
     @request    = ActionController::TestRequest.new
@@ -26,7 +27,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,47 @@
 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;safari&quot;=&gt;&quot;/Applications/Safari.app/Contents/MacOS/Safari&quot;,
+     &quot;firefox&quot;=&gt;&quot;/Applications/Firefox.app/Contents/MacOS/firefox-bin&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>@@ -3,6 +3,7 @@ require File.dirname(__FILE__) + '/test_helper'
 class SeleniumSupportTest &lt; Test::Unit::TestCase  
   def setup
     @controller = SeleniumController.new
+    @controller.extend(SeleniumOnRails::PathsTestHelper)
     ActionController::Routing::Routes.draw
     @request    = ActionController::TestRequest.new
     @response   = ActionController::TestResponse.new</diff>
      <filename>test/selenium_support_test.rb</filename>
    </modified>
    <modified>
      <diff>@@ -5,6 +5,7 @@ RAILS_ROOT = File.expand_path(File.dirname(__FILE__) + &quot;/&quot;)
 class SetupTest &lt; Test::Unit::TestCase
   def setup
     @controller = SeleniumController.new
+    @controller.extend(SeleniumOnRails::PathsTestHelper)
     SeleniumController.any_instance.stubs(:clear_tables).returns([])
     SeleniumController.any_instance.stubs(:layout_path).returns(false)
     ActionController::Routing::Routes.draw</diff>
      <filename>test/setup_test.rb</filename>
    </modified>
    <modified>
      <diff>@@ -3,6 +3,7 @@ require File.dirname(__FILE__) + '/test_helper'
 class SuiteRendererTest &lt; Test::Unit::TestCase
   def setup
     @controller = SeleniumController.new
+    @controller.extend(SeleniumOnRails::PathsTestHelper)
     ActionController::Routing::Routes.draw
     @request    = ActionController::TestRequest.new
     @response   = ActionController::TestResponse.new</diff>
      <filename>test/suite_renderer_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>
      <diff>@@ -31,11 +31,6 @@ def setup_controller_test(controller)
   @response   = ActionController::TestResponse.new
 end
 
-module SeleniumOnRails::Paths
-  def selenium_tests_path
-    File.expand_path(File.dirname(__FILE__) + '/../test_data')
-  end
-end
 
 class SeleniumController
   attr_accessor :layout_override
@@ -76,6 +71,12 @@ class Test::Unit::TestCase
   
 end
 
+module SeleniumOnRails::PathsTestHelper
+  def selenium_tests_path
+    File.expand_path(File.dirname(__FILE__) + '/../test_data')
+  end
+end
+
 class TestView &lt; ActionView::Base
   include SeleniumOnRails::PartialsSupport
   </diff>
      <filename>test/test_helper.rb</filename>
    </modified>
  </modified>
  <removed type="array">
    <removed>
      <filename>lib/selenium_on_rails/test_builder_functions_check.rb</filename>
    </removed>
    <removed>
      <filename>test_data/html.html</filename>
    </removed>
  </removed>
  <parents type="array">
    <parent>
      <id>d5ae7496b3f46673546b2ef8dc675a339750f59e</id>
    </parent>
    <parent>
      <id>25e0918d65600c8c5fb76674368dbac4520434c4</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/dbb235f76e584eb017c459c2b449a219fad39955</url>
  <id>dbb235f76e584eb017c459c2b449a219fad39955</id>
  <committed-date>2009-03-07T15:37:16-08:00</committed-date>
  <authored-date>2009-03-07T15:37:16-08:00</authored-date>
  <message>Merge branch 'master' of git@github.com:paytonrules/selenium-on-rails

Conflicts:

	.gitignore
	test/selenium_on_rails_config_test.rb

Huge number of changes, but mostly relating to testing.


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