Sha256: 1586aa0bcfac9e4802b1b2fa62b5339a96a0f26fc5d0f4ee3a1029267d2561ac

Contents?: true

Size: 1.03 KB

Versions: 1

Compression:

Stored size: 1.03 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::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 ".method_missing" do
    it "creates a nested element" do
      group.html(:name)
      expect(group.elements.first.class).to eq HungryForm::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.2 spec/support/shared_group.rb