Sha256: c0753202ae983050ad6d16548ebc70fa47e3f65726a600c8912041144b9df297

Contents?: true

Size: 1.19 KB

Versions: 1

Compression:

Stored size: 1.19 KB

Contents

describe JsonTestData::String do
  describe ".create" do
    context "normal" do
      let(:object) do
        {
          type: "string"
        }
      end

      it "returns a string" do
        expect(described_class.create(object)).to be_a String
      end

      it "returns a single character" do
        expect(described_class.create(object).length).to eq 1
      end
    end

    context "with maximum length" do
      let(:object) do
        {
          type: "string",
          maxLength: 2
        }
      end

      it "returns a string 2 characters long" do
        expect(described_class.create(object).length).to eq 2
      end
    end

    context "with minimum length" do
      let(:object) do
        {
          type: "string",
          minLength: 8
        }
      end

      it "returns an 8-character string" do
        expect(described_class.create(object).length).to eq 8
      end
    end

    context "with enum" do
      let(:enum) { ["foo", "bar", "baz"] }

      let(:object) do
        {
          type: "string",
          enum: enum
        }
      end

      it "returns a string from the list" do
        expect(described_class.create(object)).to be_in enum
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
json_test_data-0.8.0 spec/json_test_data/data_structures/string_spec.rb