boxen 2.9.0 → 3.0.0.beta1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (69) hide show
  1. data/boxen.gemspec +12 -12
  2. data/lib/boxen/check.rb +8 -39
  3. data/lib/boxen/cli.rb +19 -45
  4. data/lib/boxen/command.rb +142 -0
  5. data/lib/boxen/command/help.rb +40 -0
  6. data/lib/boxen/command/preflight.rb +38 -0
  7. data/lib/boxen/command/project.rb +49 -0
  8. data/lib/boxen/command/project/install.rb +33 -0
  9. data/lib/boxen/command/run.rb +199 -0
  10. data/lib/boxen/command/service.rb +61 -0
  11. data/lib/boxen/command/service/disable.rb +15 -0
  12. data/lib/boxen/command/service/enable.rb +15 -0
  13. data/lib/boxen/command/service/restart.rb +24 -0
  14. data/lib/boxen/command/version.rb +29 -0
  15. data/lib/boxen/command_status.rb +15 -0
  16. data/lib/boxen/config.rb +43 -61
  17. data/lib/boxen/hook.rb +15 -8
  18. data/lib/boxen/keychain.rb +1 -1
  19. data/lib/boxen/postflight/env.rb +1 -1
  20. data/lib/boxen/postflight/github_issue.rb +124 -0
  21. data/lib/boxen/postflight/hooks.rb +16 -0
  22. data/lib/boxen/postflight/web_hook.rb +63 -0
  23. data/lib/boxen/preflight.rb +4 -7
  24. data/lib/boxen/preflight/creds.rb +8 -47
  25. data/lib/boxen/preflight/facts.rb +36 -0
  26. data/lib/boxen/preflight/homebrew.rb +13 -0
  27. data/lib/boxen/preflight/identity.rb +2 -0
  28. data/lib/boxen/preflight/offline.rb +33 -0
  29. data/lib/boxen/preflight/os.rb +1 -1
  30. data/lib/boxen/preflight/update.rb +109 -0
  31. data/lib/boxen/util/logging.rb +59 -0
  32. data/lib/boxen/version.rb +3 -0
  33. data/script/bootstrap +1 -1
  34. data/script/tests +1 -0
  35. data/test/boxen/test.rb +1 -1
  36. data/test/boxen_cli_test.rb +8 -31
  37. data/test/boxen_command_test.rb +93 -0
  38. data/test/boxen_config_test.rb +1 -31
  39. data/test/boxen_directories_test.rb +4 -4
  40. data/test/boxen_hook_test.rb +25 -0
  41. data/test/command/help_test.rb +49 -0
  42. data/test/command/project/install_test.rb +34 -0
  43. data/test/command/project_test.rb +32 -0
  44. data/test/command/run_test.rb +21 -0
  45. data/test/command/service/disable_test.rb +49 -0
  46. data/test/command/service/enable_test.rb +49 -0
  47. data/test/command/service/restart_test.rb +53 -0
  48. data/test/command/service_test.rb +55 -0
  49. data/test/command/version_test.rb +15 -0
  50. data/test/{boxen_postflight_active_test.rb → postflight/boxen_postflight_active_test.rb} +3 -3
  51. data/test/{boxen_postflight_env_test.rb → postflight/boxen_postflight_env_test.rb} +0 -0
  52. data/test/{boxen_hook_github_issue_test.rb → postflight/boxen_postflight_github_issue_test.rb} +72 -82
  53. data/test/{boxen_hook_web_test.rb → postflight/boxen_postflight_web_hook_test.rb} +12 -11
  54. data/test/preflight/boxen_preflight_creds_test.rb +82 -0
  55. data/test/{boxen_preflight_etc_my_cnf_test.rb → preflight/boxen_preflight_etc_my_cnf_test.rb} +1 -1
  56. data/test/preflight/boxen_preflight_homebrew_test.rb +10 -0
  57. data/test/{boxen_preflight_rvm_test.rb → preflight/boxen_preflight_rvm_test.rb} +1 -1
  58. metadata +247 -171
  59. checksums.yaml +0 -7
  60. data/lib/boxen/flags.rb +0 -282
  61. data/lib/boxen/hook/github_issue.rb +0 -120
  62. data/lib/boxen/hook/web.rb +0 -56
  63. data/lib/boxen/puppeteer.rb +0 -121
  64. data/lib/boxen/runner.rb +0 -149
  65. data/test/boxen_check_test.rb +0 -55
  66. data/test/boxen_flags_test.rb +0 -217
  67. data/test/boxen_preflight_creds_test.rb +0 -177
  68. data/test/boxen_puppeteer_test.rb +0 -101
  69. data/test/boxen_runner_test.rb +0 -171
