Sha256: 58a6b9208083ba606b39a2c301cad35df98b2827c699af2c88df857492a02e52

Contents?: true

Size: 1.18 KB

Versions: 1

Compression:

Stored size: 1.18 KB

Contents

RSpec.shared_examples "a group" do
  let(:resolver) { HungryForm::Resolver.new() }
  
  let(:page) { described_class.new(:parent_name, nil, resolver, {}) {} }

  let(:group_options) { {} }
  let(:group) { described_class.new(:name, page, resolver, group_options) {} }

  it_behaves_like "an element" do
    let(:element_options) { group_options }
  end

  describe "#group" do
    it "creates a nested group" do
      group.group(:nested, {}) {}
      expect(group.elements.first.class).to eq HungryForm::Elements::Group
    end

    it "concatenates nested element's name with the parent's one" do
      group.group(:nested, {}) {}
      expect(group.elements.first.name).to eq "parent_name_name_nested"
    end
  end

  describe "#to_hash" do
    it "should include group elements" do
      expect(group.to_hash).to include(:elements)
    end
  end

  describe ".method_missing" do
    it "creates a nested element" do
      group.html(:name)
      expect(group.elements.first.class).to eq HungryForm::Elements::Html
    end

    it "concatenates nested element's name with the parent's one" do
      group.html(:html)
      expect(group.elements.first.name).to eq "parent_name_name_html"
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
hungryform-0.0.4 spec/support/shared_group.rb