Skip to content

Instantly share code, notes, and snippets.

@jswright61
Created March 18, 2015 14:53
Show Gist options
  • Save jswright61/65e140b562b606d33f26 to your computer and use it in GitHub Desktop.
Save jswright61/65e140b562b606d33f26 to your computer and use it in GitHub Desktop.
Spec file uses wrong db
# spec/lib/trey/youtube/jobs/health_check.rb
require 'spec_helper'
describe 'Trey::Youtube::Jobs::HealthCheck' do
before(:all) do
DB[:youtube_channel_metrics_days].truncate
DB[:youtube_channel_metrics_days] << {channel_id: 'channel1', date: Date.parse('2014-06-02')}
DB[:youtube_channel_metrics_days] << {channel_id: 'channel2', date: Date.parse('2014-01-01')}
DB[:youtube_video_metrics_days].truncate
DB[:youtube_video_metrics_days] << {channel_id: 'channel1', date: Date.parse('2014-05-15'), video_id: 'vid1'}
DB[:youtube_video_metrics_days] << {channel_id: 'channel1', date: Date.parse('2013-05-18'), video_id: 'vid1'}
DB[:youtube_video_metrics_days] << {channel_id: 'channel2', date: Date.parse('2013-11-14'), video_id: 'vid1'}
DB[:youtube_video_metrics_days] << {channel_id: 'channel2', date: Date.parse('2015-01-07'), video_id: 'vid2'}
DB[:youtube_video_metrics_days] << {channel_id: 'channel2', date: Date.parse('2015-01-11'), video_id: 'vid2'}
end
after(:all) do
# DB[:youtube_channel_metrics_days].truncate
# DB[:youtube_video_metrics_days].truncate
end
describe '#perform' do
it 'should return valid healthcheck data for each channel and video' do
Trey::Youtube::Jobs::HealthCheck.perform.should eq({
"channel1" => (Date.today - 3.days).to_s,
"channel2" => (Date.today - 3.days).to_s
})
# data returned is from my development db, not test db.
# DB statements in before affect the test db
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment