commander 5.0.0 → 6.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/spec/spec_helper.rb DELETED
@@ -1,89 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'rubygems'
4
- require 'stringio'
5
- require 'simplecov'
6
- SimpleCov.start do
7
- add_filter '/spec/'
8
- end
9
-
10
- # Unshift so that local files load instead of something in gems
11
- $LOAD_PATH.unshift "#{File.dirname(__FILE__)}/../lib"
12
-
13
- # This basically replicates the behavior of `require 'commander/import'`
14
- # but without adding an `at_exit` hook, which interferes with exit code
15
- require 'commander'
16
- require 'commander/methods'
17
-
18
- # Mock terminal IO streams so we can spec against them
19
- def mock_terminal
20
- @input = StringIO.new
21
- @output = StringIO.new
22
- HighLine.default_instance = HighLine.new(@input, @output)
23
- end
24
-
25
- # Stub Kernel.abort
26
- TestSystemExit = Class.new(RuntimeError)
27
- module Commander
28
- class Runner
29
- def abort(message)
30
- fail TestSystemExit, message
31
- end
32
- end
33
- end
34
-
35
- # Create test command for usage within several specs
36
-
37
- def create_test_command
38
- command :test do |c|
39
- c.syntax = 'test [options] <file>'
40
- c.description = 'test description'
41
- c.example 'description', 'command'
42
- c.example 'description 2', 'command 2'
43
- c.option '-v', '--verbose', 'verbose description'
44
- c.when_called do |args, _options|
45
- format('test %s', args.join)
46
- end
47
- end
48
- @command = command :test
49
- end
50
-
51
- # Create a new command runner
52
-
53
- def new_command_runner(*args, &block)
54
- Commander::Runner.instance_variable_set :@instance, Commander::Runner.new(args)
55
- program :name, 'test'
56
- program :version, '1.2.3'
57
- program :description, 'something'
58
- create_test_command
59
- yield if block
60
- Commander::Runner.instance
61
- end
62
-
63
- # Comply with how specs were previously written
64
-
65
- def command_runner
66
- Commander::Runner.instance
67
- end
68
-
69
- def run(*args)
70
- new_command_runner(*args) do
71
- program :help_formatter, Commander::HelpFormatter::Base
72
- yield if block_given?
73
- end.run!
74
- @output.string
75
- end
76
-
77
- RSpec.configure do |c|
78
- c.expect_with(:rspec) do |e|
79
- e.syntax = :expect
80
- end
81
-
82
- c.mock_with(:rspec) do |m|
83
- m.syntax = :expect
84
- end
85
-
86
- c.before(:each) do
87
- allow(Commander::UI).to receive(:enable_paging)
88
- end
89
- end
data/spec/ui_spec.rb DELETED
@@ -1,32 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'spec_helper'
4
-
5
- describe Commander::UI do
6
- include Commander::Methods
7
-
8
- describe '.replace_tokens' do
9
- it 'should replace tokens within a string, with hash values' do
10
- result = Commander::UI.replace_tokens 'Welcome :name, enjoy your :object', name: 'TJ', object: 'cookie'
11
- expect(result).to eq('Welcome TJ, enjoy your cookie')
12
- end
13
- end
14
-
15
- describe 'progress' do
16
- it 'should not die on an empty list' do
17
- exception = false
18
- begin
19
- progress([]) {}
20
- rescue StandardError
21
- exception = true
22
- end
23
- expect(exception).not_to be true
24
- end
25
- end
26
-
27
- describe '.available_editor' do
28
- it 'should not fail on available editors with shell arguments' do
29
- expect(Commander::UI.available_editor('sh -c')).to eq('sh -c')
30
- end
31
- end
32
- end