boxen 3.0.0.beta1 → 3.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.travis.yml +0 -1
- data/README.md +1 -1
- data/boxen.gemspec +13 -13
- data/lib/boxen/check.rb +39 -8
- data/lib/boxen/cli.rb +45 -19
- data/lib/boxen/config.rb +61 -43
- data/lib/boxen/flags.rb +282 -0
- data/lib/boxen/hook.rb +8 -15
- data/lib/boxen/hook/github_issue.rb +120 -0
- data/lib/boxen/hook/web.rb +56 -0
- data/lib/boxen/keychain.rb +1 -1
- data/lib/boxen/postflight/env.rb +1 -1
- data/lib/boxen/preflight.rb +7 -4
- data/lib/boxen/preflight/creds.rb +47 -8
- data/lib/boxen/preflight/identity.rb +0 -2
- data/lib/boxen/preflight/os.rb +6 -2
- data/lib/boxen/puppeteer.rb +121 -0
- data/lib/boxen/runner.rb +149 -0
- data/script/bootstrap +1 -1
- data/script/tests +0 -1
- data/test/boxen/test.rb +1 -1
- data/test/boxen_check_test.rb +55 -0
- data/test/boxen_cli_test.rb +31 -8
- data/test/boxen_config_test.rb +31 -1
- data/test/boxen_directories_test.rb +4 -4
- data/test/boxen_flags_test.rb +217 -0
- data/test/{postflight/boxen_postflight_github_issue_test.rb → boxen_hook_github_issue_test.rb} +82 -72
- data/test/{postflight/boxen_postflight_web_hook_test.rb → boxen_hook_web_test.rb} +11 -12
- data/test/{postflight/boxen_postflight_active_test.rb → boxen_postflight_active_test.rb} +3 -3
- data/test/{postflight/boxen_postflight_env_test.rb → boxen_postflight_env_test.rb} +0 -0
- data/test/boxen_preflight_creds_test.rb +177 -0
- data/test/{preflight/boxen_preflight_etc_my_cnf_test.rb → boxen_preflight_etc_my_cnf_test.rb} +1 -1
- data/test/{preflight/boxen_preflight_rvm_test.rb → boxen_preflight_rvm_test.rb} +1 -1
- data/test/boxen_puppeteer_test.rb +101 -0
- data/test/boxen_runner_test.rb +171 -0
- metadata +172 -251
- data/lib/boxen/command.rb +0 -142
- data/lib/boxen/command/help.rb +0 -40
- data/lib/boxen/command/preflight.rb +0 -38
- data/lib/boxen/command/project.rb +0 -49
- data/lib/boxen/command/project/install.rb +0 -33
- data/lib/boxen/command/run.rb +0 -199
- data/lib/boxen/command/service.rb +0 -61
- data/lib/boxen/command/service/disable.rb +0 -15
- data/lib/boxen/command/service/enable.rb +0 -15
- data/lib/boxen/command/service/restart.rb +0 -24
- data/lib/boxen/command/version.rb +0 -29
- data/lib/boxen/command_status.rb +0 -15
- data/lib/boxen/postflight/github_issue.rb +0 -124
- data/lib/boxen/postflight/hooks.rb +0 -16
- data/lib/boxen/postflight/web_hook.rb +0 -63
- data/lib/boxen/preflight/facts.rb +0 -36
- data/lib/boxen/preflight/homebrew.rb +0 -13
- data/lib/boxen/preflight/offline.rb +0 -33
- data/lib/boxen/preflight/update.rb +0 -109
- data/lib/boxen/util/logging.rb +0 -59
- data/lib/boxen/version.rb +0 -3
- data/lib/system_timer.rb +0 -13
- data/test/boxen_command_test.rb +0 -93
- data/test/boxen_hook_test.rb +0 -25
- data/test/command/help_test.rb +0 -49
- data/test/command/project/install_test.rb +0 -34
- data/test/command/project_test.rb +0 -32
- data/test/command/run_test.rb +0 -21
- data/test/command/service/disable_test.rb +0 -49
- data/test/command/service/enable_test.rb +0 -49
- data/test/command/service/restart_test.rb +0 -53
- data/test/command/service_test.rb +0 -55
- data/test/command/version_test.rb +0 -15
- data/test/preflight/boxen_preflight_creds_test.rb +0 -82
- data/test/preflight/boxen_preflight_homebrew_test.rb +0 -10
- data/test/system_timer.rb +0 -10
@@ -1,49 +0,0 @@
|
|
1
|
-
require "boxen/command/service/disable"
|
2
|
-
|
3
|
-
describe Boxen::Command::Service::Disable do
|
4
|
-
describe "given arguments" do
|
5
|
-
before do
|
6
|
-
@config = mock("config")
|
7
|
-
@single_c_thread = mock("service",
|
8
|
-
:name => "single_c_thread",
|
9
|
-
:disable => true)
|
10
|
-
|
11
|
-
Boxen::Service.stubs(:new).with("single_c_thread").returns(@single_c_thread)
|
12
|
-
end
|
13
|
-
|
14
|
-
it "should disable the service" do
|
15
|
-
stdout, _ = capture_io do
|
16
|
-
Boxen::Command::Service::Disable.new(@config, "single_c_thread").run
|
17
|
-
end
|
18
|
-
|
19
|
-
assert_equal stdout, "Disabling service: single_c_thread\n"
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
describe "given no arguments" do
|
24
|
-
before do
|
25
|
-
@config = mock("config")
|
26
|
-
@single_c_thread = mock("service",
|
27
|
-
:name => "single_c_thread",
|
28
|
-
:disable => true)
|
29
|
-
|
30
|
-
@many_pthreads = mock("service",
|
31
|
-
:name => "many_pthreads",
|
32
|
-
:disable => true)
|
33
|
-
|
34
|
-
Boxen::Service.stubs(:list).
|
35
|
-
returns([@single_c_thread, @many_pthreads])
|
36
|
-
end
|
37
|
-
|
38
|
-
it "should enable all services" do
|
39
|
-
stdout, _ = capture_io do
|
40
|
-
Boxen::Command::Service::Disable.new(@config).run
|
41
|
-
end
|
42
|
-
|
43
|
-
assert_equal stdout, <<-EOS
|
44
|
-
Disabling service: single_c_thread
|
45
|
-
Disabling service: many_pthreads
|
46
|
-
EOS
|
47
|
-
end
|
48
|
-
end
|
49
|
-
end
|
@@ -1,49 +0,0 @@
|
|
1
|
-
require "boxen/command/service/enable"
|
2
|
-
|
3
|
-
describe Boxen::Command::Service::Enable do
|
4
|
-
describe "given arguments" do
|
5
|
-
before do
|
6
|
-
@config = mock("config")
|
7
|
-
@single_c_thread = mock("service",
|
8
|
-
:name => "single_c_thread",
|
9
|
-
:enable => true)
|
10
|
-
|
11
|
-
Boxen::Service.stubs(:new).with("single_c_thread").returns(@single_c_thread)
|
12
|
-
end
|
13
|
-
|
14
|
-
it "should enable the service" do
|
15
|
-
stdout, _ = capture_io do
|
16
|
-
Boxen::Command::Service::Enable.new(@config, "single_c_thread").run
|
17
|
-
end
|
18
|
-
|
19
|
-
assert_equal stdout, "Enabling service: single_c_thread\n"
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
describe "given no arguments" do
|
24
|
-
before do
|
25
|
-
@config = mock("config")
|
26
|
-
@single_c_thread = mock("service",
|
27
|
-
:name => "single_c_thread",
|
28
|
-
:enable => true)
|
29
|
-
|
30
|
-
@many_pthreads = mock("service",
|
31
|
-
:name => "many_pthreads",
|
32
|
-
:enable => true)
|
33
|
-
|
34
|
-
Boxen::Service.stubs(:list).
|
35
|
-
returns([@single_c_thread, @many_pthreads])
|
36
|
-
end
|
37
|
-
|
38
|
-
it "should enable all services" do
|
39
|
-
stdout, _ = capture_io do
|
40
|
-
Boxen::Command::Service::Enable.new(@config).run
|
41
|
-
end
|
42
|
-
|
43
|
-
assert_equal stdout, <<-EOS
|
44
|
-
Enabling service: single_c_thread
|
45
|
-
Enabling service: many_pthreads
|
46
|
-
EOS
|
47
|
-
end
|
48
|
-
end
|
49
|
-
end
|
@@ -1,53 +0,0 @@
|
|
1
|
-
require "boxen/command/service/restart"
|
2
|
-
|
3
|
-
|
4
|
-
describe Boxen::Command::Service::Restart do
|
5
|
-
describe "with args" do
|
6
|
-
before do
|
7
|
-
@config = mock("config")
|
8
|
-
@single_c_thread = mock("service",
|
9
|
-
:name => "single_c_thread",
|
10
|
-
:enable => true,
|
11
|
-
:disable => true)
|
12
|
-
|
13
|
-
Boxen::Service.stubs(:new).with("single_c_thread").returns(@single_c_thread)
|
14
|
-
end
|
15
|
-
|
16
|
-
it "should restart the service" do
|
17
|
-
stdout, _ = capture_io do
|
18
|
-
Boxen::Command::Service::Restart.new(@config, "single_c_thread").run
|
19
|
-
end
|
20
|
-
|
21
|
-
assert_equal stdout, "Restarting service: single_c_thread\n"
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
describe "without args" do
|
26
|
-
before do
|
27
|
-
@config = mock("config")
|
28
|
-
@single_c_thread = mock("service",
|
29
|
-
:name => "single_c_thread",
|
30
|
-
:enable => true,
|
31
|
-
:disable => true)
|
32
|
-
|
33
|
-
@many_pthreads = mock("service",
|
34
|
-
:name => "many_pthreads",
|
35
|
-
:enable => true,
|
36
|
-
:disable => true)
|
37
|
-
|
38
|
-
Boxen::Service.stubs(:list_enabled).
|
39
|
-
returns([@single_c_thread, @many_pthreads])
|
40
|
-
end
|
41
|
-
|
42
|
-
it "should enable all services" do
|
43
|
-
stdout, _ = capture_io do
|
44
|
-
Boxen::Command::Service::Restart.new(@config).run
|
45
|
-
end
|
46
|
-
|
47
|
-
assert_equal stdout, <<-EOS
|
48
|
-
Restarting service: single_c_thread
|
49
|
-
Restarting service: many_pthreads
|
50
|
-
EOS
|
51
|
-
end
|
52
|
-
end
|
53
|
-
end
|
@@ -1,55 +0,0 @@
|
|
1
|
-
require "boxen/command/service"
|
2
|
-
|
3
|
-
describe Boxen::Command::Service do
|
4
|
-
before do
|
5
|
-
@config = Minitest::Mock.new
|
6
|
-
end
|
7
|
-
|
8
|
-
describe "#run" do
|
9
|
-
before do
|
10
|
-
Boxen::Service.stubs(:list).returns([
|
11
|
-
mock("service", :name => "foo"),
|
12
|
-
mock("service", :name => "bar")
|
13
|
-
])
|
14
|
-
end
|
15
|
-
|
16
|
-
it "displays the list of services we know about" do
|
17
|
-
stdout, _ = capture_io do
|
18
|
-
Boxen::Command::Service.new(@config).run
|
19
|
-
end
|
20
|
-
|
21
|
-
assert_equal stdout, <<-EOS
|
22
|
-
Boxen manages the following services:
|
23
|
-
|
24
|
-
foo
|
25
|
-
bar
|
26
|
-
EOS
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
describe "#services" do
|
31
|
-
before do
|
32
|
-
@foobar = mock()
|
33
|
-
end
|
34
|
-
|
35
|
-
describe "given args" do
|
36
|
-
before do
|
37
|
-
Boxen::Service.stubs(:new).with("foobar").returns(@foobar)
|
38
|
-
end
|
39
|
-
|
40
|
-
it "collects services based on args" do
|
41
|
-
assert_equal [@foobar], Boxen::Command::Service.new(@config, "foobar").services
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
describe "given no args" do
|
46
|
-
before do
|
47
|
-
Boxen::Service.stubs(:list).returns([@foobar])
|
48
|
-
end
|
49
|
-
|
50
|
-
it "collects all services" do
|
51
|
-
assert_equal [@foobar], Boxen::Command::Service.new(@config).services
|
52
|
-
end
|
53
|
-
end
|
54
|
-
end
|
55
|
-
end
|
@@ -1,15 +0,0 @@
|
|
1
|
-
require "boxen/command/version"
|
2
|
-
|
3
|
-
describe Boxen::Command::Version do
|
4
|
-
let(:instance) { Boxen::Command::Version.new(mock("config")) }
|
5
|
-
|
6
|
-
it "writes the boxen version to standard out, duh" do
|
7
|
-
instance.stubs(:version).returns("100.0.0")
|
8
|
-
|
9
|
-
stdout, _ = capture_io do
|
10
|
-
instance.run
|
11
|
-
end
|
12
|
-
|
13
|
-
assert_match "Boxen 100.0.0", stdout
|
14
|
-
end
|
15
|
-
end
|
@@ -1,82 +0,0 @@
|
|
1
|
-
require 'boxen/test'
|
2
|
-
require 'boxen/config'
|
3
|
-
require 'boxen/preflight/creds'
|
4
|
-
|
5
|
-
class BoxenPreflightCredsTest < Boxen::Test
|
6
|
-
def setup
|
7
|
-
@config = Boxen::Config.new do |c|
|
8
|
-
c.user = 'mojombo'
|
9
|
-
c.token = 'sekr3t!'
|
10
|
-
end
|
11
|
-
@command = stub 'command'
|
12
|
-
ENV.delete("BOXEN_GITHUB_LOGIN")
|
13
|
-
ENV.delete("BOXEN_GITHUB_PASSWORD")
|
14
|
-
end
|
15
|
-
|
16
|
-
def test_basic
|
17
|
-
preflight = Boxen::Preflight::Creds.new @config, @command
|
18
|
-
|
19
|
-
error = Octokit::Unauthorized.new
|
20
|
-
@config.api.stubs(:user).returns(error)
|
21
|
-
@config.stubs(:offline?).returns(false)
|
22
|
-
|
23
|
-
refute preflight.ok?
|
24
|
-
end
|
25
|
-
|
26
|
-
def test_basic_with_otp_challenge
|
27
|
-
preflight = Boxen::Preflight::Creds.new @config, @command
|
28
|
-
|
29
|
-
blank_opt = {:headers => {}}
|
30
|
-
good_otp = {:headers => {"X-GitHub-OTP" => "123456"}}
|
31
|
-
|
32
|
-
error = Octokit::OneTimePasswordRequired.new
|
33
|
-
error.stubs(:message).returns("OTP")
|
34
|
-
|
35
|
-
preflight.tmp_api.expects(:authorizations).with(blank_opt).raises(error)
|
36
|
-
preflight.tmp_api.expects(:authorizations).with(good_otp).returns([])
|
37
|
-
preflight.tmp_api.expects(:create_authorization).raises(error)
|
38
|
-
|
39
|
-
preflight.expects(:warn)
|
40
|
-
HighLine.any_instance.expects(:ask).returns("123456")
|
41
|
-
|
42
|
-
preflight.get_tokens
|
43
|
-
assert_equal "123456", preflight.otp
|
44
|
-
end
|
45
|
-
|
46
|
-
def test_fetch_login_and_password_when_nothing_is_given_in_env
|
47
|
-
# fetches login and password by asking
|
48
|
-
preflight = Boxen::Preflight::Creds.new @config, @command
|
49
|
-
HighLine.any_instance.expects(:ask).with("GitHub login: ").returns "l"
|
50
|
-
HighLine.any_instance.expects(:ask).with("GitHub password: ").returns "p"
|
51
|
-
preflight.send(:fetch_login_and_password)
|
52
|
-
|
53
|
-
assert_equal "l", @config.login
|
54
|
-
assert_equal "p", preflight.instance_variable_get(:@password)
|
55
|
-
end
|
56
|
-
|
57
|
-
def test_fetch_password_when_login_is_given_in_env
|
58
|
-
# fetches only password by asking
|
59
|
-
ENV["BOXEN_GITHUB_LOGIN"] = "l"
|
60
|
-
preflight = Boxen::Preflight::Creds.new @config, @command
|
61
|
-
preflight.expects(:warn)
|
62
|
-
HighLine.any_instance.expects(:ask).with("GitHub login: ").never
|
63
|
-
HighLine.any_instance.expects(:ask).with("GitHub password: ").returns "p"
|
64
|
-
preflight.send(:fetch_login_and_password)
|
65
|
-
|
66
|
-
assert_equal "l", @config.login
|
67
|
-
assert_equal "p", preflight.instance_variable_get(:@password)
|
68
|
-
end
|
69
|
-
|
70
|
-
def test_fetch_login_when_password_is_given_in_env
|
71
|
-
# fetches only login by asking
|
72
|
-
ENV["BOXEN_GITHUB_PASSWORD"] = "p"
|
73
|
-
preflight = Boxen::Preflight::Creds.new @config, @command
|
74
|
-
preflight.expects(:warn)
|
75
|
-
HighLine.any_instance.expects(:ask).with("GitHub login: ").returns "l"
|
76
|
-
HighLine.any_instance.expects(:ask).with("GitHub password: ").never
|
77
|
-
preflight.send(:fetch_login_and_password)
|
78
|
-
|
79
|
-
assert_equal "l", @config.login
|
80
|
-
assert_equal "p", preflight.instance_variable_get(:@password)
|
81
|
-
end
|
82
|
-
end
|
@@ -1,10 +0,0 @@
|
|
1
|
-
require 'boxen/test'
|
2
|
-
require 'boxen/preflight/homebrew'
|
3
|
-
|
4
|
-
class BoxenPreflightHomebrewTest < Boxen::Test
|
5
|
-
def test_directory_check
|
6
|
-
preflight = Boxen::Preflight::Homebrew.new(mock('config'), mock('command'))
|
7
|
-
File.expects(:exist?).with("/usr/local/Library/Homebrew").returns(false)
|
8
|
-
assert preflight.ok?
|
9
|
-
end
|
10
|
-
end
|
data/test/system_timer.rb
DELETED
@@ -1,10 +0,0 @@
|
|
1
|
-
# THIS IS SUCH HAX. Faraday helpfully reminds you to install
|
2
|
-
# `system_timer` if you're running Ruby 1.8, since Timeout can give
|
3
|
-
# unreliable results. We can't do this during first-time runs, since
|
4
|
-
# there's no C compiler available.
|
5
|
-
#
|
6
|
-
# To squash the message and stop confusing people, this shim just
|
7
|
-
# exposes Timeout as SystemTimer. I'm a bad person.
|
8
|
-
|
9
|
-
require "timeout"
|
10
|
-
SystemTimer = Timeout
|