Module: RSpec::PowerAssert

Defined in:
lib/rspec/power_assert.rb,
lib/rspec/power_assert/version.rb

Constant Summary collapse

VERSION =
"1.0.0"

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.example_assertion_alias(name) ⇒ Object



21
22
23
# File 'lib/rspec/power_assert.rb', line 21

def self.example_assertion_alias(name)
  alias_method(name.to_sym, :is_asserted_by)
end

.example_group_assertion_alias(name) ⇒ Object



25
26
27
# File 'lib/rspec/power_assert.rb', line 25

def self.example_group_assertion_alias(name)
  PowerAssertExtensions.assertion_method_alias(name)
end

.verbose_successful_reportObject



13
14
15
# File 'lib/rspec/power_assert.rb', line 13

def self.verbose_successful_report
  !!@verbose_successful_report
end

.verbose_successful_report=(verbose) ⇒ Object



17
18
19
# File 'lib/rspec/power_assert.rb', line 17

def self.verbose_successful_report=(verbose)
  @verbose_successful_report = verbose
end

Instance Method Details

#is_asserted_by(&blk) ⇒ Object



29
30
31
32
33
34
35
36
# File 'lib/rspec/power_assert.rb', line 29

def is_asserted_by(&blk)
  result, msg = ::PowerAssert.start(blk, assertion_method: __callee__) do |tp|
    [tp.yield, tp.message_proc.call]
  end

  location = blk.source_location.join(":")
  handle_result_and_message(result, msg, __callee__, location)
end