Class: RSpec::Expectations::Configuration

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

Instance Method Summary collapse

Instance Method Details

#original_syntaxObject


17
# File 'lib/rspec/maybes/configuration.rb', line 17

alias :original_syntax  :syntax

#original_syntax=Object


16
# File 'lib/rspec/maybes/configuration.rb', line 16

alias :original_syntax= :syntax=

#syntaxArray<Symbol>

The list of configured syntaxes.

Examples:

unless RSpec::Matchers.configuration.syntax.include?(:maybe)
  raise "this RSpec extension gem requires the spec-me-maybe `:maybe` syntax"
end

Returns:

  • (Array<Symbol>)

    the list of configured syntaxes.


47
48
49
50
51
# File 'lib/rspec/maybes/configuration.rb', line 47

def syntax
  syntaxes = original_syntaxes
  syntaxes << :maybe if Maybes::Syntax.maybe_enabled?
  syntaxes
end

#syntax=(values) ⇒ Object

Configures the supported syntax.

Examples:

RSpec.configure do |rspec|
  rspec.expect_with :rspec do |c|
    c.syntax = :maybe
    # or
    c.syntax = :expect
    # or
    c.syntax = [:maybe, :expect]
  end
end

Parameters:

  • values (Array<Symbol>, Symbol)

    the syntaxes to enable


31
32
33
34
35
36
37
38
39
# File 'lib/rspec/maybes/configuration.rb', line 31

def syntax=(values)
  original_syntax = values

  if Array(values).include?(:maybe)
    Maybes::Syntax.enable_maybe
  else
    Maybes::Syntax.disable_maybe
  end
end