Sha256: f5dc0fba92417a34014b1fd6bf1f7cf054cee345fab3c5f9fcc4b7ad2fe3a865

Contents?: true

Size: 1.91 KB

Versions: 21

Compression:

Stored size: 1.91 KB

Contents

Given /^beanstalkd is not running$/ do
  if @beanstalk
    Process.kill("KILL", @beanstalk.pid)
  end
end

Then /^I should see "([^"]*)" running$/ do |command|
  instance_variable_name = "@" + command.split("-")[1]
  pipe = instance_variable_get(instance_variable_name)
  pipe.should_not be_nil
  `ps -p #{pipe.pid}`.split("\n").size.should == 2
end

When /^I background run "flapjack-worker"$/ do
  @root    = Pathname.new(File.dirname(__FILE__)).parent.parent.expand_path
  bin_path = @root.join('bin')
  command  = "ruby -rubygems #{bin_path}/flapjack-worker 2>&1"

  @worker = spawn_daemon(command)

  sleep 1
end

Then /^I should see "([^"]*)" in the "([^"]*)" output$/ do |string, command|
  instance_variable_name = "@" + command.split("-")[1]
  pipe = instance_variable_get(instance_variable_name)
  pipe.should_not be_nil

  @output = read_until_timeout(pipe, 4)
  @output.grep(/#{string}/).size.should > 0
end

Then /^I should not see "([^"]*)" in the "([^"]*)" output$/ do |string, command|
  instance_variable_name = "@" + command.split("-")[1]
  pipe = instance_variable_get(instance_variable_name)
  pipe.should_not be_nil

  @output = read_until_timeout(pipe, 4)
  @output.grep(/#{string}/).size.should == 0
end

When /^beanstalkd is killed$/ do
  Given "beanstalkd is not running"
end

Then /^show me the output from "([^"]*)"$/ do |command|
  instance_variable_name = "@" + command.split("-")[1]
  pipe = instance_variable_get(instance_variable_name)
  pipe.should_not be_nil

  @output = read_until_timeout(pipe, 5)
  puts @output
end

When /^I sleep "(\d+)" seconds$/ do |time|
  sleep(time.to_i)
end

When /^I insert a check onto the beanstalk$/ do
  @queue = Beanstalk::Connection.new('localhost:11300', 'checks')


  pending # express the regexp above with the code you wish you had
end

Then /^I should see a job on the "([^"]*)" beanstalk queue$/ do |arg1|
  pending # express the regexp above with the code you wish you had
end

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
flapjack-0.6.23 features/steps/flapjack-worker_steps.rb