Class: Purist::Integrations::RSpec::BePure

Inherits:
Object
  • Object
show all
Defined in:
lib/purist/integrations/rspec/be_pure.rb

Instance Method Summary collapse

Instance Method Details

#descriptionObject



25
26
27
# File 'lib/purist/integrations/rspec/be_pure.rb', line 25

def description
  'block to be pure'
end

#description_when_negatedObject



29
30
31
# File 'lib/purist/integrations/rspec/be_pure.rb', line 29

def description_when_negated
  'block to be impure'
end

#failure_messageObject



33
34
35
# File 'lib/purist/integrations/rspec/be_pure.rb', line 33

def failure_message
  "expected #{description}, detected impure #{purist_exception.trace_point.inspect}"
end

#failure_message_when_negatedObject



37
38
39
# File 'lib/purist/integrations/rspec/be_pure.rb', line 37

def failure_message_when_negated
  "expected #{description_when_negated}, but no side-effects were detected"
end

#matches?(block) ⇒ Boolean



15
16
17
18
19
20
21
22
23
# File 'lib/purist/integrations/rspec/be_pure.rb', line 15

def matches?(block)
  Purist.trace { block.call }

  true
rescue Purist::Errors::PurityViolationError => e
  @purist_exception = e

  false
end

#supports_block_expectations?Boolean



11
12
13
# File 'lib/purist/integrations/rspec/be_pure.rb', line 11

def supports_block_expectations?
  true
end

#supports_value_expectations?Boolean



7
8
9
# File 'lib/purist/integrations/rspec/be_pure.rb', line 7

def supports_value_expectations?
  false
end