Skip to content

Commit

Permalink
speed up selenium by not doing setup/teardown after every set of specs
Browse files Browse the repository at this point in the history
Change-Id: I735c8a55f0c141b4843b187fd817eda21000d34b
Reviewed-on: https://gerrit.instructure.com/4733
Tested-by: Hudson <[email protected]>
Tested-by: Selenium <[email protected]>
Reviewed-by: Zach Wily <[email protected]>
  • Loading branch information
codekitchen authored and zwily committed Jul 20, 2011
1 parent b4116e5 commit 823cb75
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 13 deletions.
25 changes: 15 additions & 10 deletions spec/selenium/common.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@
$server_port = nil
$app_host_and_port = nil

at_exit do
$selenium_driver.try(:quit)
end

module SeleniumTestsHelperMethods
def setup_selenium
if SELENIUM_CONFIG[:host] && SELENIUM_CONFIG[:port] && !SELENIUM_CONFIG[:host_and_port]
Expand Down Expand Up @@ -166,9 +170,9 @@ def self.start_forked_webrick_server
include SeleniumTestsHelperMethods
include CustomSeleniumRspecMatchers

attr_reader :selenium_driver
def selenium_driver; $selenium_driver; end
alias_method :driver, :selenium_driver

def login_as(username = "[email protected]", password = "asdfasdf")
# log out (just in case)
driver.navigate.to(app_host + '/logout')
Expand Down Expand Up @@ -304,12 +308,7 @@ def make_full_screen
end

append_before(:all) do
@selenium_driver = setup_selenium
end

append_after(:all) do
@webserver_shutdown.call
@selenium_driver.quit
$selenium_driver ||= setup_selenium
end

append_before(:all) do
Expand All @@ -328,13 +327,19 @@ def make_full_screen
shared_examples_for "in-process server selenium tests" do
it_should_behave_like "all selenium tests"
prepend_before(:all) do
@webserver_shutdown = SeleniumTestsHelperMethods.start_in_process_webrick_server
$in_proc_webserver_shutdown ||= SeleniumTestsHelperMethods.start_in_process_webrick_server
end
end

shared_examples_for "forked server selenium tests" do
it_should_behave_like "all selenium tests"
prepend_before(:all) do
@webserver_shutdown = SeleniumTestsHelperMethods.start_forked_webrick_server
$in_proc_webserver_shutdown.try(:call)
$in_proc_webserver_shutdown = nil
@forked_webserver_shutdown = SeleniumTestsHelperMethods.start_forked_webrick_server
end

append_after(:all) do
@forked_webserver_shutdown.call
end
end
2 changes: 1 addition & 1 deletion spec/selenium/grading_standards_sel.rb
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@

@standard = @course.grading_standards.create!(:title => "some standard", :standard_data => {:a => {:name => 'A', :value => '95'}, :b => {:name => 'B', :value => '80'}, :f => {:name => 'F', :value => ''}})

get "/courses/#{@course.id}/details"
get "/courses/#{@course.id}/details#tab-details"
driver.find_element(:css, ".edit_course_link").click
form = driver.find_element(:css, "#course_form")
form.find_element(:css, "#course_grading_standard_enabled").click
Expand Down
2 changes: 0 additions & 2 deletions spec/spec.opts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
--colour
--format progress
--format html:tmp/spec_html/index.html
--loadby mtime
--reverse

0 comments on commit 823cb75

Please sign in to comment.