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.

%w(ignore pending exception).map(&:intern)
STRING_FAILURE_MESSAGE_MATCH_OPTIONS =

Options for matching failure messages to strings.

%w(exact substring).map(&:intern)

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
# File 'lib/rspec/sleeping_king_studios/configuration.rb', line 32

def handle_missing_failure_message_with= value
  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.



46
47
48
# File 'lib/rspec/sleeping_king_studios/configuration.rb', line 46

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.



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

def match_string_failure_message_as= value
  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