Module: ApprovalTests::Extensions::RSpec

Defined in:
lib/approval_tests/extensions/rspec.rb

Instance Method Summary collapse

Instance Method Details

#approve(thing = nil, options = {}, backtrace = nil, &implementation) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/approval_tests/extensions/rspec.rb', line 4

def approve(thing=nil, options={}, backtrace=nil, &implementation)
  if block_given?
    approve_description = "#{thing}" 
  else
    approve_description = nil
    result = thing
  end

  example(approve_description, options) do
    if block_given?    
      result = yield implementation
    end
    Approvals.approve(result)
  end
end

#approve_html(thing = nil, options = {}, backtrace = nil, &implementation) ⇒ Object



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/approval_tests/extensions/rspec.rb', line 20

def approve_html(thing=nil, options={}, backtrace=nil, &implementation)
  if block_given?
    approve_description = "#{thing}" 
  else
    approve_description = nil
    result = thing
  end

  example(approve_description, options) do
    if block_given?    
      result = yield implementation
    end
    Approvals.approve(result, :html)
  end
end