Skip to content

Instantly share code, notes, and snippets.

@laszpio
Created July 23, 2010 14:00
Show Gist options
  • Save laszpio/487467 to your computer and use it in GitHub Desktop.
Save laszpio/487467 to your computer and use it in GitHub Desktop.
require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
require "rake"
describe "Upload inventory to abe" do
before(:all) do
@rake = Rake::Application.new
Rake.application = @rake
Rake.application.rake_require "lib/tasks/cron/abe/upload_inventory"
Rake::Task.define_task(:environment)
end
after(:all) do
`ps -e -o pid,command | grep "[c]ron:abe:upload" | grep "[t]est" | awk '{print $1}' | xargs kill`
end
it "should run only 1 rake task at any given time" do
3.times { system("rake cron:abe:upload_inventory[1] RAILS_ENV=test") }
`ps -e -o pid,command | grep "[c]ron:abe:upload_inventory"`.split("\n").count.should eql 1
end
it "should raise error if batch count is not specified" do
lambda { @rake.invoke_task("cron:abe:upload_inventory") }.should raise_error ArgumentError, "Batch count missing"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment