Class: RSpec::SleepingKingStudios::Configuration::Examples

Inherits:
Object
  • Object
show all
Defined in:
lib/rspec/sleeping_king_studios/configuration.rb

Overview

Configuration options for RSpec::SleepingKingStudios::Examples.

Constant Summary collapse

MISSING_FAILURE_MESSAGE_HANDLERS =

Permitted options for :handle_missing_failure_message_with.

%i[ignore pending exception].freeze
STRING_FAILURE_MESSAGE_MATCH_OPTIONS =

Options for matching failure messages to strings.

%i[exact substring].freeze

Instance Method Summary collapse

Instance Method Details

#handle_missing_failure_message_withSymbol

Gets the handler for missing failure messages when using the matcher examples, and sets to :pending if unset.

Returns:

  • (Symbol)

    The current missing message handler.



20
21
22
# File 'lib/rspec/sleeping_king_studios/configuration.rb', line 20

def handle_missing_failure_message_with
  @handle_missing_failure_message_with ||= :pending
end

#handle_missing_failure_message_with=(value) ⇒ Object

Sets the handler for missing failure messages when using the matcher examples.

Parameters:

  • value (Symbol)

    The desired handler. Must be :ignore, :pending, or :exception.

Raises:

  • ArgumentError If the handler is not one of the recognized values.



32
33
34
35
36
37
38
39
40
41
42
# File 'lib/rspec/sleeping_king_studios/configuration.rb', line 32

def handle_missing_failure_message_with= value
  value = value.to_s.intern

  unless MISSING_FAILURE_MESSAGE_HANDLERS.include?(value)
    message = "unrecognized handler value -- must be in #{MISSING_FAILURE_MESSAGE_HANDLERS.join ', '}"

    raise ArgumentError.new message
  end # unless

  @handle_missing_failure_message_with = value
end

#match_string_failure_message_asSymbol

Gets the option for matching failure messages to strings, and sets to :substring if unset.

Returns:

  • (Symbol)

    The current failure message string matching option.



48
49
50
# File 'lib/rspec/sleeping_king_studios/configuration.rb', line 48

def match_string_failure_message_as
  @match_string_failure_message_as ||= :substring
end

#match_string_failure_message_as=(value) ⇒ Object

Sets the option for matching failure messages to strings.

Parameters:

  • value (Symbol)

    The desired option. Must be :exact, :substring, or :partial (alias of :substring).

Raises:

  • ArgumentError If the handler is not one of the recognized values.



59
60
61
62
63
64
65
66
67
68
69
70
# File 'lib/rspec/sleeping_king_studios/configuration.rb', line 59

def match_string_failure_message_as= value
  value = value.to_s.intern
  value = :substring if value == :partial

  unless STRING_FAILURE_MESSAGE_MATCH_OPTIONS.include?(value)
    message = "unrecognized value -- must be in #{STRING_FAILURE_MESSAGE_MATCH_OPTIONS.join ', '}"

    raise ArgumentError.new message
  end # unless

  @match_string_failure_message_as = value
end