From 6897bfbd366eb3a7c48fd72f0b8ddbfec7d79ad3 Mon Sep 17 00:00:00 2001 From: Tawan Sierek Date: Sat, 28 Nov 2015 21:16:19 +0100 Subject: [PATCH] Add active_job dependency --- Gemfile.lock | 18 +++++++++++++++++ .../queue_adapters/rails_eb_job_adapter.rb | 4 +++- rails-eb-job.gemspec | 1 + .../rails_eb_job_adapter_spec.rb | 20 +++++++++++++++---- spec/spec_helper.rb | 1 + 5 files changed, 39 insertions(+), 5 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 0e1dfe3..6421da4 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -7,6 +7,15 @@ PATH GEM remote: https://rubygems.org/ specs: + activejob (4.2.5) + activesupport (= 4.2.5) + globalid (>= 0.3.0) + activesupport (4.2.5) + i18n (~> 0.7) + json (~> 1.7, >= 1.7.7) + minitest (~> 5.1) + thread_safe (~> 0.3, >= 0.3.4) + tzinfo (~> 1.1) aws-sdk-core (2.1.30) jmespath (~> 1.0) byebug (5.0.0) @@ -18,8 +27,13 @@ GEM fuubar (2.0.0) rspec (~> 3.0) ruby-progressbar (~> 1.4) + globalid (0.3.6) + activesupport (>= 4.1.0) + i18n (0.7.0) jmespath (1.1.3) + json (1.8.3) method_source (0.8.2) + minitest (5.8.3) pry (0.10.3) coderay (~> 1.1.0) method_source (~> 0.8.1) @@ -42,11 +56,15 @@ GEM rspec-support (3.3.0) ruby-progressbar (1.7.5) slop (3.6.0) + thread_safe (0.3.5) + tzinfo (1.2.2) + thread_safe (~> 0.1) PLATFORMS ruby DEPENDENCIES + activejob (~> 4.2) bundler dotenv fuubar diff --git a/lib/active_job/queue_adapters/rails_eb_job_adapter.rb b/lib/active_job/queue_adapters/rails_eb_job_adapter.rb index 5c7d72d..dc7468a 100644 --- a/lib/active_job/queue_adapters/rails_eb_job_adapter.rb +++ b/lib/active_job/queue_adapters/rails_eb_job_adapter.rb @@ -1,7 +1,9 @@ module ActiveJob module QueueAdapters class RailsEbJobAdapter - + class << self + attr_writer :aws_client + end end end end diff --git a/rails-eb-job.gemspec b/rails-eb-job.gemspec index 8ee90b6..771f0be 100644 --- a/rails-eb-job.gemspec +++ b/rails-eb-job.gemspec @@ -20,6 +20,7 @@ Gem::Specification.new do |spec| spec.add_development_dependency 'pry-byebug' spec.add_development_dependency 'dotenv' spec.add_development_dependency 'fuubar' + spec.add_development_dependency 'activejob', '~> 4.2' spec.add_dependency 'aws-sdk-core', '~> 2' end diff --git a/spec/active_job/queue_adapters/rails_eb_job_adapter_spec.rb b/spec/active_job/queue_adapters/rails_eb_job_adapter_spec.rb index d3c882b..39a7871 100644 --- a/spec/active_job/queue_adapters/rails_eb_job_adapter_spec.rb +++ b/spec/active_job/queue_adapters/rails_eb_job_adapter_spec.rb @@ -1,15 +1,27 @@ require 'spec_helper' +require 'active_job' + +class TestJob < ActiveJob::Base + def perform(test_arg) + test_arg + end +end describe ActiveJob::QueueAdapters::RailsEbJobAdapter do + subject(:adapter) { ActiveJob::QueueAdapters::RailsEbJobAdapter } + let(:aws_client) { - Aws::SQS::Client.new(stub_responses: true, credentials: credentials) + Aws::SQS::Client.new(stub_responses: true) } + let(:job) { TestJob.new } before do - aws_client.stub_responses(:get_queue_url, { queue_url: queue_url }) + adapter.aws_client = aws_client end - it "enqueues jobs to Amazon Simple Queue Service queues" do - described_class.enqueue + describe ".enqueue" do + it "sends the serialized job as a message to an AWS SQS queue" do + + end end end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index b75bac8..47dae5a 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -3,6 +3,7 @@ require 'pry-byebug' require 'rails_eb_job' + require 'dotenv' Dotenv.load