Sha256: 5633ec72e83b7b3b1f6999f3c272b922777d0220c11911d758757080bbf5e65d

Contents?: true

Size: 1.46 KB

Versions: 2

Compression:

Stored size: 1.46 KB

Contents

require 'spec_helper'

describe APIMatchers::HTTPStatusCode::CreateResource do
  describe "should create_resource" do
    it "should passes if the actual is equal to 201" do
      expect(201).to create_resource
    end

    it "should fails if the actual is not equal to 201" do
      expect {
        expect(200).to create_resource
      }.to fail_with(%Q{expected that '200' to be Created Resource with the status '201'.})
    end
  end

  describe "should_not create_resource" do
    it "should passes if the actual is not equal to 201" do
      expect(401).not_to create_resource
    end

    it "should fail if the actual is equal equal to 201" do
      expect {
        expect(201).not_to create_resource
      }.to fail_with(%Q{expected that '201' to NOT be Created Resource.})
    end
  end

  describe "with change configuration" do
    before do
      APIMatchers.setup { |config| config.http_status_method = :http_status }
    end

    after do
      APIMatchers.setup { |config| config.http_status_method = nil }
    end

    it "should pass if the actual.http_status is equal to 201" do
      response = OpenStruct.new(:http_status => 201)
      expect(response).to create_resource
    end

    it "should fail if the actual.http_status is not equal to 201" do
      response = OpenStruct.new(:http_status => 402)
      expect {
        expect(response).to create_resource
      }.to fail_with(%Q{expected that '402' to be Created Resource with the status '201'.})
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
api_matchers-0.5.1 spec/api_matchers/http_status_code/create_resource_spec.rb
api_matchers-0.5.0 spec/api_matchers/http_status_code/create_resource_spec.rb