@@ -0,0 +1,49 @@
1
+ require "boxen/command/help"
2
+
3
+ class FooBar
4
+ def self.detailed_help
5
+ "okay fine I'll help you"
6
+ end
7
+
8
+ def self.help
9
+ "help yourself"
10
+ end
11
+ end
12
+
13
+ class BarBaz
14
+ def self.help
15
+ "no you"
16
+ end
17
+ end
18
+
19
+ describe Boxen::Command::Help do
20
+ before do
21
+ @config = mock("config")
22
+
23
+ Boxen::Command.reset!
24
+ Boxen::Command.register :foo_bar, FooBar
25
+ Boxen::Command.register :bar_baz, BarBaz
26
+ Boxen::Command.register :help, Boxen::Command::Help
27
+ end
28
+
29
+ after do
30
+ Boxen::Command.reset!
31
+ end
32
+
33
+ it "can write help for all commands" do
34
+ stdout, _ = capture_io do
35
+ Boxen::Command.invoke(:help, @config)
36
+ end
37
+
38
+ assert_match " foo_bar help yourself", stdout
39
+ assert_match " bar_baz no you", stdout
40
+ end
41
+
42
+ it "can write detailed help for a single command" do
43
+ stdout, _ = capture_io do
44
+ Boxen::Command.invoke(:help, @config, "foo_bar")
45
+ end
46
+
47
+ assert_match "okay fine I'll help you", stdout
48
+ end
49
+ end
@@ -0,0 +1,34 @@
1
+ require "boxen/command/project/install"
2
+ require "tmpdir"
3
+
4
+ describe Boxen::Command::Project::Install do
5
+ before do
6
+ @config = mock("config")
7
+ end
8
+
9
+ describe "#run" do
10
+ before do
11
+ Boxen::Command.expects(:invoke).with('run', @config)
12
+ end
13
+
14
+ it "installs a single project" do
15
+ Dir.mktmpdir { |dir|
16
+ @config.stubs(:repodir).returns(dir)
17
+ Boxen::Command::Project::Install.new(@config, 'awesome-project').run
18
+
19
+ projects = File.read("#{dir}/.projects")
20
+ assert_equal projects, "awesome-project"
21
+ }
22
+ end
23
+
24
+ it "installs multiple projects" do
25
+ Dir.mktmpdir { |dir|
26
+ @config.stubs(:repodir).returns(dir)
27
+ Boxen::Command::Project::Install.new(@config, 'awesome-project', 'better-project').run
28
+
29
+ projects = File.read("#{dir}/.projects")
30
+ assert_equal projects, "awesome-project,better-project"
31
+ }
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,32 @@
1
+ require "boxen/command/project"
2
+
3
+ describe Boxen::Command::Project do
4
+ before do
5
+ @config = mock("config")
6
+ end
7
+
8
+ describe "#run" do
9
+ before do
10
+ @config.stubs(:projects).returns([
11
+ mock("project-a", :name => "puppet-boxen"),
12
+ mock("project-b", :name => "puppet-ruby")
13
+ ])
14
+ end
15
+
16
+ it "displays the projects we know about" do
17
+ stdout, _ = capture_io do
18
+ Boxen::Command::Project.new(@config).run
19
+ end
20
+
21
+ assert_equal stdout, <<-EOS
22
+ Boxen knows about the following projects:
23
+
24
+ puppet-boxen
25
+ puppet-ruby
26
+
27
+ You can install any of them by running \"boxen project:install <project>\"
28
+
29
+ EOS
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,21 @@
1
+ require "boxen/command/run"
2
+
3
+ describe Boxen::Command::Run do
4
+ before do
5
+ @config = mock("config")
6
+ end
7
+
8
+ it "should enable puppet reports" do
9
+ command = Boxen::Command::Run.new(@config, "--report")
10
+ assert command.report?
11
+ end
12
+ it "should enable puppet profiling" do
13
+ command = Boxen::Command::Run.new(@config, "--profile")
14
+ assert command.profile?
15
+ end
16
+
17
+ it "should enable puppet's future parser" do
18
+ command = Boxen::Command::Run.new(@config, "--future-parser")
19
+ assert command.future_parser?
20
+ end
21
+ end
@@ -0,0 +1,49 @@
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
@@ -0,0 +1,49 @@
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
@@ -0,0 +1,53 @@
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
@@ -0,0 +1,55 @@
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
@@ -0,0 +1,15 @@
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
@@ -3,7 +3,7 @@ require "boxen/postflight"
3
3
 
