require "spec_helper" module GhostInThePost describe JsInline do let(:html){"
"} let(:html_without_script){""} let(:js){"(function(){document.getElementById('test').innerHTML='complete';})()"} let(:html_with_js){""} let(:included_scripts){["application.js"]} subject {JsInline.new(html, included_scripts)} describe "#initialize" do it "should assign html" do expect(Nokogiri::HTML).to receive(:parse) JsInline.new(html, included_scripts) end it "should set included_scripts" do ji = JsInline.new(html, included_scripts) expect(ji.instance_variable_get(:@included_scripts)).to eq(included_scripts) end it "should default included_scripts to an array" do ji = JsInline.new(html) expect(ji.instance_variable_get(:@included_scripts)).to eq([]) end end describe "#inline" do before :each do allow(subject).to receive(:find_asset_in_pipeline).with("application.js").and_return(js) end it "should inline js" do subject.inline expect(subject.html).to include(js) expect(subject.html).to include("