Project

General

Profile

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

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

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
    :interactive => false
24
  }
25
end
26

    
27
def hammer(context=nil)
28
  HammerCLI::MainCommand.new("", context || ctx)
29
end
30

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

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

    
52

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