Sha256: 1e06e06e0129229cf0ec90bcf6b351c666838c9846600fad11a34d318513f7d3

Contents?: true

Size: 1.29 KB

Versions: 11

Compression:

Stored size: 1.29 KB

Contents

require 'spec_helper'

RSpec.describe :products, :type => :api do
  endpoint 'products/create' do
    test do
      it { should have_status(:created) }
    end
  end

  endpoint 'products/show' do
    test do
      it { should have_status(:ok) }
      it { should be_like_schema }
    end
  end

  endpoint 'products/index' do
    test do
      it { should have_status(:ok) }
      it { should be_like_schema_array }
    end
  end

  endpoint 'products/update', resource: 'products/show' do
    payload { { name: "#{initial_resource.name}-001" } }

    test do
      it 'updates the name' do
        expect(final_resource.name).to_not eq(initial_resource.name)
        expect(final_resource.name).to eq(request.payload.name)
      end

      it 'includes the payload' do
        expect(final_resource).to include(payload)
      end

      it 'does not include the initial resource attributes' do
        expect(final_resource.values).to_not include(initial_resource.values)
      end
    end
  end

  endpoint 'products/destroy', resource: 'products/show' do
    test do
      it { should have_status(:no_content) }

      it 'actually destroyed the product' do
        resource_after_destruction = resource_endpoint.execute
        expect(resource_after_destruction).to have_status(:not_found)
      end
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
restspec-0.3.2 examples/store-api-tests/spec/api/product_spec.rb
restspec-0.3.1 examples/store-api-tests/spec/api/product_spec.rb
restspec-0.3.0 examples/store-api-tests/spec/api/product_spec.rb
restspec-0.2.6 examples/store-api-tests/spec/api/product_spec.rb
restspec-0.2.5 examples/store-api-tests/spec/api/product_spec.rb
restspec-0.2.4 examples/store-api-tests/spec/api/product_spec.rb
restspec-0.2.3 examples/store-api-tests/spec/api/product_spec.rb
restspec-0.2.2 examples/store-api-tests/spec/api/product_spec.rb
restspec-0.2.1 examples/store-api-tests/spec/api/product_spec.rb
restspec-0.2 examples/store-api-tests/spec/api/product_spec.rb
restspec-0.1 examples/store-api-tests/spec/api/product_spec.rb