require 'spec_helper'
describe SimpleMessages::Builder do
before do
@builder = SimpleMessages::Builder.new header: 'This title my alert message.',
body: 'Lorem Ipsum is simply dummy text of the printing and typesetting industry.'
end
it { expect(@builder.header_wrapper).to eq '
This title my alert message.
' }
it { expect(@builder.close_wrapper).to eq "" }
it { expect(@builder.closable?).to eq true }
it { expect(@builder.has_header?).to eq true }
it { expect(@builder.to_html).to eq "
This title my alert message.
Lorem Ipsum is simply dummy text of the printing and typesetting industry.
" }
context "without close" do
before do
@builder.closable = false
end
it { expect(@builder.closable?).to eq false }
it { expect(@builder.to_html).to eq "
This title my alert message.
Lorem Ipsum is simply dummy text of the printing and typesetting industry.
" }
end
context "without header" do
before do
@builder.header = nil
end
it { expect(@builder.has_header?).to eq false }
it { expect(@builder.to_html).to eq "
Lorem Ipsum is simply dummy text of the printing and typesetting industry.
" }
it { expect(@builder.header_wrapper).to eq nil }
end
context "body is a array" do
before do
@builder.body = [ 'Line 1.', 'Line 2.' ]
end
it { expect(@builder.to_html).to eq "
This title my alert message.
Line 1. Line 2.
" }
end
context "notice kind" do
before do
@builder.kind = :notice
end
it { expect(@builder.to_html).to eq "
This title my alert message.
Lorem Ipsum is simply dummy text of the printing and typesetting industry.
" }
end
context "danger kind" do
before do
@builder.kind = :danger
end
it { expect(@builder.to_html).to eq "
This title my alert message.
Lorem Ipsum is simply dummy text of the printing and typesetting industry.
" }
end
context "alert kind" do
before do
@builder.kind = :alert
end
it { expect(@builder.to_html).to eq "
This title my alert message.
Lorem Ipsum is simply dummy text of the printing and typesetting industry.
" }
end
context "with html attributes" do
before do
@builder.html = { class: 'my-class', id: 'my-id' }
end
it { expect(@builder.to_html).to eq "
This title my alert message.
Lorem Ipsum is simply dummy text of the printing and typesetting industry.