Parsing Variables from the RakeFile to spec_helper


#1

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?


#2

On Thu, Nov 6, 2008 at 4:52 AM, Togetherne Togetherne
removed_email_address@domain.invalid 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.


#3

David C. 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?


#4

On Thu, Nov 6, 2008 at 5:59 AM, Togetherne Togetherne
removed_email_address@domain.invalidwrote:

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