Sha256: 6c1f5a23200f97e498bce2b7aac56fad66dd5375649fce4fc2d3e79a6bd45c39

Contents?: true

Size: 1001 Bytes

Versions: 1

Compression:

Stored size: 1001 Bytes

Contents

RSpec.describe Rambo::RamlModels::Body do
  let(:raml) { Raml::Parser.parse_file(raml_file) }
  let(:body) { raml.resources.first.methods.first.responses.first.bodies.first }

  subject { described_class.new(body) }

  describe "#content_type" do
    let(:raml_file) { File.expand_path("../../../support/foobar.raml", __FILE__) }

    it "returns the content type" do
      expect(subject.content_type).to eql body.content_type
    end
  end

  describe "#example" do
    context "when an example is given" do
      let(:raml_file) { File.expand_path("../../../support/foobar.raml", __FILE__) }

      it "returns an example" do
        expect(subject.example).to eql body.example
      end
    end

    context "when a schema is given" do
      let(:raml_file) { File.expand_path("../../../../features/support/examples/raml/basic_raml_with_schema.raml", __FILE__) }

      it "returns generated JSON data" do
        expect(JSON.parse(subject.example)).to have_key "data"
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rambo_ruby-0.1.0 spec/lib/raml_models/body_spec.rb