about summary refs log tree commit diff
path: root/spec
diff options
context:
space:
mode:
authorChad Pytel <chad@thoughtbot.com>2017-04-14 19:21:02 -0400
committerEugen <eugen@zeonfederated.com>2017-04-15 01:21:02 +0200
commit92cd207c5083e60074e0ce123bb5b848a58e7417 (patch)
tree503e0e5222579ebb5d5ddfd1c6e617f6d03974b0 /spec
parentf5cd1383231af6922dbab4f54b7d29eacfec9d9e (diff)
Introduce capybara and first feature spec (#1801)
This commit introduces Capybara and the first feature spec.

I focused on coverage for log in for the first feature spec because that would
have prevented 624a9a7136159d460228a0c2f5df18a9ead3b7f2 causing #1236.
Diffstat (limited to 'spec')
-rw-r--r--spec/features/log_in_spec.rb16
-rw-r--r--spec/rails_helper.rb6
2 files changed, 22 insertions, 0 deletions
diff --git a/spec/features/log_in_spec.rb b/spec/features/log_in_spec.rb
new file mode 100644
index 000000000..4a634f6b8
--- /dev/null
+++ b/spec/features/log_in_spec.rb
@@ -0,0 +1,16 @@
+require "rails_helper"
+
+feature "Log in" do
+  scenario "A valid email and password user is able to log in" do
+    email = "test@example.com"
+    password = "password"
+    Fabricate(:user, email: email, password: password)
+
+    visit new_user_session_path
+    fill_in "user_email", with: email
+    fill_in "user_password", with: password
+    click_on "Log in"
+
+    expect(page).to have_css "div.app-holder[data-react-class=Mastodon]"
+  end
+end
diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb
index faac96982..536c5a774 100644
--- a/spec/rails_helper.rb
+++ b/spec/rails_helper.rb
@@ -7,6 +7,7 @@ require 'spec_helper'
 require 'rspec/rails'
 require 'webmock/rspec'
 require 'paperclip/matchers'
+require 'capybara/rspec'
 
 Dir[Rails.root.join('spec/support/**/*.rb')].each { |f| require f }
 
@@ -24,6 +25,11 @@ RSpec.configure do |config|
   config.include Devise::Test::ControllerHelpers, type: :controller
   config.include Devise::TestHelpers, type: :view
   config.include Paperclip::Shoulda::Matchers
+
+  config.before :each, type: :feature do
+    https = ENV['LOCAL_HTTPS'] == 'true'
+    Capybara.app_host = "http#{https ? 's' : ''}://#{ENV.fetch('LOCAL_DOMAIN')}"
+  end
 end
 
 RSpec::Sidekiq.configure do |config|