|
|
@ -5,71 +5,73 @@ RSpec.describe QuestionViewHelper do |
|
|
|
let(:conditional) { false } |
|
|
|
let(:conditional) { false } |
|
|
|
|
|
|
|
|
|
|
|
describe "caption" do |
|
|
|
describe "caption" do |
|
|
|
let(:subject) { caption(caption_text, page_header, conditional) } |
|
|
|
subject(:header) { caption(caption_text, page_header, conditional) } |
|
|
|
|
|
|
|
|
|
|
|
let(:caption_text) { "Some text" } |
|
|
|
let(:caption_text) { "Some text" } |
|
|
|
let(:caption_options_hash) { { text: caption_text.html_safe, size: "l" } } |
|
|
|
let(:caption_options_hash) { { text: caption_text.html_safe, size: "l" } } |
|
|
|
|
|
|
|
|
|
|
|
context "a page without a header" do |
|
|
|
context "when viewing a page without a header" do |
|
|
|
let(:page_header) { nil } |
|
|
|
let(:page_header) { nil } |
|
|
|
|
|
|
|
|
|
|
|
it "returns an options hash" do |
|
|
|
it "returns an options hash" do |
|
|
|
expect(subject).to eq(caption_options_hash) |
|
|
|
expect(header).to eq(caption_options_hash) |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
context "a page with a header" do |
|
|
|
context "when viewing a page with a header" do |
|
|
|
it "returns nil" do |
|
|
|
it "returns nil" do |
|
|
|
expect(subject).to be_nil |
|
|
|
expect(header).to be_nil |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
context "a conditional question" do |
|
|
|
context "when viewing a conditional question" do |
|
|
|
let(:conditional) { true } |
|
|
|
let(:conditional) { true } |
|
|
|
|
|
|
|
|
|
|
|
it "returns nil" do |
|
|
|
it "returns nil" do |
|
|
|
expect(subject).to be_nil |
|
|
|
expect(header).to be_nil |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
context "a question without a caption" do |
|
|
|
context "when viewig a question without a caption" do |
|
|
|
let(:caption_text) { nil } |
|
|
|
let(:caption_text) { nil } |
|
|
|
|
|
|
|
|
|
|
|
it "returns nil" do |
|
|
|
it "returns nil" do |
|
|
|
expect(subject).to be_nil |
|
|
|
expect(header).to be_nil |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
describe "legend" do |
|
|
|
describe "legend" do |
|
|
|
|
|
|
|
subject(:question_view_helper) { legend(question, page_header, conditional) } |
|
|
|
|
|
|
|
|
|
|
|
let(:question) { OpenStruct.new(header: "Some question header") } |
|
|
|
let(:question) { OpenStruct.new(header: "Some question header") } |
|
|
|
let(:subject) { legend(question, page_header, conditional) } |
|
|
|
|
|
|
|
let(:size) { "m" } |
|
|
|
let(:size) { "m" } |
|
|
|
let(:tag) { "h2" } |
|
|
|
let(:tag) { "h2" } |
|
|
|
let(:legend_options_hash) do |
|
|
|
let(:legend_options_hash) do |
|
|
|
{ text: "Some question header".html_safe, size: size, tag: tag } |
|
|
|
{ text: "Some question header".html_safe, size: size, tag: tag } |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
context "a page with a header" do |
|
|
|
context "when viewing a page with a header" do |
|
|
|
it "returns an options hash with a medium question header" do |
|
|
|
it "returns an options hash with a medium question header" do |
|
|
|
expect(subject).to eq(legend_options_hash) |
|
|
|
expect(question_view_helper).to eq(legend_options_hash) |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
context "a page without a header" do |
|
|
|
context "when viewing a page without a header" do |
|
|
|
let(:page_header) { nil } |
|
|
|
let(:page_header) { nil } |
|
|
|
let(:size) { "l" } |
|
|
|
let(:size) { "l" } |
|
|
|
let(:tag) { "h1" } |
|
|
|
let(:tag) { "h1" } |
|
|
|
|
|
|
|
|
|
|
|
it "returns an options hash with a large question header" do |
|
|
|
it "returns an options hash with a large question header" do |
|
|
|
expect(subject).to eq(legend_options_hash) |
|
|
|
expect(question_view_helper).to eq(legend_options_hash) |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
context "a conditional question" do |
|
|
|
context "when viewinng a conditional question" do |
|
|
|
let(:conditional) { true } |
|
|
|
let(:conditional) { true } |
|
|
|
|
|
|
|
|
|
|
|
it "returns an options hash with a medium question header" do |
|
|
|
it "returns an options hash with a medium question header" do |
|
|
|
expect(subject).to eq(legend_options_hash) |
|
|
|
expect(question_view_helper).to eq(legend_options_hash) |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|