Skip to content

Instantly share code, notes, and snippets.

View nbulaj's full-sized avatar

Nikita Bulai nbulaj

View GitHub Profile
  1. Run main_api.rb (ruby main_api.rb)
  2. Run proxy_api.rb (ruby proxy_api.rb)
  3. Open browser and go to http://localhost:3001/test
  4. See infinite load :(
# frozen_string_literal: true
RSpec::Matchers.define :exceed_query_limit do |expected, pattern = nil|
supports_block_expectations
match do |block|
query_count(pattern, &block) > expected
end
failure_message_when_negated do |actual|
begin
require 'bundler/inline'
rescue LoadError => e
$stderr.puts 'Bundler version 1.10 or later is required. Please update your Bundler'
raise e
end
gemfile(true) do
source 'https://rubygems.org'
# Gemfile
source 'https://rubygems.org'
gem 'grape_oauth2', git: 'https://github.com/nbulaj/grape_oauth2.git'
gem 'grape', '~> 1.0'
gem 'rack-oauth2'
gem 'tzinfo-data', platforms: %i[mingw mswin x64_mingw jruby]
@nbulaj
nbulaj / be_success_matcher.rb
Last active March 11, 2018 11:37
More informative RSpec #be_success matcher with negotiation
# spec/rails_helper.rb or spec/spec_helper.rb
# ...
# require custom matchers from the "support" directory:
Dir[Rails.root.join('spec/support/**/*.rb')].each { |f| require f }
# -----
# support/matchers/be_success.rb
RSpec::Matchers.define :be_success do
match do |actual|