spec/ballast/concerns/view_spec.rb in ballast-1.6.0 vs spec/ballast/concerns/view_spec.rb in ballast-1.7.0

- old
+ new

@@ -53,9 +53,40 @@ expect(subject.browser).to receive(:supported?).with("ROOT/config/supported-browsers.yml").and_return(true) subject.browser_supported? end end + describe "#layout_params" do + it "should return a single parameter" do + subject.set_layout_params(a: 1) + expect(subject.layout_params(:a)).to eq(1) + end + + it "should return a default value for a missing parameter" do + subject.set_layout_params(a: 1) + expect(subject.layout_params(:b, 2)).to eq(2) + end + + it "should never raise an error" do + expect(subject.layout_params(:a)).to be_nil + expect(subject.layout_params(:a, 3)).to eq(3) + end + + it "should return the entire hash if no arguments are passed" do + expect(subject.layout_params).to eq({}) + subject.set_layout_params(a: 1) + expect(subject.layout_params).to eq({"a" => 1}) + end + end + + describe "#set_layout_params" do + it "should merge arguments into the existing parameters" do + expect(subject.layout_params).to eq({}) + subject.set_layout_params(a: 1, b: 2) + expect(subject.layout_params).to eq({"a" => 1, "b" => 2}) + end + end + describe "#javascript_params" do before(:each) do subject.instance_variable_set(:@javascript_params, {a: "1", b: 2}) end \ No newline at end of file