Skip to content

Instantly share code, notes, and snippets.

@henrypoydar
Created July 11, 2014 20:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save henrypoydar/46dce767da0862365656 to your computer and use it in GitHub Desktop.
Save henrypoydar/46dce767da0862365656 to your computer and use it in GitHub Desktop.
RSpec.configure do |config|
config.before(:suite) do
DatabaseCleaner.clean_with(:truncation)
load "#{Rails.root}/db/seeds.rb"
end
config.before(:each) do
DatabaseCleaner.strategy = :transaction
end
config.before(:each, js: true) do |example|
screen_size = if example.metadata[:tablet]
{width: 768, height: 1024}
elsif example.metadata[:mobile]
{width: 540, height: 960}
else
# http://www.w3schools.com/browsers/browsers_resolution_higher.asp
{width: 1366, height: 768}
end
# For Poltergeist
page.driver.resize(screen_size[:width], screen_size[:height])
# For Selenium
# page.driver.browser.manage.window.resize_to(screen_size[:width], screen_size[:height])
DatabaseCleaner.strategy = :truncation
end
config.before(:each) do
DatabaseCleaner.start
end
config.after(:each) do |example|
DatabaseCleaner.clean
if example.metadata[:js]
page.execute_script("window.localStorage.clear()")
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment