mirror of
https://github.com/discourse/discourse.git
synced 2024-11-24 10:02:33 +08:00
c9dab6fd08
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.
56 lines
1.5 KiB
Ruby
56 lines
1.5 KiB
Ruby
# frozen_string_literal: true
|
|
|
|
describe Onebox::Engine::HackernewsOnebox do
|
|
context "When oneboxing a comment" do
|
|
let(:link) { "https://news.ycombinator.com/item?id=30181167" }
|
|
let(:api_link) { "https://hacker-news.firebaseio.com/v0/item/30181167.json" }
|
|
let(:html) { described_class.new(link).to_html }
|
|
|
|
before do
|
|
stub_request(:get, api_link).to_return(status: 200, body: onebox_response("hackernews_comment"))
|
|
end
|
|
|
|
it "has the comments first words" do
|
|
expect(html).to include("Completely, forums are about basic human expression in paragraph form.")
|
|
end
|
|
|
|
it "has author username" do
|
|
expect(html).to include("codinghorror")
|
|
end
|
|
|
|
it "has the permalink to the comic" do
|
|
expect(html).to include(link)
|
|
end
|
|
|
|
it "has the item date" do
|
|
expect(html).to include("2013")
|
|
end
|
|
end
|
|
|
|
context "When oneboxing a story" do
|
|
let(:link) { "https://news.ycombinator.com/item?id=5172905" }
|
|
let(:api_link) { "https://hacker-news.firebaseio.com/v0/item/5172905.json" }
|
|
let(:html) { described_class.new(link).to_html }
|
|
|
|
before do
|
|
stub_request(:get, api_link).to_return(status: 200, body: onebox_response("hackernews_story"))
|
|
end
|
|
|
|
it "has story title" do
|
|
expect(html).to include("Civilized Discourse Construction Kit")
|
|
end
|
|
|
|
it "has author username" do
|
|
expect(html).to include("sosuke")
|
|
end
|
|
|
|
it "has the permalink to the comic" do
|
|
expect(html).to include(link)
|
|
end
|
|
|
|
it "has the item date" do
|
|
expect(html).to include("2013")
|
|
end
|
|
end
|
|
end
|