Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save RobBikmansurov/c456524d00099ba14a25b6ac24c4a9d9 to your computer and use it in GitHub Desktop.
Save RobBikmansurov/c456524d00099ba14a25b6ac24c4a9d9 to your computer and use it in GitHub Desktop.
Rails Rspec API Testing Notes

Respec APIs Testing Notes

Folder Structure

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

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

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 #apply to all spec for apis folder
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