Sha256: 2885d2f7cb0c5af205d354b824606f5463aac6a8e194f3ccb634bde6086ec52a

Contents?: true

Size: 968 Bytes

Versions: 4

Compression:

Stored size: 968 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.join(SPEC_DIR_ROOT, "support/foobar.raml") }

    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.join(SPEC_DIR_ROOT, "support/foobar.raml") }

      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.join(SPEC_DIR_ROOT, "../features/support/examples/raml/basic_raml_with_schema.raml") }

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

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
rambo_ruby-0.2.3 spec/lib/rambo/raml_models/body_spec.rb
rambo_ruby-0.2.2 spec/lib/rambo/raml_models/body_spec.rb
rambo_ruby-0.2.1 spec/lib/rambo/raml_models/body_spec.rb
rambo_ruby-0.2.0 spec/lib/rambo/raml_models/body_spec.rb