Skip to content

Commit

Permalink
Use Bacon and work more on the Job tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
alloy committed Aug 6, 2012
1 parent 1907983 commit b2744fd
Show file tree
Hide file tree
Showing 24 changed files with 26 additions and 1,420 deletions.
6 changes: 4 additions & 2 deletions .kick
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
recipe :ignore
recipe :ruby

Kicker::Recipes::Ruby.runner_bin = 'bacon'

process do |files|
test_files = files.take_and_map do |file|
case file
when %r{^lib/kicker(\.rb|/validate\.rb|/growl\.rb)$}
["test/initialization_test.rb", ("test/filesystem_change_test.rb" if $1 == '.rb')]
["spec/initialization_spec.rb", ("spec/filesystem_change_spec.rb" if $1 == '.rb')]
when %r{^lib/kicker/(.+)\.rb$}
"test/#{$1}_test.rb"
"spec/#{$1}_spec.rb"
end
end

Expand Down
15 changes: 8 additions & 7 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,19 @@ GEM
activesupport (3.2.7)
i18n (~> 0.6)
multi_json (~> 1.0)
ffi (1.1.1)
bacon (1.1.0)
ffi (1.1.4)
i18n (0.6.0)
json (1.7.4)
listen (0.4.7)
rb-fchange (~> 0.0.5)
rb-fsevent (~> 0.9.1)
rb-inotify (~> 0.8.8)
metaclass (0.0.1)
mocha (0.12.1)
mocha (0.12.3)
metaclass (~> 0.0.1)
mocha-on-bacon (0.2.1)
mocha (>= 0.9.8)
multi_json (1.3.6)
rake (0.9.2.2)
rb-fchange (0.0.5)
Expand All @@ -30,18 +33,16 @@ GEM
ffi (>= 0.5.0)
rdoc (3.12)
json (~> 1.4)
terminal-notifier (1.2.0)
test-spec (0.10.0)
test-unit (2.5.1)
terminal-notifier (1.3.0)

PLATFORMS
ruby

DEPENDENCIES
activesupport
bacon
kicker!
mocha
mocha-on-bacon
rake
rdoc
test-spec
test-unit
10 changes: 5 additions & 5 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ rescue LoadError
require 'rake/rdoctask'
end

desc "Run tests"
task :test do
desc "Run specs"
task :spec do
# shuffle to ensure that tests are run in different order
files = FileList['test/**/*_test.rb'].map { |f| f[0,f.size-3] }.shuffle
sh "ruby -Ilib -I. -r '#{files.join("' -r '")}' -e ''"
files = FileList['spec/**/*_spec.rb'].shuffle
sh "bundle exec bacon #{files.map { |file| "'#{file}'" }.join(' ')}"
end

namespace :docs do
Expand All @@ -19,4 +19,4 @@ namespace :docs do
end
end

task :default => :test
task :default => :spec
4 changes: 2 additions & 2 deletions kicker.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ Gem::Specification.new do |s|
s.add_development_dependency("rake")
s.add_development_dependency("rdoc") # purely so it doesn't warn about deprecated rake task

s.add_development_dependency("bacon")
s.add_development_dependency("mocha")
s.add_development_dependency("test-unit")
s.add_development_dependency("test-spec")
s.add_development_dependency("mocha-on-bacon")
s.add_development_dependency("activesupport")
end

15 changes: 7 additions & 8 deletions lib/kicker/job.rb
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
class Kicker
class Job
def self.attr_with_default(name, &default)
def self.attr_with_default(name, merge_hash = false, &default)
# If `nil` this returns the `default`, unless explicitely set to `nil` by
# the user.
define_method(name) do
options = instance_eval(&default)
if instance_variable_get("@#{name}_assigned")
if assigned_options = instance_variable_get("@#{name}")
options.merge(assigned_options)
if assigned_value = instance_variable_get("@#{name}")
merge_hash ? instance_eval(&default).merge(assigned_value) : assigned_value
end
else
options
instance_eval(&default)
end
end
define_method("#{name}=") do |value|
Expand Down Expand Up @@ -42,11 +41,11 @@ def success?

# TODO default titles??

attr_with_default(:notify_before) do
{ :title => "Kicker: Executing", :message => command } unless Kicker.silent?
attr_with_default(:notify_before, true) do
{ :title => "Kicker: Executing", :message => command }
end

attr_with_default(:notify_after) do
attr_with_default(:notify_after, true) do
message = Kicker.silent? ? "" : output
if success?
{ :title => "Kicker: Success", :message => message }
Expand Down
165 changes: 0 additions & 165 deletions test/callback_chain_test.rb

This file was deleted.

38 changes: 0 additions & 38 deletions test/core_ext_test.rb

This file was deleted.

Loading

0 comments on commit b2744fd

Please sign in to comment.