2021-05-26 04:41:35 -05:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2022-07-27 21:27:38 -05:00
|
|
|
RSpec.describe Onebox do
|
2021-05-26 04:41:35 -05:00
|
|
|
before do
|
2023-01-09 05:18:21 -06:00
|
|
|
stub_request(:get, "https://www.amazon.com/product").to_return(
|
|
|
|
status: 200,
|
|
|
|
body: onebox_response("amazon"),
|
|
|
|
)
|
2021-05-26 04:41:35 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
describe "templates" do
|
2023-01-09 05:18:21 -06:00
|
|
|
let(:ignored) { ["templates/_layout.mustache"] }
|
2021-05-26 04:41:35 -05:00
|
|
|
let(:templates) { Dir["templates/*.mustache"] - ignored }
|
|
|
|
|
|
|
|
def expect_templates_to_not_match(text)
|
2023-01-09 05:18:21 -06:00
|
|
|
templates.each { |template| expect(File.read(template)).not_to match(text) }
|
2021-05-26 04:41:35 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
it "should not contain any script tags" do
|
|
|
|
expect_templates_to_not_match(/<script/)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2023-01-09 05:18:21 -06:00
|
|
|
describe "has_matcher?" do
|
2021-05-26 04:41:35 -05:00
|
|
|
it "has a matcher for a real site" do
|
|
|
|
expect(Onebox.has_matcher?("http://www.youtube.com/watch?v=azaIE6QSMUs")).to be true
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|