summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorAzul <azul@leap.se>2014-02-08 11:13:10 +0100
committerAzul <azul@leap.se>2014-02-10 14:26:30 +0100
commit67f17e65b9e9e8ad2991b9c4002dba5203baa77f (patch)
tree136f644eac462e583ca4bf1c957414f12d7c5035 /test
parent88f8128d568daaaa122d55ac7e546a81ae60964a (diff)
refactor tests to ease the testing of token only auth
Diffstat (limited to 'test')
-rw-r--r--test/test_helper.rb73
1 files changed, 5 insertions, 68 deletions
diff --git a/test/test_helper.rb b/test/test_helper.rb
index 3fb2716..f63591f 100644
--- a/test/test_helper.rb
+++ b/test/test_helper.rb
@@ -10,74 +10,6 @@ Dir["#{File.dirname(__FILE__)}/../*/test/support/**/*.rb"].each { |f| require f
class ActiveSupport::TestCase
# Add more helper methods to be used by all tests here...
- def file_path(name)
- File.join(Rails.root, 'test', 'files', name)
- end
-
-end
-
-require 'capybara/poltergeist'
-
-CONFIG_RU = (Rails.root + 'config.ru').to_s
-OUTER_APP = Rack::Builder.parse_file(CONFIG_RU).first
-
-Capybara.register_driver :rack_test do |app|
- Capybara::RackTest::Driver.new(app)
-end
-
-Capybara.register_driver :poltergeist do |app|
- Capybara::Poltergeist::Driver.new(app)
-end
-
-# this is integration testing. So let's make the whole
-# rack stack available...
-Capybara.app = OUTER_APP
-Capybara.run_server = true
-Capybara.app_host = 'http://lvh.me:3003'
-Capybara.server_port = 3003
-Capybara.javascript_driver = :poltergeist
-Capybara.default_wait_time = 5
-
-class BrowserIntegrationTest < ActionDispatch::IntegrationTest
- # Make the Capybara DSL available
- include Capybara::DSL
- include IntegrationTestHelper
-
- setup do
- Capybara.current_driver = Capybara.javascript_driver
- page.driver.add_headers 'ACCEPT-LANGUAGE' => 'en-EN'
- end
-
- teardown do
- Capybara.reset_sessions! # Forget the (simulated) browser state
- Capybara.use_default_driver # Revert Capybara.current_driver to Capybara.default_driver
- end
-
- add_teardown_hook do |testcase|
- unless testcase.passed?
- testcase.save_state
- end
- end
-
- def save_state
- page.save_screenshot screenshot_path
- File.open(logfile_path, 'w') do |test_log|
- test_log.puts self.class.name
- test_log.puts "========================="
- test_log.puts __name__
- test_log.puts Time.now
- test_log.puts current_path
- test_log.puts page.status_code
- test_log.puts page.response_headers
- test_log.puts "page.html"
- test_log.puts "------------------------"
- test_log.puts page.html
- test_log.puts "server log"
- test_log.puts "------------------------"
- test_log.puts `tail log/test.log -n 200`
- end
- end
-
protected
def logfile_path
@@ -87,4 +19,9 @@ class BrowserIntegrationTest < ActionDispatch::IntegrationTest
def screenshot_path
Rails.root + 'tmp' + "#{self.class.name.underscore}.#{__name__}.png"
end
+
+ def file_path(name)
+ File.join(Rails.root, 'test', 'files', name)
+ end
+
end