Class: RSpecFixtures::ApprovalHandler

Inherits:
Object
  • Object
show all
Includes:
Colsole
Defined in:
lib/rspec_fixtures/approval_handler.rb

Instance Method Summary collapse

Instance Method Details

#run(expected, actual, fixture_file) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/rspec_fixtures/approval_handler.rb', line 8

def run(expected, actual, fixture_file)
  line = '_' * terminal_width

  say "!txtgrn!#{line}"
  if expected.empty?
    say actual
  else
    say "> Old (Fixture):"
    say expected
    say "!txtpur!#{line}"
    say "> New (Actual):"
    say actual
  end
  say "!txtgrn!#{line}"
  say "> Approve new fixture? (y/N): "
  
  if user_approves?
    say "!txtgrn!Approved"
    File.deep_write fixture_file, actual
    true
  else
    say "!txtred!Not Approved"
    false
  end
end