kicker 2.4.0 → 2.5.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/README.rdoc +3 -1
- data/lib/kicker.rb +3 -2
- data/lib/kicker/options.rb +5 -0
- data/lib/kicker/recipes.rb +6 -5
- data/lib/kicker/recipes/ruby.rb +4 -3
- data/lib/kicker/utils.rb +37 -8
- data/lib/kicker/version.rb +3 -0
- metadata +98 -155
- data/.kick +0 -37
- data/.travis.yml +0 -6
- data/Gemfile +0 -11
- data/Gemfile.lock +0 -34
- data/Rakefile +0 -37
- data/TODO.rdoc +0 -5
- data/VERSION +0 -1
- data/kicker.gemspec +0 -106
- data/test/callback_chain_test.rb +0 -165
- data/test/core_ext_test.rb +0 -38
- data/test/filesystem_change_test.rb +0 -104
- data/test/fixtures/a_file_thats_reloaded.rb +0 -2
- data/test/fsevents_test.rb +0 -35
- data/test/growl_test.rb +0 -87
- data/test/initialization_test.rb +0 -137
- data/test/log_status_helper_test.rb +0 -56
- data/test/options_test.rb +0 -80
- data/test/recipes/could_not_handle_file_test.rb +0 -21
- data/test/recipes/dot_kick_test.rb +0 -22
- data/test/recipes/execute_cli_command_test.rb +0 -37
- data/test/recipes/ignore_test.rb +0 -29
- data/test/recipes/jstest_test.rb +0 -31
- data/test/recipes/rails_test.rb +0 -186
- data/test/recipes/ruby_test.rb +0 -162
- data/test/recipes_test.rb +0 -67
- data/test/test_helper.rb +0 -29
- data/test/utils_test.rb +0 -193
data/test/recipes_test.rb
DELETED
@@ -1,67 +0,0 @@
|
|
1
|
-
require File.expand_path('../test_helper', __FILE__)
|
2
|
-
|
3
|
-
module ReloadDotKick; end
|
4
|
-
|
5
|
-
describe "Kicker::Recipes" do
|
6
|
-
before do
|
7
|
-
Kicker::Recipes.reset!
|
8
|
-
end
|
9
|
-
|
10
|
-
it "returns a list of recipes" do
|
11
|
-
recipe_files = Kicker::Recipes.recipe_files
|
12
|
-
if File.exist?(File.expand_path('~/.kick'))
|
13
|
-
Set.new(recipe_files).should == Set.new(Dir.glob('../../lib/kicker/recipes/**/*.rb'))
|
14
|
-
else
|
15
|
-
Dir.glob('../../lib/kicker/recipes/**/*.rb').each do |filename|
|
16
|
-
recipe_files.should.include?(filename)
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
it "returns a list of recipe names" do
|
22
|
-
expected = Set.new(%w(could_not_handle_file dot_kick execute_cli_command ignore jstest rails ruby).map { |n| n.to_sym })
|
23
|
-
actual = Kicker::Recipes.recipe_names
|
24
|
-
if File.exist?(File.expand_path('~/.kick'))
|
25
|
-
actual.should == expected
|
26
|
-
else
|
27
|
-
expected.each do |name|
|
28
|
-
actual.should.include?(name)
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
if File.exist?(File.expand_path('~/.kick'))
|
34
|
-
it "should add ~/.kick to the load path" do
|
35
|
-
$:.should.include File.expand_path('~/.kick')
|
36
|
-
end
|
37
|
-
else
|
38
|
-
puts "[!] ~/.kick does not exist, not testing the Kicker directory support."
|
39
|
-
end
|
40
|
-
|
41
|
-
it "should load a recipe" do
|
42
|
-
name = Kicker::Recipes.recipe_names.last
|
43
|
-
recipe name
|
44
|
-
end
|
45
|
-
|
46
|
-
it "does not break when a recipe is loaded twice" do
|
47
|
-
name = Kicker::Recipes.recipe_names.last
|
48
|
-
recipe name
|
49
|
-
recipe name
|
50
|
-
end
|
51
|
-
|
52
|
-
it "should define a recipe load callback" do
|
53
|
-
called = false
|
54
|
-
recipe('new_recipe') { called = true }
|
55
|
-
assert !called
|
56
|
-
recipe(:new_recipe)
|
57
|
-
assert called
|
58
|
-
end
|
59
|
-
|
60
|
-
it "should raise if a recipe does not exist" do
|
61
|
-
begin
|
62
|
-
recipe :foobar
|
63
|
-
rescue LoadError => e
|
64
|
-
e.message.should.start_with "Can't load recipe `foobar', it doesn't exist on disk."
|
65
|
-
end
|
66
|
-
end
|
67
|
-
end
|
data/test/test_helper.rb
DELETED
@@ -1,29 +0,0 @@
|
|
1
|
-
require 'rubygems'
|
2
|
-
require 'test/spec'
|
3
|
-
require 'mocha'
|
4
|
-
require 'set'
|
5
|
-
|
6
|
-
$:.unshift File.expand_path('../../lib', __FILE__)
|
7
|
-
require 'kicker'
|
8
|
-
|
9
|
-
class File
|
10
|
-
class << self
|
11
|
-
attr_accessor :existing_files
|
12
|
-
attr_accessor :use_original_exist
|
13
|
-
|
14
|
-
alias exist_without_stubbing? exist?
|
15
|
-
def exist?(file)
|
16
|
-
if use_original_exist
|
17
|
-
exist_without_stubbing?(file)
|
18
|
-
else
|
19
|
-
if existing_files
|
20
|
-
existing_files.include?(file)
|
21
|
-
else
|
22
|
-
raise "Please stub the files you want to exist by setting File.existing_files"
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
File.use_original_exist = true
|
data/test/utils_test.rb
DELETED
@@ -1,193 +0,0 @@
|
|
1
|
-
require File.expand_path('../test_helper', __FILE__)
|
2
|
-
|
3
|
-
class Kicker
|
4
|
-
module Utils
|
5
|
-
public :will_execute_command, :did_execute_command
|
6
|
-
end
|
7
|
-
end
|
8
|
-
|
9
|
-
describe "A Kicker instance, concerning its utility methods" do
|
10
|
-
before do
|
11
|
-
utils.stubs(:puts)
|
12
|
-
end
|
13
|
-
|
14
|
-
after do
|
15
|
-
Kicker.silent = false
|
16
|
-
Kicker::Growl.use = true
|
17
|
-
end
|
18
|
-
|
19
|
-
it "should print a log entry with timestamp" do
|
20
|
-
now = Time.now
|
21
|
-
Time.stubs(:now).returns(now)
|
22
|
-
|
23
|
-
utils.expects(:puts).with("#{now.strftime('%H:%M:%S')}.#{now.usec.to_s[0,2]} | the message")
|
24
|
-
utils.send(:log, 'the message')
|
25
|
-
end
|
26
|
-
|
27
|
-
it 'should print a log entry with no timestamp in quiet mode' do
|
28
|
-
before = Kicker.quiet
|
29
|
-
|
30
|
-
utils.expects(:puts).with('the message')
|
31
|
-
|
32
|
-
Kicker.quiet = true
|
33
|
-
utils.send(:log, 'the message')
|
34
|
-
|
35
|
-
Kicker.quiet = before
|
36
|
-
end
|
37
|
-
|
38
|
-
it "should log the output of the command indented by 2 spaces and whether or not the command succeeded" do
|
39
|
-
Kicker::Growl.use = false
|
40
|
-
|
41
|
-
utils.stubs(:`).returns("line 1\nline 2")
|
42
|
-
|
43
|
-
utils.stubs(:last_command_succeeded?).returns(true)
|
44
|
-
utils.expects(:log).with('Executing: ls')
|
45
|
-
utils.expects(:puts).with("\nline 1\nline 2\n\n")
|
46
|
-
utils.expects(:log).with('Success')
|
47
|
-
utils.execute('ls')
|
48
|
-
|
49
|
-
utils.stubs(:last_command_succeeded?).returns(false)
|
50
|
-
utils.stubs(:last_command_status).returns(123)
|
51
|
-
utils.expects(:log).with('Executing: ls')
|
52
|
-
utils.expects(:puts).with("\nline 1\nline 2\n\n")
|
53
|
-
utils.expects(:log).with('Failed (123)')
|
54
|
-
utils.execute('ls')
|
55
|
-
end
|
56
|
-
|
57
|
-
it "should growl a change occurred and the output" do
|
58
|
-
utils.stubs(:`).returns("line 1\nline 2")
|
59
|
-
utils.stubs(:last_command_succeeded?).returns(true)
|
60
|
-
utils.stubs(:log)
|
61
|
-
|
62
|
-
Kicker::Growl.expects(:change_occured).with { |status| status.command == 'ls' }
|
63
|
-
Kicker::Growl.expects(:result).with { |status| status.output == "line 1\nline 2" }
|
64
|
-
utils.execute('ls')
|
65
|
-
end
|
66
|
-
|
67
|
-
it "should not growl that a change occured in silent mode" do
|
68
|
-
Kicker.silent = true
|
69
|
-
utils.stubs(:did_execute_command)
|
70
|
-
|
71
|
-
utils.expects(:log)
|
72
|
-
Kicker::Growl.expects(:change_occured).never
|
73
|
-
utils.execute('ls')
|
74
|
-
end
|
75
|
-
|
76
|
-
it "should only log that is has succeeded in silent mode" do
|
77
|
-
Kicker.silent = true
|
78
|
-
Kicker::Growl.expects(:result).with { |status| status.output == "line 1\nline 2" }
|
79
|
-
|
80
|
-
status = Kicker::LogStatusHelper.new(nil, 'ls -l')
|
81
|
-
status.result("line 1\nline 2", true, 0)
|
82
|
-
|
83
|
-
utils.expects(:log).with("Success")
|
84
|
-
utils.did_execute_command(status)
|
85
|
-
end
|
86
|
-
|
87
|
-
it "should fully log that it has failed in silent mode" do
|
88
|
-
Kicker.silent = true
|
89
|
-
Kicker::Growl.expects(:result).with { |status| status.output == "line 1\nline 2" }
|
90
|
-
|
91
|
-
utils.expects(:puts).with("\nline 1\nline 2\n\n")
|
92
|
-
utils.expects(:log).with('Failed (123)')
|
93
|
-
|
94
|
-
status = Kicker::LogStatusHelper.new(nil, 'ls -l')
|
95
|
-
status.result("line 1\nline 2", false, 123)
|
96
|
-
|
97
|
-
utils.did_execute_command(status)
|
98
|
-
end
|
99
|
-
|
100
|
-
it "should clear the console before running a command" do
|
101
|
-
Kicker.clear_console = true
|
102
|
-
utils.expects(:puts).with("\e[H\e[2J")
|
103
|
-
|
104
|
-
Kicker::Growl.stubs(:change_occured)
|
105
|
-
status = Kicker::LogStatusHelper.new(nil, 'ls -l')
|
106
|
-
status.result("line 1\nline 2", false, 123)
|
107
|
-
|
108
|
-
utils.will_execute_command(status)
|
109
|
-
end
|
110
|
-
|
111
|
-
it "should store the last executed command" do
|
112
|
-
Kicker::Growl.use = false
|
113
|
-
utils.stubs(:log)
|
114
|
-
|
115
|
-
utils.execute('date')
|
116
|
-
utils.last_command.should == 'date'
|
117
|
-
end
|
118
|
-
|
119
|
-
it "should call the block given to execute and yield the log status helper with status success" do
|
120
|
-
Kicker.silent = true
|
121
|
-
Kicker::Growl.use = false
|
122
|
-
utils.stubs(:last_command_succeeded?).returns(true)
|
123
|
-
|
124
|
-
utils.expects(:log).with('Start!')
|
125
|
-
utils.expects(:log).with('Done!')
|
126
|
-
|
127
|
-
utils.execute('ls -l') do |status|
|
128
|
-
if status.after?
|
129
|
-
if status.success?
|
130
|
-
'Done!'
|
131
|
-
else
|
132
|
-
'Ohnoes!'
|
133
|
-
end
|
134
|
-
elsif status.before?
|
135
|
-
'Start!'
|
136
|
-
end
|
137
|
-
end
|
138
|
-
end
|
139
|
-
|
140
|
-
it "should call the block given to execute and yield the log status helper with status failed" do
|
141
|
-
Kicker.silent = true
|
142
|
-
Kicker::Growl.use = false
|
143
|
-
utils.stubs(:last_command_succeeded?).returns(false)
|
144
|
-
|
145
|
-
utils.expects(:log).with('Start!')
|
146
|
-
utils.expects(:log).with('Ohnoes!')
|
147
|
-
|
148
|
-
utils.execute('ls -l') do |status|
|
149
|
-
if status.after?
|
150
|
-
if status.success?
|
151
|
-
'Done!'
|
152
|
-
else
|
153
|
-
'Ohnoes!'
|
154
|
-
end
|
155
|
-
elsif status.before?
|
156
|
-
'Start!'
|
157
|
-
end
|
158
|
-
end
|
159
|
-
end
|
160
|
-
|
161
|
-
private
|
162
|
-
|
163
|
-
def utils
|
164
|
-
Kicker::Utils
|
165
|
-
end
|
166
|
-
end
|
167
|
-
|
168
|
-
describe "Kernel utility methods" do
|
169
|
-
before do
|
170
|
-
utils.stubs(:last_command_succeeded?).returns(true)
|
171
|
-
end
|
172
|
-
|
173
|
-
it "should forward log calls to the Kicker::Utils module" do
|
174
|
-
utils.expects(:log).with('the message')
|
175
|
-
log 'the message'
|
176
|
-
end
|
177
|
-
|
178
|
-
it "should forward execute calls to the Kicker::Utils module" do
|
179
|
-
utils.expects(:execute).with('ls')
|
180
|
-
execute 'ls'
|
181
|
-
end
|
182
|
-
|
183
|
-
it "should return the last_command" do
|
184
|
-
utils.stubs(:last_command).returns('abcde')
|
185
|
-
last_command.should == 'abcde'
|
186
|
-
end
|
187
|
-
|
188
|
-
private
|
189
|
-
|
190
|
-
def utils
|
191
|
-
Kicker::Utils
|
192
|
-
end
|
193
|
-
end
|