discourse/spec/lib/onebox/engine/xkcd_spec.rb
David Taylor c9dab6fd08
DEV: Automatically require 'rails_helper' in all specs (#16077)
It's very easy to forget to add `require 'rails_helper'` at the top of every core/plugin spec file, and omissions can cause some very confusing/sporadic errors.

By setting this flag in `.rspec`, we can remove the need for `require 'rails_helper'` entirely.
2022-03-01 17:50:50 +00:00

28 lines
719 B
Ruby

# frozen_string_literal: true
describe Onebox::Engine::XkcdOnebox do
let(:link) { "https://xkcd.com/327/" }
let(:api_link) { "https://xkcd.com/327/info.0.json" }
let(:html) { described_class.new(link).to_html }
before do
stub_request(:get, api_link).to_return(status: 200, body: onebox_response("xkcd"))
end
it "has the comic's description" do
expect(html).to include("Her daughter is named Help")
end
it "has the comic's title" do
expect(html).to include("Exploits of a Mom")
end
it "has the permalink to the comic" do
expect(html).to include(link)
end
it "has the comic image" do
expect(html).to include("http://imgs.xkcd.com/comics/exploits_of_a_mom.png")
end
end