forked from eliotsykes/rspec-rails-examples
-
Notifications
You must be signed in to change notification settings - Fork 0
/
headline_scraper_job_spec.rb
38 lines (26 loc) · 986 Bytes
/
headline_scraper_job_spec.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
require 'rails_helper'
RSpec.describe HeadlineScraperJob, :type => :job do
it "emails headlines scraped from given URL" do
url_to_scrape = "https://eliotsykes.github.io/rspec-rails-examples/"
recipient_email = "[email protected]"
assert_performed_with(
job: HeadlineScraperJob,
args: [{url: url_to_scrape, recipient: recipient_email}],
queue: 'default'
) do
VCR.use_cassette("news_page") do
HeadlineScraperJob.perform_later url: url_to_scrape, recipient: recipient_email
end
end
open_email recipient_email, with_subject: "Today's Headlines"
expected_headlines = [
# Original headline edited to prove VCR is serving scraped page.
"Man Bites Dog (served by VCR)",
"Dog Presses Charges",
"Cat Dismissed as Unreliable Witness"
]
expected_headlines.each do |expected_headline|
expect(current_email).to have_body_text expected_headline
end
end
end