Sha256: 7437ef2a0d0193eb5c59456a4d3b92374a251628f791b360dfd9723343b87d88

Contents?: true

Size: 798 Bytes

Versions: 6

Compression:

Stored size: 798 Bytes

Contents

RSpec.shared_examples "an element with options" do
  describe ".new" do
    it "should raise an exception if there is no options provided" do
      options.delete(:options)
      expect { described_class.new(:element_name, group, resolver, options) }.to raise_error(HungryForm::HungryFormException)
    end

    it "should have options" do
      options[:options] = {"1" => "First", "2" => "Last"}
      expect(subject.options).to eq({"1" => "First", "2" => "Last"})
    end

    it "should convert options to hash" do
      options[:options] = ->(el) {{"1" => "First", "2" => "Last"}}
      expect(subject.options).to eq({"1" => "First", "2" => "Last"})
    end
  end

  describe "#to_hash" do
    it "should include options" do
      expect(subject.to_hash).to include(:options)
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
hungryform-0.0.11 spec/elements/shared_examples/options_element.rb
hungryform-0.0.10 spec/elements/shared_examples/options_element.rb
hungryform-0.0.9 spec/elements/shared_examples/options_element.rb
hungryform-0.0.8 spec/elements/shared_examples/options_element.rb
hungryform-0.0.7 spec/elements/shared_examples/options_element.rb
hungryform-0.0.6 spec/elements/shared_examples/options_element.rb