4
4
  class BoxenPostflightActiveTest < Boxen::Test
5
5
  def setup
6
- @check = Boxen::Postflight::Active.new :config
6
+ @check = Boxen::Postflight::Active.new :config, :command
7
7
  end
8
8
 
9
9
  def test_ok?
@@ -18,9 +18,9 @@ class BoxenPostflightActiveTest < Boxen::Test
18
18
 
19
19
  def test_run
20
20
  config = stub :envfile => "foo"
21
- @check = Boxen::Postflight::Active.new config
21
+ @check = Boxen::Postflight::Active.new config, :command
22
22
 
23
- stdout, stderr = capture_io do
23
+ _, stderr = capture_io do
24
24
  @check.run
25
25
  end
26
26
 
@@ -1,57 +1,54 @@
1
- require "boxen/test"
2
- require "boxen/hook/github_issue"
1
+ require 'boxen/test'
2
+ require 'boxen/postflight'
3
+ require 'boxen/postflight/github_issue'
3
4
 
4
5
  class Boxen::Config
5
6
  attr_writer :api
6
7
  end
7
8
 
8
- class BoxenHookGitHubIssueTest < Boxen::Test
9
+ class Boxen::Postflight::GithubIssue < Boxen::Postflight
10
+ attr_writer :checkout
11
+ end
12
+
13
+ class BoxenPostflightGithubIssueTest < Boxen::Test
9
14
  def setup
10
15
  @config = Boxen::Config.new
11
16
  @checkout = Boxen::Checkout.new(@config)
12
- @puppet = mock 'puppeteer'
13
- @result = stub 'result', :success? => true
14
- @hook = Boxen::Hook::GitHubIssue.new @config, @checkout, @puppet, @result
17
+ @command = stub 'command', :success? => true
18
+ @check = Boxen::Postflight::GithubIssue.new @config, @command
19
+ @check.checkout = @checkout
15
20
  end
16
21
 
17
22
  def test_enabled
18
23
  original = ENV['BOXEN_ISSUES_ENABLED']
19
24
 
20
25
  ENV['BOXEN_ISSUES_ENABLED'] = nil
21
- refute @hook.enabled?
26
+ refute @check.enabled?
22
27
 
23
28
  ENV['BOXEN_ISSUES_ENABLED'] = 'duh'
24
- assert @hook.enabled?
29
+ assert @check.enabled?
25
30
 
26
31
  ENV['BOXEN_ISSUES_ENABLED'] = original
27
32
  end
28
33
 
29
- def test_perform
30
- @hook.stubs(:enabled?).returns(false)
31
- @config.stubs(:stealth?).returns(true)
32
- @config.stubs(:pretend?).returns(true)
34
+ def test_ok
35
+ @check.stubs(:enabled?).returns(false)
33
36
  @checkout.stubs(:master?).returns(false)
34
37
  @config.stubs(:login).returns(nil)
35
38
 
