This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
( (1.year.ago.to_date)..(Date.today) ).select{ |d| (1..5).include? d.wday }.size.to_f |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
################################# | |
# GEMFILE: gem 'get_process_mem' | |
################################# | |
require 'get_process_mem' | |
def profile_mem(description=nil) | |
mb = GetProcessMem.new.mb | |
puts "\n\n---- #{ description } - MEMORY USAGE(MB): #{ mb.round } ----\n\n" | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--color | |
--require spec_helper |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Shared specs for models with the `:validates_numericality_of` validators. | |
# Usage: pass a hash of each of the symbolized names of each options for the | |
# numericality validator. If the option has a value with which to evaluate | |
# against, add it as the value of that option hash name. | |
# E.g.: | |
# `it_behaves_like :validates_numericality_model, :numeric_attr, { greater_than_or_equal_to: 0, only_integer: true }` | |
RSpec.shared_examples :validates_numericality_model do |attribute_name, options| | |
it { is_expected.to validate_numericality_of(attribute_name) } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module RequestSpecHelper::SessionsHelper | |
# Set single expectation that checks auth headers were returned. | |
def expect_auth_headers(response) | |
expect(response.headers.keys).to include('access-token', 'client', 'expiry', 'uid') | |
end | |
end | |
######################################################################## |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Helpers to assist with the `devise_token_auth` security features, such as | |
# generation of new authentication tokens for each request. | |
# @see [devise_token_auth Github issue](https://github.com/lynndylanhurley/devise_token_auth/issues/75) | |
module RequestSpecHelper::ApiAuthHelper | |
module Extensions | |
# Helper method for authenticating a User for each Request type spec. | |
# Use `devise_token_auth` callback to generate an authentication token | |
# for each request. | |
# Call this on a created User at the beginning of a `describe` or `context` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function clearswap { sudo swapoff -a && sudo swapon -a; } |