class Shoulda::Matchers::Integrations::Configuration
@private
Public Class Methods
apply(configuration, &block)
click to toggle source
# File lib/shoulda/matchers/integrations/configuration.rb, line 8 def self.apply(configuration, &block) new(configuration, &block).apply end
new(configuration, &block)
click to toggle source
# File lib/shoulda/matchers/integrations/configuration.rb, line 12 def initialize(configuration, &block) @test_frameworks = Set.new @libraries = Set.new test_framework :missing_test_framework library :missing_library block.call(self) end
Public Instance Methods
apply()
click to toggle source
# File lib/shoulda/matchers/integrations/configuration.rb, line 31 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 end
library(name)
click to toggle source
# File lib/shoulda/matchers/integrations/configuration.rb, line 27 def library(name) @libraries << Integrations.find_library!(name) end
test_framework(name)
click to toggle source
# File lib/shoulda/matchers/integrations/configuration.rb, line 22 def test_framework(name) clear_default_test_framework @test_frameworks << Integrations.find_test_framework!(name) end
Private Instance Methods
clear_default_test_framework()
click to toggle source
# File lib/shoulda/matchers/integrations/configuration.rb, line 54 def clear_default_test_framework @test_frameworks.select!(&:present?) end
no_libraries_added?()
click to toggle source
# File lib/shoulda/matchers/integrations/configuration.rb, line 62 def no_libraries_added? @libraries.empty? end
no_test_frameworks_added?()
click to toggle source
# File lib/shoulda/matchers/integrations/configuration.rb, line 58 def no_test_frameworks_added? @test_frameworks.empty? || !@test_frameworks.any?(&:present?) end