Sha256: 58989e5b67f2585e8b829a51249de29d6059a723aaed9fe0a2e35b4bff14c7ab

Contents?: true

Size: 581 Bytes

Versions: 2

Compression:

Stored size: 581 Bytes

Contents

require 'forwardable'


class RestService
  extend Forwardable
  
  
  attr_reader :path
  attr_reader :service
  attr_reader :browser

  def initialize(params = {})
    defaults = {
      :service => Sinatra::Base,
      :path => '/'
    }
    defaults.merge! params
    @service = defaults[:service]
    @path = defaults[:path]
    @browser = Rack::Test::Session.new(Rack::MockSession.new(@service))
  end
  
    def_delegators :@browser, :get, :post, :put, :delete

    def returned_data
      return JSON::parse(@browser.last_response.body, symbolize_names: true)
    end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rack-rest-rspec-0.0.5 lib/rack-rest-rspec/lib/rest_service.rb
rack-rest-rspec-0.0.4 lib/rack-rest-rspec/lib/rest_service.rb