Skip to content

Instantly share code, notes, and snippets.

@cpkenn09y
Last active January 26, 2017 21:41
Show Gist options
  • Save cpkenn09y/2d67157cd922cbf32390b25cc85443b5 to your computer and use it in GitHub Desktop.
Save cpkenn09y/2d67157cd922cbf32390b25cc85443b5 to your computer and use it in GitHub Desktop.
# spec/helpers/support/request_helpers.rb
# Add the following require statement to your rails_helper.rb
# require Rails.root.join("spec/support/request_helpers.rb")
module Requests
module JsonHelpers
def json
@json ||= Oj.load(response.body)
end
end
end
# Some helpful rails_helper.rb configurations
=begin
RSpec.configure do |config|
# Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
config.include FactoryGirl::Syntax::Methods
config.include Shoulda::Matchers::ActiveModel
config.include Shoulda::Matchers::ActiveRecord
config.include Requests::JsonHelpers
config.include Devise::TestHelpers, :type => :controller
# If you're not using ActiveRecord, or you'd prefer not to run each of your
# examples within a transaction, remove the following line or assign false
# instead of true.
config.use_transactional_fixtures = true
# RSpec Rails can automatically mix in different behaviours to your tests
# based on their file location, for example enabling you to call `get` and
# `post` in specs under `spec/controllers`.
#
# You can disable this behaviour by removing the line below, and instead
# explicitly tag your specs with their type, e.g.:
#
# RSpec.describe UsersController, :type => :controller do
# # ...
# end
#
# The different available types are documented in the features, such as in
# https://relishapp.com/rspec/rspec-rails/docs
config.infer_spec_type_from_file_location!
# Filter lines from Rails gems in backtraces.
config.filter_rails_from_backtrace!
# arbitrary gems may also be filtered via:
# config.filter_gems_from_backtrace("gem name")
end
=end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment