Sha256: 38638636aff264b13202bc665d13fe7cc2727f0a356dd4f825fb1cd02c0f135b

Contents?: true

Size: 1.35 KB

Versions: 1

Compression:

Stored size: 1.35 KB

Contents

module RSpecApi
  module DSL
    module Accepts

      def accepts_page(page_parameter)
        any_page = 2
        @expectations << {
          query_params: {}.tap{|qp| qp[page_parameter] = any_page},
          status_expect: {status: 200},
          headers_expect: {has_prev_page: true}
        }
      end

      def accepts_sort(sort_parameter, options={})
        @expectations << {
          query_params: {sort: sort_parameter}.merge(options.fetch(:sort_if, {})),
          before: create_fixture,
          after: destroy_fixture,
          status_expect: {status: 200},
          body_expect: {sort: options.slice(:by, :verse)}
        }
      end

      def accepts_callback(callback_parameter)
        any_callback = 'a_callback'
        @expectations << {
          query_params: {}.tap{|qp| qp[callback_parameter] = any_callback},
          status_expect: {status: 200},
          body_expect: {callback: any_callback}
        }
      end

      def accepts_filter(filter_parameter, options={})
        value = existing(options[:by])
        @expectations << {
          query_params: {}.tap{|qp| qp[filter_parameter] = value},
          before: create_fixture,
          after: destroy_fixture,
          status_expect: {status: 200},
          body_expect: {filter: options.slice(:by, :comparing_with).merge(value: value)}
        }
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rspec-api-0.5.0 lib/rspec-api/dsl/accepts.rb