Sha256: 9ca4168fdcccdbd83890f69003cad28dabcf8a9d5b188818db3936a1bd627983

Contents?: true

Size: 949 Bytes

Versions: 16

Compression:

Stored size: 949 Bytes

Contents

# frozen_string_literal: true

module Spree
  module Api
    module TestingSupport
      module Helpers
        def json_response
          case body = JSON.parse(response.body)
          when Hash
            body.with_indifferent_access
          when Array
            body
          end
        end

        def assert_not_found!
          expect(json_response).to eq({ "error" => "The resource you were looking for could not be found." })
          expect(response.status).to eq 404
        end

        def assert_unauthorized!
          expect(json_response).to eq({ "error" => "You are not authorized to perform that action." })
          expect(response.status).to eq 401
        end

        def image(filename)
          File.open(Spree::Api::Engine.root + "spec/fixtures" + filename)
        end

        def upload_image(filename)
          fixture_file_upload(image(filename).path, 'image/jpg')
        end
      end
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
solidus_api_devise_token_auth-2.8.0.alpha.14 lib/spree/api/testing_support/helpers.rb
solidus_api_devise_token_auth-2.8.0.alpha.13 lib/spree/api/testing_support/helpers.rb
solidus_api_devise_token_auth-2.8.0.alpha.12 lib/spree/api/testing_support/helpers.rb
solidus_api_devise_token_auth-2.8.0.alpha.11 lib/spree/api/testing_support/helpers.rb
solidus_api_devise_token_auth-2.8.0.alpha.10 lib/spree/api/testing_support/helpers.rb
solidus_api_devise_token_auth-2.8.0.alpha.9 lib/spree/api/testing_support/helpers.rb
solidus_api_devise_token_auth-2.8.0.alpha.8 lib/spree/api/testing_support/helpers.rb
solidus_api_devise_token_auth-2.8.0.alpha.7 lib/spree/api/testing_support/helpers.rb
solidus_api_devise_token_auth-2.8.0.alpha.6 lib/spree/api/testing_support/helpers.rb
solidus_api_devise_token_auth-2.8.0.alpha.5 lib/spree/api/testing_support/helpers.rb
solidus_api_devise_token_auth-2.8.0.alpha.4 lib/spree/api/testing_support/helpers.rb
solidus_api_devise_token_auth-2.8.0.alpha.3 lib/spree/api/testing_support/helpers.rb
solidus_api_devise_token_auth-2.8.0.alpha.2 lib/spree/api/testing_support/helpers.rb
solidus_api_devise_token_auth-2.8.0.alpha.1 lib/spree/api/testing_support/helpers.rb
solidus_api_devise_token_auth-2.8.0.alpha.0 lib/spree/api/testing_support/helpers.rb
solidus_api_devise_token_auth-2.8.0.alpha lib/spree/api/testing_support/helpers.rb