require 'spec_helper' require 'magic_reveal/index_libber' describe MagicReveal::IndexLibber do subject { described_class.new html_text } describe ".update_author" do let(:html_text) { '' } it "replaces the author" do author = "Joe Cool #{rand 99}" subject.update_author author expect(subject.to_s).to match %r{content=.#{Regexp.quote author}.} end end describe ".update_description" do let(:html_text) { '' } it "replaces the description" do description = "#{rand 99} luft balloons" subject.update_description description expect(subject.html.at('meta').get_attribute('content')).to eq(description) end end describe ".update_slides" do let(:slides) { '

life with Joe

…is good

' * 2 } let(:html_text) { 'bogus
text
' } it "inserts the slides" do subject.update_slides slides expect(subject.to_s).to include('life with Joe') end it "sets the title from the first Hx item" do subject.update_slides slides expect(subject.html.at_css('title').text).to eq('life with Joe') end end context "with random html" do let(:html_text) { "\n\n

text here\n" } its(:to_s) { should match %r{\s*

text here\s*

\s*} } its(:to_s) { should be_kind_of(String) } end end