Project

General

Profile

Download (1.5 KB) Statistics
| Branch: | Tag: | Revision:

hammer-cli-csv / test / csv_test_helper.rb @ 7b00acc6

1
require 'simplecov'
2
require 'pathname'
3
require 'stringio'
4
require 'tempfile'
5

    
6
SimpleCov.use_merging true
7
SimpleCov.start do
8
  command_name 'MiniTest'
9
  add_filter 'test'
10
end
11
SimpleCov.root Pathname.new(File.dirname(__FILE__) + "../../../")
12

    
13

    
14
require 'minitest/autorun'
15
require 'minitest/spec'
16
require "minitest-spec-context"
17
require "mocha/setup"
18

    
19
require 'hammer_cli'
20
require 'hammer_cli_foreman/commands'
21

    
22
HammerCLI::Settings.load_from_file 'test/config.yml'
23

    
24
require 'hammer_cli_csv'
25
require 'hammer_cli_foreman'
26
require 'hammer_cli_katello'
27

    
28
def ctx
29
  {
30
    :interactive => false,
31
    :username => 'admin',
32
    :password => 'changeme'
33
  }
34
end
35

    
36
def hammer(context=nil)
37
  HammerCLI::MainCommand.new("", context || ctx)
38
end
39

    
40
def capture
41
  old_stdout = $stdout
42
  old_stderr = $stderr
43
  $stdout = stdout = StringIO.new
44
  $stderr = stderr = StringIO.new
45
  yield
46
  [stdout.string, stderr.string]
47
ensure
48
  $stdout = old_stdout
49
  $stderr = old_stderr
50
end
51

    
52
def set_user(username, password='changeme')
53
  HammerCLI::Settings.load({
54
                             :_params => {
55
                               :username => username,
56
                               :password => password,
57
                               :interactive => false
58
                             }})
59
end
60

    
61

    
62
#require File.join(File.dirname(__FILE__), 'test_output_adapter')
63
require File.join(File.dirname(__FILE__), 'apipie_resource_mock')
64
require File.join(File.dirname(__FILE__), 'helpers/command')
65
require File.join(File.dirname(__FILE__), 'helpers/resource_disabled')