Skip to content

Instantly share code, notes, and snippets.

@singh08avinash
Created May 15, 2018 06:05
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 singh08avinash/e93a3d9d6129e746424f00234f07a7c7 to your computer and use it in GitHub Desktop.
Save singh08avinash/e93a3d9d6129e746424f00234f07a7c7 to your computer and use it in GitHub Desktop.
Error related to database_cleaner gem
# IMPORTANT: This file is generated by cucumber-rails - edit at your own peril.
# It is recommended to regenerate this file in the future when you upgrade to a
# newer version of cucumber-rails. Consider adding your own code to a new file
# instead of editing this one. Cucumber will automatically load all features/**/*.rb
# files.
require 'cucumber/rails'
require 'simplecov'
SimpleCov.start 'rails'
# require 'sidekiq/testing'
# Sidekiq::Testing.inline!
# Capybara defaults to CSS3 selectors rather than XPath.
# If you'd prefer to use XPath, just uncomment this line and adjust any
# selectors in your step definitions to use the XPath syntax.
# Capybara.default_selector = :xpath
# By default, any exception happening in your Rails application will bubble up
# to Cucumber so that your scenario will fail. This is a different from how
# your application behaves in the production environment, where an error page will
# be rendered instead.
#
# Sometimes we want to override this default behaviour and allow Rails to rescue
# exceptions and display an error page (just like when the app is running in production).
# Typical scenarios where you want to do this is when you test your error pages.
# There are two ways to allow Rails to rescue exceptions:
#
# 1) Tag your scenario (or feature) with @allow-rescue
#
# 2) Set the value below to true. Beware that doing this globally is not
# recommended as it will mask a lot of errors for you!
#
class ActiveRecord::Base
mattr_accessor :shared_connection
@@shared_connection = nil
def self.connection
@@shared_connection || ConnectionPool::Wrapper.new(:size => 1) { retrieve_connection }
end
end
ActiveRecord::Base.shared_connection = ActiveRecord::Base.connection
# Forces all threads to share the same connection. This works on
# Capybara because it starts the web server in a thread.
# ActiveRecord::Base.shared_connection = ActiveRecord::Base.connection
ActionController::Base.allow_rescue = false
Capybara.default_selector = :css
Capybara.default_driver = :chrome
Capybara.register_driver :chrome do |app|
options = {
:js_errors => false,
:timeout => 360,
:inspector => false,
}
Capybara::Selenium::Driver.new(app, :browser => :chrome)
end
Capybara.default_max_wait_time = 5
Capybara.configure do |config|
config.run_server = true
config.server_port = 3004
config.javascript_driver = :webkit
# config.always_include_port = true
# config.default_host = 'http://127.0.0.1:3004'
# config.app_host = 'http://127.0.0.1:3004'
end
# Remove/comment out the lines below if your app doesn't have a database.
# For some databases (like MongoDB and CouchDB) you may need to use :truncation instead.
begin
require 'database_cleaner'
require 'database_cleaner/cucumber'
DatabaseCleaner.strategy = :truncation
rescue NameError
raise "You need to add database_cleaner to your Gemfile (in the :test group) if you wish to use it."
end
# user = User.new(email: "trade@trustss.io", password: "123456", username: "admin2", role: "admin", full_name:"admin").save(validate: false)
# You may also want to configure DatabaseCleaner to use different strategies for certain features and scenarios.
# See the DatabaseCleaner documentation for details. Example:
#
# Before('@no-txn,@selenium,@culerity,@celerity,@javascript') do
# # { :except => [:widgets] } may not do what you expect here
# # as Cucumber::Rails::Database.javascript_strategy overrides
# # this setting.
# DatabaseCleaner.strategy = :truncation
# end
#
# Before('~@no-txn', '~@selenium', '~@culerity', '~@celerity', '~@javascript') do
# DatabaseCleaner.strategy = :transaction
# end
#
# Possible values are :truncation and :transaction
# The :transaction strategy is faster, but might give you threading problems.
# See https://github.com/cucumber/cucumber-rails/blob/master/features/choose_javascript_database_strategy.feature
Cucumber::Rails::Database.javascript_strategy = :truncation
Around do |scenario, block|
DatabaseCleaner.cleaning(&block)
end
Cucumber::Rails::Database.javascript_strategy = :truncation
source 'https://rubygems.org'
ruby '2.4.3'
git_source(:github) do |repo_name|
repo_name = "#{repo_name}/#{repo_name}" unless repo_name.include?("/")
"https://github.com/#{repo_name}.git"
end
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '~> 5.0.6'
# Use mysql as the database for Active Record
gem 'mysql2', '>= 0.3.18', '< 0.5'
# Use Puma as the app server
gem 'puma', '~> 3.0'
gem 'gentelella-rails'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 5.0'
gem 'aws-sdk','1.66.0'
gem "bootstrap_flash_messages"
gem 'eth'
gem 'jsonrpc-client'
gem 'ethereum.rb'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# Use CoffeeScript for .coffee assets and views
gem 'coffee-rails', '~> 4.2'
gem "paperclip", "4.3.7"
# See https://github.com/rails/execjs#readme for more supported runtimes
# gem 'therubyracer', platforms: :ruby
gem 'active_model_serializers'
gem 'json','~>1.4'
gem 'whenever'
gem 'will_paginate', '~> 3.1.0'
gem "twitter-bootstrap-rails"
gem "font-awesome-rails"
gem 'jquery-rails'
gem 'bootstrap-glyphicons'
gem 'exception_notification'
gem "slim-rails"
gem "letter_opener", :group => :development
gem 'devise'
gem "recaptcha", require: "recaptcha/rails"
# Use jquery as the JavaScript library
gem 'jquery-rails'
# Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks
gem 'turbolinks', '~> 5'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.5'
# Use Redis adapter to run Action Cable in production
# gem 'redis', '~> 3.0'
# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'
# Use Capistrano for deployment
# gem 'capistrano-rails', group: :development
gem "slim-rails"
group :development, :test do
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
gem 'byebug', platforms: [:mri, :mingw, :x64_mingw]
# Adds support for Capybara system testing and selenium driver
gem 'capybara', '~> 2.13'
gem 'selenium-webdriver'
gem 'cucumber-rails', :require => false
gem 'database_cleaner'
gem "cucumber-websteps"
gem 'chromedriver-helper'
gem 'connection_pool'
end
group :development do
# Access an IRB console on exception pages or by using <%= console %> anywhere in the code.
gem 'web-console', '>= 3.3.0'
gem 'listen', '~> 3.0.5', '< 3.2'
# Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
gem 'spring'
gem 'spring-watcher-listen', '~> 2.0.0'
end
# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
group :development, :test do
gem "factory_bot_rails", "~> 4.0"
gem "webmock"
gem 'faker'
gem 'rspec-rails'
gem 'thin'
gem 'shoulda-matchers', '~> 3.1'
gem 'simplecov', :require => false
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment