forked from drnic/rubigen
/
test_rubigen_cli.rb
71 lines (59 loc) · 1.98 KB
/
test_rubigen_cli.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
require File.dirname(__FILE__) + "/test_generator_helper"
require 'rubigen/cli'
class TestRubigenCli < Test::Unit::TestCase
include RubiGen::GeneratorTestHelper
attr_reader :stdout
context "run executable with scope 'rubygems'" do
setup do
bare_setup
Rubigen::CLI.new.execute(@stdout_io = StringIO.new,
%w[rubygems component_generator name scope], :backtrace => true)
@stdout_io.rewind
@stdout = @stdout_io.read
end
should "create main generator manifest" do
assert_file_exists("scope_generators/name/name_generator.rb")
end
end
context "run executable with scope 'rubygems'" do
setup do
Rubigen::CLI.execute(@stdout_io = StringIO.new, %w[rubygems])
@stdout_io.rewind
@stdout = @stdout_io.read
end
should "display help" do
assert_match(/General Options/, stdout)
end
should "display installed generators for 'rubygems'" do
assert_match(/Installed Generators/, stdout)
assert_match(/application_generator/, stdout)
assert_match(/component_generator/, stdout)
end
end
context "run executable with multiple scopes 'rubygems' and 'something_else'" do
setup do
# rubigen rubygems,something_else a_generator
Rubigen::CLI.execute(@stdout_io = StringIO.new, ['rubygems,something_else'])
@stdout_io.rewind
@stdout = @stdout_io.read
end
should "display help" do
assert_match(/General Options/, stdout)
end
should "display installed generators for 'rubygems,something_else'" do
assert_match(/Installed Generators/, stdout)
assert_match(/application_generator/, stdout)
assert_match(/component_generator/, stdout)
end
end
context "run executable without any arguments" do
setup do
Rubigen::CLI.execute(@stdout_io = StringIO.new, %w[])
@stdout_io.rewind
@stdout = @stdout_io.read
end
should "display main usage" do
assert_match(/Usage:/, stdout)
end
end
end