80 lines
2.7 KiB
Ruby
80 lines
2.7 KiB
Ruby
# This file is copied to spec/ when you run 'rails generate rspec:install'
|
|
ENV["RAILS_ENV"] ||= 'test'
|
|
require File.expand_path("../../config/environment", __FILE__)
|
|
require 'rspec/rails'
|
|
require 'rspec/matchers'
|
|
require 'capybara/rspec'
|
|
require 'turnip/capybara'
|
|
|
|
# Requires supporting ruby files with custom matchers and macros, etc,
|
|
# in spec/support/ and its subdirectories.
|
|
Dir[Rails.root.join("spec/support/**/*.rb")].each {|f| require f}
|
|
#Dir[Rails.root.join("spec/factories/**/*.rb")].each {|f| require f }
|
|
Dir.glob("spec/acceptance_steps/**/*steps.rb") { |f| load f, true }
|
|
|
|
I18n.locale = Rails.configuration.i18n.default_locale
|
|
Devise.stretches = 1
|
|
Capybara.javascript_driver = :webkit
|
|
#Capybara.default_driver = :selenium
|
|
|
|
module FactoryAttributesFor
|
|
def attributes_for(obj, options={})
|
|
super(obj, options).merge(build(obj).attributes.select{|k,v| k =~ /_id$/}).symbolize_keys
|
|
end
|
|
end
|
|
RSpec.configure do |config|
|
|
# == Mock Framework
|
|
#
|
|
# If you prefer to use mocha, flexmock or RR, uncomment the appropriate line:
|
|
#
|
|
# config.mock_with :mocha
|
|
# config.mock_with :flexmock
|
|
# config.mock_with :rr
|
|
config.mock_with :rspec
|
|
config.include FactoryGirl::Syntax::Methods
|
|
config.include FactoryAttributesFor
|
|
config.include Devise::TestHelpers, :type => :controller
|
|
config.include EndWithMatcher
|
|
config.include Features::BasicHelpers, type: :feature
|
|
#config.use_transactional_fixtures = true
|
|
config.infer_base_class_for_anonymous_controllers = true
|
|
config.render_views = true
|
|
|
|
# Use color in STDOUT
|
|
config.color_enabled = true
|
|
config.fail_fast = false
|
|
|
|
# Use color not only in STDOUT but also in pagers and files
|
|
config.tty = true
|
|
|
|
# Use the specified formatter
|
|
#config.formatter = :documentation # :progress, :html, :textmate
|
|
|
|
# Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
|
|
#config.fixture_path = "#{::Rails.root}/spec/fixtures"
|
|
|
|
# If you're not using ActiveRecord, or you'd prefer not to run each of your
|
|
# examples within a transaction, remove the following line or assign false
|
|
# instead of true.
|
|
#config.use_transactional_fixtures = true
|
|
|
|
config.before :each do
|
|
CouchPotato.couchrest_database.recreate!
|
|
end
|
|
|
|
config.before :each, type: :feature do
|
|
Supplier.any_instance.stub send_confirmation_instructions: true
|
|
end
|
|
|
|
# If true, the base class of anonymous controllers will be inferred
|
|
# automatically. This will be the default behavior in future versions of
|
|
# rspec-rails.
|
|
#config.infer_base_class_for_anonymous_controllers = true
|
|
def sign_in_user_through_request
|
|
visit "/users/sign_in"
|
|
fill_in 'user[email]', with: @user.email
|
|
fill_in 'user[password]', with: @user.password
|
|
click_on 'Inloggen'
|
|
end
|
|
end
|