Class: RSpec::Matchers::DefineConstant::Matcher

Inherits:
Object
  • Object
show all
Includes:
RSpec::Matcher
Defined in:
lib/rspec/matchers/define_constant/matcher.rb

Overview

runs block, checks if it defines constant, removes defined constant

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#typeObject

Returns the value of attribute type.



8
9
10
# File 'lib/rspec/matchers/define_constant/matcher.rb', line 8

def type
  @type
end

Instance Method Details

#descriptionObject



20
21
22
# File 'lib/rspec/matchers/define_constant/matcher.rb', line 20

def description
  "define constant"
end

#matchObject



10
11
12
13
14
15
16
17
18
# File 'lib/rspec/matchers/define_constant/matcher.rb', line 10

def match
  validate_input
  expected_shouldnt_exist
  actual.call
  expected_should_exist
  expected_should_have_correct_type

  true
end

#of_type(type) ⇒ Object



28
29
30
# File 'lib/rspec/matchers/define_constant/matcher.rb', line 28

def of_type type
  self.type = type and self
end

#supports_block_expectations?Boolean

Returns:

  • (Boolean)


24
25
26
# File 'lib/rspec/matchers/define_constant/matcher.rb', line 24

def supports_block_expectations?
  true
end