keep browser windows open between runs, good for guard

This commit is contained in:
John Bintz 2012-03-15 14:20:07 -04:00
parent 8b36430ba9
commit cc753a10fd
4 changed files with 13 additions and 4 deletions

View File

@ -8,7 +8,9 @@ class Flowerbox::CLI < Thor
method_options :pwd => :string, :env_options => nil, :runners => :string, :runner => :string, :verbose_server => false
def test(dir = "spec/javascripts", *files)
Dir.chdir(pwd) do
exit Flowerbox.run(dir, options.dup.merge(:files => files))
result = Flowerbox.run(dir, options.dup.merge(:files => files))
Flowerbox.cleanup!
exit result
end
end

View File

@ -110,6 +110,15 @@ module Flowerbox
def run(dir, options = {})
Flowerbox::Run::Test.execute(dir, options)
end
def browsers
@browsers ||= {}
end
def cleanup!
browsers.values.each(&:close)
@browsers = {}
end
end
end

View File

@ -13,8 +13,7 @@ class Flowerbox::Runner::Chrome < Flowerbox::Runner::Selenium
end
def browser
@browser ||= ::Selenium::WebDriver.for(:chrome)
Flowerbox.browsers[:chrome] ||= ::Selenium::WebDriver.for(:chrome)
end
end

View File

@ -12,7 +12,6 @@ module Flowerbox
end
def cleanup
@browser.close if @browser
end
def browser