Forum: RSpec Parsing Variables from the RakeFile to spec_helper

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
D99563233e91c9191187cecd5cce4eec?d=identicon&s=25 Togetherne Togetherne (linux_cat)
on 2008-11-06 10:52
Is this possible, i basically want to create a loop in my Rakefile which
updates a variable in my spec file with every run the variable is
something like:

  browser =  ENV['SELENIUM_RC_BROWSER'] || "*chrome"

in my spec_helper i have:


  def create_selenium_driver
    remote_control_server = ENV['SELENIUM_RC_HOST'] || "localhost"
    port = ENV['SELENIUM_RC_PORT'] || 4444
    browser = ENV['SELENIUM_RC_BROWSER']
    #browser = ENV['SELENIUM_RC_BROWSER'] || "*chrome"
    timeout = ENV['SELENIUM_RC_TIMEOUT'] || 200
    application_host = ENV['SELENIUM_APPLICATION_HOST'] || ""
    #application_port = ENV['SELENIUM_APPLICATION_PORT'] || ""

        @selenium_driver = Selenium::Client::Driver.new(
        remote_control_server, port, browser,
        "http://#{application_host}", timeout)

  end

I basically want to change the browser variable in my RakeFile and parse
it to my spechelper so i can change it with every run.....any ideas?
5d38ab152e1e3e219512a9859fcd93af?d=identicon&s=25 David Chelimsky (Guest)
on 2008-11-06 14:46
(Received via mailing list)
On Thu, Nov 6, 2008 at 4:52 AM, Togetherne Togetherne
<lists@ruby-forum.com> wrote:
>    remote_control_server = ENV['SELENIUM_RC_HOST'] || "localhost"
>
>  end
>
> I basically want to change the browser variable in my RakeFile and parse
> it to my spechelper so i can change it with every run.....any ideas?

Are you saying you want to type the same command and have it behave
differently each time? I think you'd have to save something to a file
each run and read it in each subsequent run.

Why not create different tasks? There's a few ways you can handle that
and keep control from the command line.
D99563233e91c9191187cecd5cce4eec?d=identicon&s=25 Togetherne Togetherne (linux_cat)
on 2008-11-06 14:59
David Chelimsky wrote:
> Why not create different tasks? There's a few ways you can handle that
> and keep control from the command line.

Thanks for the reply, i have managed i think to get half way there!!:

@environment = ["*iehta", "*chrome"]

@environment.each {|browse|
desc("Run all tests in parallel using DeepTest.")
Spec::Rake::SpecTask.new("tests:run_in_parallel") do |t|
  ENV['SELENIUM_RC_BROWSER'] = browse
  puts "running test on #{browse}"
  t.spec_files = FileList['google*.rb']
  t.deep_test :number_of_workers => 2
           #   :timeout_in_seconds => 300
  t.spec_opts << '--color'
  t.spec_opts << "--require
'rubygems,selenium/rspec/reporting/selenium_test_report_formatter'"
  t.spec_opts <<
"--format=Selenium::RSpec::SeleniumTestReportFormatter:./tmp/test_report.html"
  t.spec_opts << "--format=progress"
end
}
task :'tests:run_in_parallel' => :create_report


however everytime i run tests:run_in_parallel it runs the tests for
*chrome twice!!?....

If i create a seperate rake task for each how would i chain them togethr
to run 1 after eachother?
48641c4be1fbe167929fb16c9fd94990?d=identicon&s=25 Mark Wilden (Guest)
on 2008-11-06 16:49
(Received via mailing list)
On Thu, Nov 6, 2008 at 5:59 AM, Togetherne Togetherne
<lists@ruby-forum.com>wrote:


> If i create a seperate rake task for each how would i chain them togethr
> to run 1 after eachother?
>

Make a dependency chain. task3 depends on task2 which depends on task1.

///ark
This topic is locked and can not be replied to.