Skip to content

Instantly share code, notes, and snippets.

@wenweih
Forked from alex-zige/gist:5795358
Created September 18, 2016 16:28
Show Gist options
  • Select an option

  • Save wenweih/b124236cb9bc876c67837e703fbc14ac to your computer and use it in GitHub Desktop.

Select an option

Save wenweih/b124236cb9bc876c67837e703fbc14ac to your computer and use it in GitHub Desktop.
Rails Rspec API Testing Notes

#h1 Respec APIs Testing Notes

Folder Structure

spec |--- apis |--- your_api_test_spec.rb |--- controllers |--- models |--- supports |--- api_helper.rb

Custom Rspec Helper for Rake::Test::Methods.

spec/supports/api_helper.rb


module ApiHelper
  include Rack::Test::Methods

  def app
    Rails.application
  end
end

RSpec.configure do |config|
  config.include ApiHelper, :type=>:api
end
ActionController::TestCase::Behavior 

v.s.

Rack::Test::Methods
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment