forked from rspec/rspec-rails
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfeature_check.rb
60 lines (50 loc) · 1.48 KB
/
feature_check.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
module RSpec
module Rails
# @private
# Disable some cops until https://github.com/bbatsov/rubocop/issues/1310
# rubocop:disable Style/IndentationConsistency
module FeatureCheck
# rubocop:disable Style/IndentationWidth
module_function
# rubocop:enable Style/IndentationWidth
def can_check_pending_migrations?
has_active_record_migration? &&
::ActiveRecord::Migration.respond_to?(:check_pending!)
end
def can_maintain_test_schema?
has_active_record_migration? &&
::ActiveRecord::Migration.respond_to?(:maintain_test_schema!)
end
def has_active_job?
defined?(::ActiveJob)
end
def has_active_record?
defined?(::ActiveRecord)
end
def has_active_record_migration?
has_active_record? && defined?(::ActiveRecord::Migration)
end
def has_action_mailer?
defined?(::ActionMailer)
end
def has_action_mailer_preview?
has_action_mailer? && defined?(::ActionMailer::Preview)
end
def has_action_mailer_show_preview?
has_action_mailer_preview? &&
::ActionMailer::Base.respond_to?(:show_previews=)
end
def has_1_9_hash_syntax?
::Rails::VERSION::STRING > '4.0'
end
def type_metatag(type)
if has_1_9_hash_syntax?
"type: :#{type}"
else
":type => :#{type}"
end
end
end
# rubocop:enable Style/IndentationConsistency
end
end