require 'spec_helper'
describe Rack::DevMark::Theme::Base do
it "has private initialize method" do
expect {
Rack::DevMark::Theme::Base.new
}.to raise_error(Rack::DevMark::RuntimeError)
end
describe "subclass" do
subject { Class.new(Rack::DevMark::Theme::Base).new }
describe "#gsub_tag_content" do
let(:input) { %Q|
head
xy| }
let(:output) { %Q|head
replacedy| }
it "replaces a string" do
expect(subject.send(:gsub_tag_content, input, 'a', &lambda{ |v| 'replaced' })).to eq(output)
end
context "for multiple tags" do
let(:input) { %Q|head
xy| }
let(:output) { %Q|head
replacedreplaced| }
it "replaces a string" do
expect(subject.send(:gsub_tag_content, input, 'a', &lambda{ |v| 'replaced' })).to eq(output)
end
end
context "for nested tags" do
let(:input) { %Q|head
xy| }
let(:output) { %Q|head
xy| }
it "does not replace a string" do
expect(subject.send(:gsub_tag_content, input, 'a', &lambda{ |v| 'replaced' })).to eq(output)
end
end
end
describe "#gsub_tag_attribute" do
let(:input) { %Q|head
xy| }
let(:output) { %Q|head
xy| }
it "replaces a string" do
expect(subject.send(:gsub_tag_attribute, input, 'a', 'data-title', &lambda{ |v| 'replaced' })).to eq(output)
end
context "for multiple tags" do
let(:input) { %Q|head
xy| }
let(:output) { %Q|head
xy| }
it "replaces a string" do
expect(subject.send(:gsub_tag_attribute, input, 'a', 'data-title', &lambda{ |v| 'replaced' })).to eq(output)
end
end
context "for single tag" do
let(:input) { %Q|head
xy
| }
let(:output) { %Q|head
xy
| }
it "replaces a string" do
expect(subject.send(:gsub_tag_attribute, input, 'img', 'data-title', &lambda{ |v| 'replaced' })).to eq(output)
end
end
context "for any tags" do
let(:input) { %Q|head
xy| }
let(:output) { %Q|head
xy| }
it "replaces a string" do
expect(subject.send(:gsub_tag_attribute, input, nil, 'data-title', &lambda{ |v| 'replaced' })).to eq(output)
end
end
context "with single quotations" do
let(:input) { %Q|head
xy| }
let(:output) { %Q|head
xy| }
it "replaces a string" do
expect(subject.send(:gsub_tag_attribute, input, 'a', 'data-title', &lambda{ |v| 'replaced' })).to eq(output)
end
end
end
end
end