require 'spec_helper'
require 'carto_gears_api/queue/generic_job'
require 'carto_gears_api/test_mail'

describe CartoGearsApi::Queue::GenericJob do
  describe '#perform' do
    it 'instantiates the class, and invokes the method with random parameters' do
      from = 'support@carto.com'
      to = 'backend@carto.com'
      subject = 'test email'
      CartoGearsApi::Mailers::TestMail.any_instance.should_receive(:test_mail).with(from, to, subject)
      CartoGearsApi::Queue::GenericJob.perform('CartoGearsApi::Mailers::TestMail', :test_mail, from, to, subject)
    end
  end
end

require 'spec_helper'
require 'carto_gears_api/queue/generic_job'
require 'carto_gears_api/test_mail'

describe CartoGearsApi::Queue::GenericJob do
  describe '#perform' do
    it 'instantiates the class, and invokes the method with random parameters' do
      from = 'support@carto.com'
      to = 'backend@carto.com'
      subject = 'test email'
      # CartoGearsApi::Mailers::TestMail.any_instance.should_receive(:test_mail).with(from, to, subject)
      Object.any_instance.should_receive(:test_mail).with(from, to, subject)
      CartoGearsApi::Queue::GenericJob.perform('CartoGearsApi::Mailers::TestMail', :test_mail, from, to, subject)
    end
  end
end

Fix Gears test for Rails 4 There is some interaction going on with reflected instantiations so even though the previous code worked in Rails 3, it doesn't now
Fix Gears test for Rails 4
There is some interaction going on with reflected instantiations
so even though the previous code worked in Rails 3, it doesn't now