36
- refute @hook.perform?
37
-
38
- @hook.stubs(:enabled?).returns(true)
39
- refute @hook.perform?
39
+ assert @check.ok?
40
40
 
41
- @config.stubs(:stealth?).returns(false)
42
- refute @hook.perform?
43
-
44
- @config.stubs(:pretend?).returns(false)
45
- refute @hook.perform?
41
+ @check.stubs(:enabled?).returns(true)
42
+ assert @check.ok?
46
43
 
47
44
  @checkout.stubs(:master?).returns(true)
48
- refute @hook.perform?
45
+ assert @check.ok?
49
46
 
50
47
  @config.stubs(:login).returns('')
51
- refute @hook.perform?
48
+ assert @check.ok?
52
49
 
53
50
  @config.stubs(:login).returns('somelogin')
54
- assert @hook.perform?
51
+ refute @check.ok?
55
52
  end
56
53
 
57
54
  def test_compare_url
@@ -60,7 +57,7 @@ class BoxenHookGitHubIssueTest < Boxen::Test
60
57
  @checkout.expects(:sha).returns(sha)
61
58
 
62
59
  expected = "https://github.com/#{repo}/compare/#{sha}...master"
63
- assert_equal expected, @hook.compare_url
60
+ assert_equal expected, @check.compare_url
64
61
  end
65
62
 
66
63
  def test_compare_url_ghurl
@@ -70,108 +67,102 @@ class BoxenHookGitHubIssueTest < Boxen::Test
70
67
  @checkout.expects(:sha).returns(sha)
71
68
 
72
69
  expected = "https://git.foo.com/#{repo}/compare/#{sha}...master"
73
- assert_equal expected, @hook.compare_url
70
+ assert_equal expected, @check.compare_url
74
71
  end
75
72
 
76
73
  def test_hostname
77
- @hook.expects(:"`").with("hostname").returns "whatevs.local\n"
78
- assert_equal "whatevs.local", @hook.hostname
74
+ Socket.expects(:gethostname).returns("whatevs.local")
75
+ assert_equal "whatevs.local", @check.hostname
79
76
  end
80
77
 
81
78
  def test_initialize
82
- hook = Boxen::Hook::GitHubIssue.new :config, :checkout, :puppet, :result
83
- assert_equal :config, hook.config
84
- assert_equal :checkout, hook.checkout
85
- assert_equal :puppet, hook.puppet
86
- assert_equal :result, hook.result
79
+ check = Boxen::Postflight::GithubIssue.new :config, :command
80
+ assert_equal :config, check.config
81
+ assert_equal :command, check.command
87
82
  end
88
83
 
89
84
  def test_os
90
- @hook.expects(:"`").with("sw_vers -productVersion").returns "11.1.1\n"
91
- assert_equal "11.1.1", @hook.os
85
+ @check.expects(:"`").with("sw_vers -productVersion").returns "11.1.1\n"
86
+ assert_equal "11.1.1", @check.os
92
87
  end
93
88
 
94
89
  def test_shell
95
90
  val = ENV['SHELL']
96
91
 
97
92
  ENV['SHELL'] = '/bin/crush'
98
- assert_equal "/bin/crush", @hook.shell
93
+ assert_equal "/bin/crush", @check.shell
99
94
 
100
95
  ENV['SHELL'] = val
101
96
  end
102
97
 
103
98
  def test_record_failure
104
- @hook.stubs(:issues?).returns(true)
99
+ @check.stubs(:issues?).returns(true)
105
100
 
106
101
  details = 'Everything went wrong.'
107
- @hook.stubs(:failure_details).returns(details)
102
+ @check.stubs(:failure_details).returns(details)
108
103
 
109
104
  @config.reponame = repo = 'some/repo'
110
105
  @config.user = user = 'hapless'
111
106
 
112
- @hook.failure_label = label = 'boom'
107
+ @check.failure_label = label = 'boom'
113
108
 
114
109
  @config.api = api = mock('api')
115
110
  api.expects(:create_issue).with(repo, "Failed for #{user}", details, :labels => [label])
