mirror of
https://github.com/thoughtbot/shoulda-matchers.git
synced 2022-11-09 12:01:38 -05:00
3e88500318
Updated Layout/LineLength cop to Max 120 lenght and ignore everything inside specs/**/* Added rules for below cops in .rubocop.yml Lint/AmbiguousBlockAssociation Naming/HeredocDelimiterNaming Rails/SkipsModelValidations Style/FormatStringToken Fixed below mentioned cops: - Layout/CaseIndentation - Layout/DotPosition - Layout/ElseAlignment - Layout/IndentationWidth - Layout/LineLength - Layout/MultilineBlockLayout - Layout/MultilineOperationIndentation - Lint/AmbiguousBlockAssociation - Lint/MissingCopEnableDirective - Lint/NestedMethodDefinition - Lint/RedundantCopDisableDirective - Lint/RedundantRequireStatement - Lint/UnusedBlockArgument - Lint/UnusedMethodArgument - Metrics/ModuleLength - Naming/MemoizedInstanceVariableName - Naming/RescuedExceptionsVariableName - Rails/Output - Rails/Presence - Security/Eval - Security/Open - Style/ClassCheck - Style/CollectionMethods - Style/ConditionalAssignment - Style/EvalWithLocation - Style/FormatStringToken - Style/InverseMethods - Style/MutableConstant - Style/ParallelAssignment - Style/RedundantBegin - Style/RedundantCondition - Style/RedundantInterpolation - Style/RedundantSelf - Style/RedundantSort - Style/RescueStandardError - Style/SafeNavigation - Style/StringLiteralsInInterpolation - Style/SymbolProc
72 lines
1.6 KiB
Ruby
72 lines
1.6 KiB
Ruby
require 'set'
|
|
|
|
module Shoulda
|
|
module Matchers
|
|
module Integrations
|
|
# @private
|
|
class Configuration
|
|
def self.apply(&block)
|
|
new(&block).apply
|
|
end
|
|
|
|
attr_reader :test_frameworks
|
|
|
|
def initialize(&block)
|
|
@test_frameworks = Set.new
|
|
@libraries = Set.new
|
|
|
|
test_framework :missing_test_framework
|
|
library :missing_library
|
|
|
|
block.call(self)
|
|
end
|
|
|
|
def test_framework(name)
|
|
clear_default_test_framework
|
|
@test_frameworks << Integrations.find_test_framework!(name)
|
|
end
|
|
|
|
def library(name)
|
|
@libraries << Integrations.find_library!(name)
|
|
end
|
|
|
|
def apply
|
|
if no_test_frameworks_added? && no_libraries_added?
|
|
raise ConfigurationError, <<EOT
|
|
shoulda-matchers is not configured correctly. You need to specify at least one
|
|
test framework and/or library. For example:
|
|
|
|
Shoulda::Matchers.configure do |config|
|
|
config.integrate do |with|
|
|
with.test_framework :rspec
|
|
with.library :rails
|
|
end
|
|
end
|
|
EOT
|
|
end
|
|
|
|
@test_frameworks.each do |test_framework|
|
|
test_framework.include(Shoulda::Matchers::Independent)
|
|
@libraries.each { |library| library.integrate_with(test_framework) }
|
|
end
|
|
|
|
self
|
|
end
|
|
|
|
private
|
|
|
|
def clear_default_test_framework
|
|
@test_frameworks.select!(&:present?)
|
|
end
|
|
|
|
def no_test_frameworks_added?
|
|
@test_frameworks.empty? || @test_frameworks.none?(&:present?)
|
|
end
|
|
|
|
def no_libraries_added?
|
|
@libraries.empty?
|
|
end
|
|
end
|
|
end
|
|
end
|
|
end
|