Class: Shoulda::Matchers::Integrations::Configuration
- Inherits:
-
Object
- Object
- Shoulda::Matchers::Integrations::Configuration
- Defined in:
- lib/shoulda/matchers/integrations/configuration.rb
Instance Attribute Summary collapse
-
#test_frameworks ⇒ Object
readonly
Returns the value of attribute test_frameworks.
Class Method Summary collapse
Instance Method Summary collapse
- #apply ⇒ Object
-
#initialize(&block) ⇒ Configuration
constructor
A new instance of Configuration.
- #library(name) ⇒ Object
- #test_framework(name) ⇒ Object
Constructor Details
#initialize(&block) ⇒ Configuration
Returns a new instance of Configuration.
14 15 16 17 18 19 20 21 22 |
# File 'lib/shoulda/matchers/integrations/configuration.rb', line 14 def initialize(&block) @test_frameworks = Set.new @libraries = Set.new test_framework :missing_test_framework library :missing_library block.call(self) end |
Instance Attribute Details
#test_frameworks ⇒ Object (readonly)
Returns the value of attribute test_frameworks.
12 13 14 |
# File 'lib/shoulda/matchers/integrations/configuration.rb', line 12 def test_frameworks @test_frameworks end |
Class Method Details
.apply(&block) ⇒ Object
8 9 10 |
# File 'lib/shoulda/matchers/integrations/configuration.rb', line 8 def self.apply(&block) new(&block).apply end |
Instance Method Details
#apply ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/shoulda/matchers/integrations/configuration.rb', line 33 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 |
#library(name) ⇒ Object
29 30 31 |
# File 'lib/shoulda/matchers/integrations/configuration.rb', line 29 def library(name) @libraries << Integrations.find_library!(name) end |
#test_framework(name) ⇒ Object
24 25 26 27 |
# File 'lib/shoulda/matchers/integrations/configuration.rb', line 24 def test_framework(name) clear_default_test_framework @test_frameworks << Integrations.find_test_framework!(name) end |