Sha256: 527a0d4d24d395f4496095d2a504313480f098d12db126fae361302d70503c9b

Contents?: true

Size: 978 Bytes

Versions: 10

Compression:

Stored size: 978 Bytes

Contents

require 'cucumber'

describe Cucumber do

  # Implementation is backported from ruby 2.0 when cucumber is used on ruby 1.9.
  # The tests will run on all implementations to ensure we have the same
  # feature set.
  describe 'Hash' do
    it "converts nil to empty {}" do
      expect(Cucumber::Hash(nil)).to eq({})
    end

    it "converts [] to {}" do
      expect(Cucumber::Hash([])).to eq({})
    end

    it "converts a hash to an equivalent hash" do
      original = {:a => 1, :b => 2}
      expect(Cucumber::Hash(original)).to eq({a: 1, b: 2})
    end

    it "converts an object with a to_hash method" do
      original = Object.new
      def original.to_hash
        {key: "value"}
      end

      expect(Cucumber::Hash(original)).to eq({key: "value"})
    end

    it "raises a TypeError for an object that does not have .to_hash" do
      original = %w(cannot convert to hash)

      expect { Cucumber::Hash(original) }.to raise_error TypeError
    end
  end
end


Version data entries

10 entries across 10 versions & 2 rubygems

Version Path
cucumber-2.99.0 spec/cucumber_spec.rb
mobiusloop-0.1.5 spec/cucumber_spec.rb
cucumber-2.4.0 spec/cucumber_spec.rb
mobiusloop-0.1.3 spec/cucumber_spec.rb
mobiusloop-0.1.2 spec/cucumber_spec.rb
cucumber-2.3.3 spec/cucumber_spec.rb
cucumber-2.3.2 spec/cucumber_spec.rb
cucumber-2.3.1 spec/cucumber_spec.rb
cucumber-2.3.0 spec/cucumber_spec.rb
cucumber-2.2.0 spec/cucumber_spec.rb