116
111
 
117
- @hook.record_failure
112
+ @check.record_failure
118
113
  end
119
114
 
120
115
  def test_record_failure_no_issues
121
- @hook.stubs(:issues?).returns(false)
116
+ @check.stubs(:issues?).returns(false)
122
117
 
123
118
  @config.api = api = mock('api')
124
119
  api.expects(:create_issue).never
125
120
 
126
- @hook.record_failure
121
+ @check.record_failure
127
122
  end
128
123
 
129
124
  def test_failure_label
130
125
  default = 'failure'
131
- assert_equal default, @hook.failure_label
126
+ assert_equal default, @check.failure_label
132
127
 
133
- @hook.failure_label = label = 'oops'
134
- assert_equal label, @hook.failure_label
128
+ @check.failure_label = label = 'oops'
129
+ assert_equal label, @check.failure_label
135
130
 
136
- @hook.failure_label = nil
137
- assert_equal default, @hook.failure_label
131
+ @check.failure_label = nil
132
+ assert_equal default, @check.failure_label
138
133
  end
139
134
 
140
135
  def test_ongoing_label
141
136
  default = 'ongoing'
142
- assert_equal default, @hook.ongoing_label
137
+ assert_equal default, @check.ongoing_label
143
138
 
144
- @hook.ongoing_label = label = 'checkit'
145
- assert_equal label, @hook.ongoing_label
139
+ @check.ongoing_label = label = 'checkit'
140
+ assert_equal label, @check.ongoing_label
146
141
 
147
- @hook.ongoing_label = nil
148
- assert_equal default, @hook.ongoing_label
142
+ @check.ongoing_label = nil
143
+ assert_equal default, @check.ongoing_label
149
144
  end
150
145
 
151
146
  def test_failure_details
152
147
  sha = 'decafbad'
153
148
  @checkout.stubs(:sha).returns(sha)
154
149
  hostname = 'cools.local'
155
- @hook.stubs(:hostname).returns(hostname)
150
+ @check.stubs(:hostname).returns(hostname)
156
151
  shell = '/bin/ksh'
157
- @hook.stubs(:shell).returns(shell)
152
+ @check.stubs(:shell).returns(shell)
158
153
  os = '11.1.1'
159
- @hook.stubs(:os).returns(os)
154
+ @check.stubs(:os).returns(os)
160
155
  log = "so\nmany\nthings\nto\nreport"
161
- @hook.stubs(:log).returns(log)
156
+ @check.stubs(:logfile).returns(log)
162
157
 
163
- @config.reponame = repo = 'some/repo'
164
- compare = @hook.compare_url
158
+ @config.reponame = 'some/repo'
159
+ compare = @check.compare_url
165
160
  changes = 'so many changes'
166
161
  @checkout.stubs(:changes).returns(changes)
167
162
 
168
- commands = %w[/path/to/puppet apply stuff_and_things]
169
- @puppet.stubs(:command).returns(commands)
170
- command = commands.join(' ')
171
-
172
163
  @config.logfile = logfile = '/path/to/logfile.txt'
173
164
 
174
- details = @hook.failure_details
165
+ details = @check.failure_details
175
166
 
176
167
  assert_match sha, details
177
168
  assert_match hostname, details
@@ -179,18 +170,17 @@ class BoxenHookGitHubIssueTest < Boxen::Test
179
170
  assert_match os, details
180
171
  assert_match compare, details
181
172
  assert_match changes, details
182
- assert_match command, details
183
173
  assert_match logfile, details
184
174
  assert_match log, details
185
175
  end
186
176
 
187
- def test_log
177
+ def test_logfile
188
178
  @config.logfile = logfile = '/path/to/logfile.txt'
189
179
 
190
180
  log = 'a bunch of log data'
191
181
  File.expects(:read).with(logfile).returns(log)
192
182
 
193
- assert_equal log, @hook.log
183
+ assert_equal log, @check.logfile
194
184
  end
195
185
 
196
186
 
