Project

General

Profile

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

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

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_csv'
18
require 'hammer_cli_katello'
19
require 'hammer_cli_foreman'
20

    
21
def ctx
22
  {
23
    :adapter => :csv,
24
    :interactive => false
25
  }
26
end
27

    
28
def hammer
29
  HammerCLI::MainCommand.new("", ctx)
30
end
31

    
32
def capture
33
  old_stdout = $stdout
34
  old_stderr = $stderr
35
  $stdout = stdout = StringIO.new
36
  $stderr = stderr = StringIO.new
37
  yield
38
  [stdout.string, stderr.string]
39
ensure
40
  $stdout = old_stdout
41
  $stderr = old_stderr
42
end
43

    
44
def set_user(username, password='changeme')
45
  HammerCLI::Settings.load({
46
                             :_params => {
47
                               :username => username,
48
                               :password => password,
49
                               :interactive => false
50
                             }})
51
end
52

    
53

    
54
#require File.join(File.dirname(__FILE__), 'test_output_adapter')
55
require File.join(File.dirname(__FILE__), 'apipie_resource_mock')
56
require File.join(File.dirname(__FILE__), 'helpers/command')
57
require File.join(File.dirname(__FILE__), 'helpers/resource_disabled')