require 'spec_helper' describe BeanstalkApi::JobsController do context '#show' do context 'Authorized calls' do before(:each) do @mock_pool = double("BeanstalkPool") @mock_connection = double("BeanstalkConnection") controller.stub(:pool).and_return(@mock_pool) controller.stub(:connection).and_return(@mock_connection) controller.stub(:restrict_access) controller.stub(:beanstalk_running) end it "should render the json of the job if the job was found" do mock_job = double("Job") @mock_pool.should_receive(:peek_job).with('2888').and_return(mock_job) @mock_connection.should_receive(:job_stats).with('2888').and_return({ 'id' => '1' }) controller.should_receive(:format_job).with(mock_job).and_return({ '1' => 'hello' }) get :show, id: '2888', use_route: :beanstalk_api expect(response.body).to eq('{"job":{"1":"hello"},"statistics":{"id":"1"}}') end end end end