@@ -202,12 +192,12 @@ class BoxenHookGitHubIssueTest < Boxen::Test
202
192
  Label = Struct.new(:name)
203
193
 
204
194
  def test_close_failures
205
- @hook.stubs(:issues?).returns(true)
195
+ @check.stubs(:issues?).returns(true)
206
196
 
207
197
  @config.reponame = repo = 'some/repo'
208
198
 
209
199
  issues = Array.new(3) { |i| Issue.new(i*2 + 2) }
210
- @hook.stubs(:failures).returns(issues)
200
+ @check.stubs(:failures).returns(issues)
211
201
 
212
202
  sha = 'decafbad'
213
203
  @checkout.stubs(:sha).returns(sha)
@@ -218,29 +208,29 @@ class BoxenHookGitHubIssueTest < Boxen::Test
218
208
  api.expects(:close_issue).with(repo, issue.number)
219
209
  end
220
210
 
221
- @hook.close_failures
211
+ @check.close_failures
222
212
  end
223
213
 
224
214
  def test_close_failures_no_issues
225
- @hook.stubs(:issues?).returns(false)
215
+ @check.stubs(:issues?).returns(false)
226
216
 
227
- @hook.expects(:failures).never
217
+ @check.expects(:failures).never
228
218
 
229
219
  @config.api = api = mock('api')
230
220
  api.expects(:add_comment).never
231
221
  api.expects(:close_issue).never
232
222
 
233
- @hook.close_failures
223
+ @check.close_failures
234
224
  end
235
225
 
236
226
  def test_failures
237
- @hook.stubs(:issues?).returns(true)
227
+ @check.stubs(:issues?).returns(true)
238
228
 
239
229
  @config.reponame = repo = 'some/repo'
240
230
  @config.login = user = 'hapless'
241
231
 
242
- @hook.failure_label = fail_label = 'ouch'
243
- @hook.ongoing_label = goon_label = 'goon'
232
+ @check.failure_label = fail_label = 'ouch'
233
+ @check.ongoing_label = goon_label = 'goon'
244
234
 
245
235
  fail_l = Label.new(fail_label)
246
236
  goon_l = Label.new(goon_label)
@@ -257,16 +247,16 @@ class BoxenHookGitHubIssueTest < Boxen::Test
257
247
  @config.api = api = mock('api')
258
248
  api.expects(:list_issues).with(repo, :state => 'open', :labels => fail_label, :creator => user).returns(issues)
259
249
 
260
- assert_equal issues.values_at(0,1,3), @hook.failures
250
+ assert_equal issues.values_at(0,1,3), @check.failures
261
251
  end
262
252
 
263
253
  def test_failures_no_issues
264
- @hook.stubs(:issues?).returns(false)
254
+ @check.stubs(:issues?).returns(false)
265
255
 
266
256
  @config.api = api = mock('api')
267
257
  api.expects(:list_issues).never
268
258
 
269
- assert_equal [], @hook.failures
259
+ assert_equal [], @check.failures
270
260
  end
271
261
 
272
262
  RepoInfo = Struct.new(:has_issues)
@@ -277,18 +267,18 @@ class BoxenHookGitHubIssueTest < Boxen::Test
277
267
 
278
268
  @config.api = api = mock('api')
279
269
  api.stubs(:repository).with(repo).returns(repo_info)
280
- assert @hook.issues?
270
+ assert @check.issues?
281
271
 
282
272
  repo_info = RepoInfo.new(false)
283
273
  api.stubs(:repository).with(repo).returns(repo_info)
284
- refute @hook.issues?
274
+ refute @check.issues?
285
275
 
286
276
  @config.stubs(:reponame) # to ensure the returned value is nil
287
277
  api.stubs(:repository).returns(RepoInfo.new(true))
288
- refute @hook.issues?
278
+ refute @check.issues?
289
279
 
290
280
  @config.stubs(:reponame).returns('boxen/our-boxen') # our main public repo
291
281
  api.stubs(:repository).returns(RepoInfo.new(true))
292
- refute @hook.issues?
282
+ refute @check.issues?
293
283
  end
294
284
  end