Sha256: c01430e135d5318c9e0014afb93c116ba0c836f8920a2e9907da2ea1cc730003
Contents?: true
Size: 1.37 KB
Versions: 2
Compression:
Stored size: 1.37 KB
Contents
RSpec.shared_examples "an active element" do describe ".new" do it "should have empty error" do expect(subject.error).to eq "" end it "should not be required if its parent is not visible" do group_options[:visible] = false options[:required] = true expect(subject.required?).to eq false end it "should have a nil value" do expect(subject.value).to be nil end it "should have a value from form params" do resolver_options[:params]= {"group_element_name" => "element_value" } expect(subject.value).to eq "element_value" end it "should have a value from element structure" do options[:value] = "element_value" expect(subject.value).to eq "element_value" end end describe "#valid?" do context "when required" do before(:each) { options[:required] = true } it "is valid" do subject.value = "value" expect(subject.valid?).to eq true expect(subject.error).to eq '' end it "is invalid" do subject.value = '' expect(subject.valid?).to eq false expect(subject.error).to eq 'This field is required' end end end describe "#to_hash" do it 'should include required, value and error' do options.merge!(value: '', required: true) expect(subject.to_hash).to include(:required, :value, :error) end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
hungryform-0.0.7 | spec/elements/shared_examples/active_element.rb |
hungryform-0.0.6 | spec/elements/shared_examples/active_element.rb |