From f08b5d3aa7ee8d01de27067384e421cdadeb31d8 Mon Sep 17 00:00:00 2001 From: Vokhmin Alexey V Date: Fri, 18 Jan 2013 17:41:38 +0400 Subject: [PATCH] #794: update spec_helper, add specs for BuildListsPublishTaskManager --- .../build_lists_publish_task_manager_spec.rb | 41 +++++++++++++++++++ spec/spec_helper.rb | 9 +--- 2 files changed, 43 insertions(+), 7 deletions(-) create mode 100644 spec/lib/abf-worker/build_lists_publish_task_manager_spec.rb diff --git a/spec/lib/abf-worker/build_lists_publish_task_manager_spec.rb b/spec/lib/abf-worker/build_lists_publish_task_manager_spec.rb new file mode 100644 index 000000000..5a8c71451 --- /dev/null +++ b/spec/lib/abf-worker/build_lists_publish_task_manager_spec.rb @@ -0,0 +1,41 @@ +require 'spec_helper' + +describe AbfWorker::BuildListsPublishTaskManager do + before(:all) do + init_test_root + end + + subject { AbfWorker::BuildListsPublishTaskManager } + + describe 'when no items for publishing' do + before do + stub_redis + subject.new.run + end + + %w(RESIGN_REPOSITORIES + PROJECTS_FOR_CLEANUP + LOCKED_PROJECTS_FOR_CLEANUP + LOCKED_REPOSITORIES + LOCKED_REP_AND_PLATFORMS + LOCKED_BUILD_LISTS).each do |kind| + + it "ensure that no '#{kind.downcase.gsub('_', ' ')}'" do + @redis_instance.lrange(subject.const_get(kind), 0, -1).should be_empty + end + end + + %w(publish_worker_default publish_worker).each do |kind| + it "ensure that no tasks in '#{kind}' queue" do + @redis_instance.lrange(kind, 0, -1).should be_empty + end + end + + end + + + + after(:all) do + FileUtils.rm_rf(APP_CONFIG['root_path']) + end +end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 3792ded78..9d77f115a 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -60,17 +60,12 @@ def clear_test_root end def stub_redis - redis_instance = MockRedis.new - stub(Redis).new { redis_instance } + @redis_instance = MockRedis.new + stub(Redis).new { @redis_instance } end init_test_root -def stub_redis - redis_instance = MockRedis.new - stub(Redis).new { redis_instance } -end - def fill_project project %x(mkdir -p #{project.path} && cp -Rf #{Rails.root}/spec/tests.git/* #{project.path}) # maybe FIXME ? end