2011-03-30 20:31:39 -04:00
|
|
|
require 'machinist/active_record'
|
|
|
|
require 'sham'
|
|
|
|
require 'faker'
|
2011-04-11 12:59:26 -04:00
|
|
|
require 'ransack'
|
2014-08-01 01:15:58 -04:00
|
|
|
require 'pry'
|
2011-03-30 20:31:39 -04:00
|
|
|
|
2014-05-17 17:12:59 -04:00
|
|
|
I18n.enforce_available_locales = false
|
2011-03-30 20:31:39 -04:00
|
|
|
Time.zone = 'Eastern Time (US & Canada)'
|
2011-06-04 18:01:12 -04:00
|
|
|
I18n.load_path += Dir[File.join(File.dirname(__FILE__), 'support', '*.yml')]
|
2011-03-30 20:31:39 -04:00
|
|
|
|
2013-12-10 04:52:46 -05:00
|
|
|
Dir[File.expand_path('../{helpers,support,blueprints}/*.rb', __FILE__)]
|
2015-01-07 16:45:39 -05:00
|
|
|
.each { |f| require f }
|
2011-03-30 20:31:39 -04:00
|
|
|
|
|
|
|
Sham.define do
|
2013-11-26 08:15:18 -05:00
|
|
|
name { Faker::Name.name }
|
|
|
|
title { Faker::Lorem.sentence }
|
|
|
|
body { Faker::Lorem.paragraph }
|
2013-12-10 04:52:46 -05:00
|
|
|
salary { |index| 30000 + (index * 1000) }
|
2013-11-26 08:15:18 -05:00
|
|
|
tag_name { Faker::Lorem.words(3).join(' ') }
|
|
|
|
note { Faker::Lorem.words(7).join(' ') }
|
|
|
|
only_admin { Faker::Lorem.words(3).join(' ') }
|
|
|
|
only_search { Faker::Lorem.words(3).join(' ') }
|
|
|
|
only_sort { Faker::Lorem.words(3).join(' ') }
|
2013-12-06 05:53:24 -05:00
|
|
|
notable_id { |id| id }
|
2011-03-30 20:31:39 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
RSpec.configure do |config|
|
2013-02-06 08:15:05 -05:00
|
|
|
config.alias_it_should_behave_like_to :it_has_behavior, 'has behavior'
|
2013-02-06 05:26:06 -05:00
|
|
|
|
2012-01-20 15:13:27 -05:00
|
|
|
config.before(:suite) do
|
|
|
|
puts '=' * 80
|
2013-11-05 23:58:30 -05:00
|
|
|
connection_name = ActiveRecord::Base.connection.adapter_name
|
2013-12-10 04:52:46 -05:00
|
|
|
puts "Running specs against #{connection_name}, ActiveRecord #{
|
|
|
|
ActiveRecord::VERSION::STRING} and ARel #{Arel::VERSION}..."
|
2012-01-20 15:13:27 -05:00
|
|
|
puts '=' * 80
|
|
|
|
Schema.create
|
|
|
|
end
|
|
|
|
|
2011-03-30 20:31:39 -04:00
|
|
|
config.before(:all) { Sham.reset(:before_all) }
|
|
|
|
config.before(:each) { Sham.reset(:before_each) }
|
|
|
|
|
|
|
|
config.include RansackHelper
|
2011-07-17 19:40:07 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
RSpec::Matchers.define :be_like do |expected|
|
|
|
|
match do |actual|
|
|
|
|
actual.gsub(/^\s+|\s+$/, '').gsub(/\s+/, ' ').strip ==
|
|
|
|
expected.gsub(/^\s+|\s+$/, '').gsub(/\s+/, ' ').strip
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
RSpec::Matchers.define :have_attribute_method do |expected|
|
|
|
|
match do |actual|
|
|
|
|
actual.attribute_method?(expected)
|
|
|
|
end
|
2012-04-11 11:58:27 -04:00
|
|
|
end
|