Class: ConvenientService::RSpec::Matchers::Classes::IncludeConfig
- Inherits:
-
Object
- Object
- ConvenientService::RSpec::Matchers::Classes::IncludeConfig
- Defined in:
- lib/convenient_service/rspec/matchers/classes/include_config.rb
Instance Method Summary collapse
- #description ⇒ String
- #failure_message ⇒ String
- #failure_message_when_negated ⇒ String
-
#initialize(config) ⇒ IncludeConfig
constructor
A new instance of IncludeConfig.
-
#matches?(klass) ⇒ Boolean
rubocop:disable Performance/RedundantEqualityComparisonBlock.
Constructor Details
#initialize(config) ⇒ IncludeConfig
Returns a new instance of IncludeConfig.
16 17 18 |
# File 'lib/convenient_service/rspec/matchers/classes/include_config.rb', line 16 def initialize(config) @config = config end |
Instance Method Details
#description ⇒ String
40 41 42 |
# File 'lib/convenient_service/rspec/matchers/classes/include_config.rb', line 40 def description "include config `#{config.inspect}`" end |
#failure_message ⇒ String
47 48 49 |
# File 'lib/convenient_service/rspec/matchers/classes/include_config.rb', line 47 def "expected `#{klass.inspect}` to include config `#{config.inspect}`" end |
#failure_message_when_negated ⇒ String
54 55 56 |
# File 'lib/convenient_service/rspec/matchers/classes/include_config.rb', line 54 def "expected `#{klass.inspect}` NOT to include config `#{config.inspect}`" end |
#matches?(klass) ⇒ Boolean
rubocop:disable Performance/RedundantEqualityComparisonBlock
30 31 32 33 34 |
# File 'lib/convenient_service/rspec/matchers/classes/include_config.rb', line 30 def matches?(klass) @klass = klass klass.ancestors.drop_while { |ancestor| ancestor != klass }.any? { |mod| config == mod } end |