Project

General

Profile

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

hammer-cli-csv / test / csv_test_helper.rb @ bf81b9cf

1
require 'simplecov'
2
require 'pathname'
3

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

    
11

    
12
require 'minitest/autorun'
13
require 'minitest/spec'
14
require "minitest-spec-context"
15
require "mocha/setup"
16

    
17
require 'hammer_cli'
18
require 'hammer_cli_foreman/commands'
19

    
20
HammerCLI::Settings.load_from_file 'test/config.yml'
21

    
22
require 'hammer_cli_csv'
23
require 'hammer_cli_foreman'
24
require 'hammer_cli_katello'
25

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

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

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

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

    
59

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