require 'rspec/match_ignoring_whitespace' require_relative '../lib/img_builder' require_relative '../lib/img_props' # Test ImgProperties class ImgPropertiesTest RSpec.describe ImgBuilder do Dir.chdir("demo") it 'generates sources' do props = ImgProperties.new props.src = 'jekyll.webp' builder = described_class.new(props) actual = builder.send(:generate_sources, ['png'], 'image/png') expect(actual).to contain_exactly('') end it 'generates a default img' do props = ImgProperties.new props.src = 'jekyll.webp' builder = described_class.new(props) picture = <<~END_IMG
END_IMG expect(builder.send(:generate_figure_caption)).to be_nil expect(builder.send(:generate_wrapper)).to match_ignoring_whitespace(picture) end it 'generates an img with size and caption' do props = ImgProperties.new props.caption = 'This is a caption' props.size = '123px' props.src = 'jekyll.webp' builder = described_class.new(props) caption = <<~END_CAPTION
This is a caption
END_CAPTION picture = <<~END_IMG
This is a caption #{caption}
END_IMG expect(builder.send(:generate_figure_caption)).to match_ignoring_whitespace(caption) expect(builder.send(:generate_wrapper)).to match_ignoring_whitespace(picture) end end end