-
Notifications
You must be signed in to change notification settings - Fork 69
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
spinach-rails or spinach gem? #189
Comments
I do not use My typical require "webmock"
include WebMock::API
WebMock.disable_net_connect!(allow_localhost: true)
require "./config/environment"
require "rspec/rails"
require "spinach/capybara"
require "capybara-screenshot/spinach"
require "ci/reporter/spinach"
Dir[Rails.root.join("features/support/**/*.rb")].each do |f|
require f
end
require Rails.root.join("features/steps/common_steps/base")
Capybara.javascript_driver = :selenium
Capybara.default_max_wait_time = (ENV["CAPYBARA_WAIT_TIME"] || 15).to_i
Capybara.wait_on_first_by_default = true
require "database_cleaner"
Spinach.hooks.before_run do
DatabaseCleaner.clean_with(:truncation)
end
Spinach.hooks.on_tag("javascript") do
::Capybara.current_driver = ::Capybara.javascript_driver
Capybara.page.driver.browser.manage.window.maximize
end
Spinach.hooks.before_scenario do
DatabaseCleaner.strategy = :truncation
DatabaseCleaner.start
end
Spinach.hooks.after_scenario do
DatabaseCleaner.clean
`rm -rf ~/.mozilla`
end Instead of extend my step files from Dir[Rails.root.join("features/steps/common_steps/**/*.rb")].each do |f|
require f
end
module CommonSteps
class Base < Spinach::FeatureSteps
include Login
def parent_element(element)
element.first(:xpath, ".//..")
end
def js_errors
page.driver.browser.manage.logs.get(:browser)
end
def position_of(parent_element:, text:)
parent_element["innerHTML"].index(text)
end
end
end I hope this helps you to get started with |
Thanks @ywen . This is helpful. |
@c1505 realize I'm a bit late to the party on this, but since this is still open, thought I'd provide an update for anyone else that might be wondering the same thing. I've included ENV['RAILS_ENV'] = 'test'
require './config/environment'
require 'rspec/rails'
Dir[Rails.root.join("spec/support/**/*.rb")].each { |f| require f }
# Spinach.config.save_and_open_page_on_failure = true One of the nice things about this with rails 5.2 is that I no longer have to include Capybara (it's there by default in Rails 5.2) and I also do not need DatabaseCleaner (rails 5.2 also removed the need for this). Obviously, I'm using RSpec, and the spec/support line provides all the RSpec helpers to Spinach as well. |
discovered some additional issues with my previous config. I ended up with this as my # Help Spinach find the spec directory for autoloading
$LOAD_PATH.unshift(::File.expand_path('../../spec', __dir__))
require './config/environment'
# Most of the desired config is already in rspec
require 'rails_helper'
require 'database_cleaner'
require 'timecop'
DatabaseCleaner.strategy = :truncation
Spinach.hooks.before_scenario do
::Capybara.current_driver = :selenium_chrome_headless
DatabaseCleaner.clean
end
Spinach.hooks.after_scenario do
Timecop.return
end
# Spinach.config.save_and_open_page_on_failure = true |
I am just starting to look at using spinach for rails projects and it isn't clear to me if I should be using spinach-rails or not for rails 4 and up.
It doesn't look like spinach-rails is being actively maintained. I see that spinach-rails is recommended in the readme for rails 3 projects, but I don't see any indication for other rails versions.
Thanks for your help.
The text was updated successfully, but these errors were encountered: