Sha256: 91a1c559b9ed6474ff2fc63ea5823fc47a540cc7626ed0e261b753451e07345d

Contents?: true

Size: 1.12 KB

Versions: 6

Compression:

Stored size: 1.12 KB

Contents

RSpec.shared_examples "an element" do
  describe "#visible?" do
    it "should be visible" do
      expect(subject.visible?).to eq true
    end

    it "should not be visible" do
      options[:visible] = false
      expect(subject.visible?).to eq false
    end

    context "when dependency is present" do
      it "should not be visible" do
        options[:dependency] = { eq: [0, 1] }
        expect(subject.visible?).to eq false
      end

      it "should be visible" do
        options[:dependency] = { eq: [1, 1] }
        expect(subject.visible?).to eq true
      end
    end
  end

  describe "#label" do
    it "should have a humanized label based on element's name" do
      expect(subject.label).to eq "Element name"
    end

    it "should have a label defined in options" do
      options[:label] = "Special Label"
      expect(subject.label).to eq "Special Label"
    end
  end

  describe "#to_hash" do
    it "should include visible, dependency, name and label" do
      options.merge!(dependency: { eq: [1, 1] }, name: 'name')
      expect(subject.to_hash).to include(:visible, :dependency, :name, :label)
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

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