Module: KnifeTestHelper

Extended by:
RSpec::KnifeTestUtils
Included in:
KnifeTestBed
Defined in:
lib/test/knife-utils/helper.rb

Instance Method Summary collapse

Methods included from RSpec::KnifeTestUtils

command_setting, included, knife, run

Instance Method Details

#create_file(file_dir, file_name, data_to_write_file_path) ⇒ Object



29
30
31
32
33
34
35
36
37
# File 'lib/test/knife-utils/helper.rb', line 29

def create_file(file_dir, file_name, data_to_write_file_path)
  puts "Creating: #{file_name}"
  begin
    data_to_write = File.read(File.expand_path("#{data_to_write_file_path}", __FILE__))
    File.open("#{file_dir}/#{file_name}", "w") { |f| f.write(data_to_write) }
  rescue
    puts "Error while creating file - #{file_name}"
  end
end

#match_status(test_run_expect) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
# File 'lib/test/knife-utils/helper.rb', line 13

def match_status(test_run_expect)
  if "#{test_run_expect}" == "should fail"
    should_not have_outcome status: 0
  elsif "#{test_run_expect}" == "should succeed"
    should have_outcome status: 0
  elsif "#{test_run_expect}" == "should return empty list"
    should have_outcome status: 0
  else
    should have_outcome status: 0
  end
end

#match_stdout(test_run_expect) ⇒ Object



25
26
27
# File 'lib/test/knife-utils/helper.rb', line 25

def match_stdout(test_run_expect)
  should have_outcome stdout: test_run_expect
end

#temp_dirObject



9
10
11
# File 'lib/test/knife-utils/helper.rb', line 9

def temp_dir
  @_temp_dir ||= Dir.mktmpdir
end