Sha256: eb082bdc38d65bd37892689374e7cb8bbe70498eaa8503efb912e6e06f85b86c
Contents?: true
Size: 1.3 KB
Versions: 1
Compression:
Stored size: 1.3 KB
Contents
RSpec.shared_examples "an element with options" do let(:resolver_options) { {} } let(:resolver) { HungryForm::Resolver.new(resolver_options) } let(:group_options) { {} } let(:group) { HungryForm::Elements::Group.new(:group, nil, resolver, group_options) {} } let(:element) { described_class.new(:element_name, group, resolver, options_element_options) {} } it_behaves_like "an active element" do let(:active_element_options) { options_element_options } end describe ".new" do it "should raise an exception if there is no options provided" do options_element_options.delete(:options) if options_element_options[:options] expect { described_class.new(:element_name, group, resolver, options_element_options) }.to raise_error(HungryForm::HungryFormException) end it "should have options" do options_element_options[:options] = {"1" => "First", "2" => "Last"} expect(element.options).to eq({"1" => "First", "2" => "Last"}) end it "should convert options to hash" do options_element_options[:options] = ->(el) {{"1" => "First", "2" => "Last"}} expect(element.options).to eq({"1" => "First", "2" => "Last"}) end end describe "#to_hash" do it "should include options" do expect(element.to_hash).to include(:options) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
hungryform-0.0.4 | spec/support/shared_options_element.rb |