Skip to content

Instantly share code, notes, and snippets.

@jmcervera
Forked from alex-zige/gist:5795358
Created April 10, 2014 10:33
Show Gist options
  • Select an option

  • Save jmcervera/10366285 to your computer and use it in GitHub Desktop.

Select an option

Save jmcervera/10366285 to your computer and use it in GitHub Desktop.

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