aboutsummaryrefslogtreecommitdiffstats
path: root/spec/support
diff options
context:
space:
mode:
Diffstat (limited to 'spec/support')
-rw-r--r--spec/support/capybara.rb1
-rw-r--r--spec/support/database_cleaner.rb21
-rw-r--r--spec/support/helpers.rb4
-rw-r--r--spec/support/helpers/session_helpers.rb19
-rw-r--r--spec/support/referential.rb8
5 files changed, 45 insertions, 8 deletions
diff --git a/spec/support/capybara.rb b/spec/support/capybara.rb
new file mode 100644
index 000000000..eb8124f44
--- /dev/null
+++ b/spec/support/capybara.rb
@@ -0,0 +1 @@
+Capybara.asset_host = 'http://localhost:3000'
diff --git a/spec/support/database_cleaner.rb b/spec/support/database_cleaner.rb
new file mode 100644
index 000000000..a9758d437
--- /dev/null
+++ b/spec/support/database_cleaner.rb
@@ -0,0 +1,21 @@
+RSpec.configure do |config|
+ config.before(:suite) do
+ DatabaseCleaner.clean_with(:truncation)
+ end
+
+ config.before(:each) do
+ DatabaseCleaner.strategy = :transaction
+ end
+
+ config.before(:each, :js => true) do
+ DatabaseCleaner.strategy = :truncation
+ end
+
+ config.before(:each) do
+ DatabaseCleaner.start
+ end
+
+ config.append_after(:each) do
+ DatabaseCleaner.clean
+ end
+end
diff --git a/spec/support/helpers.rb b/spec/support/helpers.rb
new file mode 100644
index 000000000..5e1becafb
--- /dev/null
+++ b/spec/support/helpers.rb
@@ -0,0 +1,4 @@
+require 'support/helpers/session_helpers'
+RSpec.configure do |config|
+ config.include Features::SessionHelpers, type: :feature
+end
diff --git a/spec/support/helpers/session_helpers.rb b/spec/support/helpers/session_helpers.rb
new file mode 100644
index 000000000..17a3fc51b
--- /dev/null
+++ b/spec/support/helpers/session_helpers.rb
@@ -0,0 +1,19 @@
+module Features
+ module SessionHelpers
+ def sign_up_with(email, password, confirmation)
+ visit new_user_session_path
+ fill_in '#registration_new #user_email', with: email
+ fill_in 'Password', with: password
+ fill_in 'Password confirmation', :with => confirmation
+ click_button 'Sign up'
+ end
+
+ def signin(email, password)
+ visit new_user_session_path
+ save_and_open_page
+ fill_in '#session_new #user_email', with: email
+ fill_in 'Password', with: password
+ click_button 'Sign in'
+ end
+ end
+end
diff --git a/spec/support/referential.rb b/spec/support/referential.rb
index d20b68ee6..c1a043b8f 100644
--- a/spec/support/referential.rb
+++ b/spec/support/referential.rb
@@ -27,10 +27,6 @@ RSpec.configure do |config|
config.include ReferentialHelper
config.before(:suite) do
- # Clean all tables to start
- DatabaseCleaner.clean_with :truncation
- # Use transactions for tests
- DatabaseCleaner.strategy = :transaction
# Truncating doesn't drop schemas, ensure we're clean here, first *may not* exist
Apartment::Tenant.drop('first') rescue nil
# Create the default tenant for our tests
@@ -39,8 +35,6 @@ RSpec.configure do |config|
end
config.before(:each) do
- # Start transaction for this test
- #DatabaseCleaner.start
# Switch into the default tenant
first_referential.switch
end
@@ -48,8 +42,6 @@ RSpec.configure do |config|
config.after(:each) do
# Reset tenant back to `public`
Apartment::Tenant.reset
- # Rollback transaction
- DatabaseCleaner.clean
end
end