Sha256: 3f4814d5d8e107c6b74e88668239eb77556fa6d3ba772fa90f7f512f36e767c4

Contents?: true

Size: 1.14 KB

Versions: 21

Compression:

Stored size: 1.14 KB

Contents

RSpec.describe Card::Set::All::RichHtml::FormElements do
  describe "#hidden_tags" do
    def hidden_tags opts
      Card["A"].format.hidden_tags opts
    end

    example "simple argument" do
      expect(hidden_tags(a: "val"))
        .to have_tag :input, with: { type: "hidden", name: "a", value: "val" }
    end

    example "deep nested arguments" do
      tags = hidden_tags(a: { b: { c: "val1" },  d: "val2" }, x: { y: "val3" } )
      expect(tags)
        .to have_tag(:input, with: { type: "hidden", name: "a[b][c]", value: "val1" })
      expect(tags)
        .to have_tag(:input, with: { type: "hidden", name: "a[d]", value: "val2" })
      expect(tags)
        .to have_tag(:input, with: { type: "hidden", name: "x[y]", value: "val3" })
    end

    describe "array values" do
      let(:tags) { hidden_tags(a: { b: [1, 2] }) }

      example "first array value" do
        expect(tags)
          .to have_tag(:input, with: { type: "hidden", name: "a[b][]", value: "1" })
      end

      example "second array value" do
        expect(tags)
          .to have_tag(:input, with: { type: "hidden", name: "a[b][]", value: "2" })
      end
    end
  end
end

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
card-1.96.8 mod/standard/spec/set/all/rich_html/form_elements_spec.rb
card-1.96.7 mod/standard/spec/set/all/rich_html/form_elements_spec.rb
card-1.96.6 mod/standard/spec/set/all/rich_html/form_elements_spec.rb
card-1.96.5 mod/standard/spec/set/all/rich_html/form_elements_spec.rb
card-1.96.4 mod/standard/spec/set/all/rich_html/form_elements_spec.rb
card-1.96.3 mod/standard/spec/set/all/rich_html/form_elements_spec.rb
card-1.96.2 mod/standard/spec/set/all/rich_html/form_elements_spec.rb
card-1.96.1 mod/standard/spec/set/all/rich_html/form_elements_spec.rb
card-1.96.0 mod/standard/spec/set/all/rich_html/form_elements_spec.rb
card-1.95.3 mod/standard/spec/set/all/rich_html/form_elements_spec.rb
card-1.95.2 mod/standard/spec/set/all/rich_html/form_elements_spec.rb
card-1.95.1 mod/standard/spec/set/all/rich_html/form_elements_spec.rb
card-1.95.0 mod/standard/spec/set/all/rich_html/form_elements_spec.rb
card-1.94.1 mod/standard/spec/set/all/rich_html/form_elements_spec.rb
card-1.94.0 mod/standard/spec/set/all/rich_html/form_elements_spec.rb
card-1.93.13 mod/standard/spec/set/all/rich_html/form_elements_spec.rb
card-1.93.12 mod/standard/spec/set/all/rich_html/form_elements_spec.rb
card-1.93.11 mod/standard/spec/set/all/rich_html/form_elements_spec.rb
card-1.93.10 mod/standard/spec/set/all/rich_html/form_elements_spec.rb
card-1.93.9 mod/standard/spec/set/all/rich_html/form_elements_spec.rb