Sha256: f9387485af66106d2377deb38cf4acf72a4f840e30c68258375a8a48695aa53a
Contents?: true
Size: 1.68 KB
Versions: 7
Compression:
Stored size: 1.68 KB
Contents
shared_examples 'a software agent' do |args| subject { described_class.new(args) } let(:agent_class) { described_class } it 'represents its agent name as the correct string, as a class' do expect(agent_class.agent_name) .to eq agent_class.to_s end it 'represents its agent name as the correct string, as an instance' do expect(subject.agent_name).to eq agent_class.to_s end describe '.agent_name' do it { expect(agent_class.agent_name).to be_a String } end describe '.queue_name' do it { expect(agent_class.queue_name).to respond_to :to_s } it 'is lowercase' do expect(agent_class.queue_name).to eq agent_class.queue_name.downcase end end describe '#agent_name' do it { expect(subject.agent_name).to be_a String } end describe '#enqueue' do let(:queue_name) { described_class.queue_name.to_s } it 'accepts options hash as first arg' do expect(agent_class.enqueue({})).to be true end it 'accepts options hash as second arg' do expect(agent_class.enqueue('my_queue', {})).to be true end it 'throws an error if too many args are given' do expect { agent_class.enqueue('my_queue', {}, :abc) } .to raise_error ArgumentError end it 'throws an error if second arg is not options hash' do expect { agent_class.enqueue(:my_queue, :abc) } .to raise_error ArgumentError end it 'enqueues a job' do expect { agent_class.enqueue(args) } .to change { Resque.size(queue_name) }.by(1) end it 'creates a new activity when it enqueues a job' do expect { agent_class.enqueue(args) } .to change { Krikri::Activity.count }.by(1) end end end
Version data entries
7 entries across 7 versions & 1 rubygems