Skip to content

Instantly share code, notes, and snippets.

View jonathanpa's full-sized avatar

Jonathan Pares jonathanpa

View GitHub Profile
require 'oauth2'
require 'awesome_print'
# Command line to call the script:
# ruby oauth_token.rb <API_key> <API_secret> https://<domain.io>
# domain.io is travelexchange.io for production
# and travelexchange-staging.herokuapp.com for staging.
client = OAuth2::Client.new(ARGV[0], ARGV[1], site: ARGV[2])
ap client.client_credentials.get_token
entity_class = "#{ARGV[0]}Entity".constantize
model_class = "#{ARGV[0]}".constantize
output_path =
Rails.root.join('spec', 'fixtures', 'entities', "#{ARGV[0].underscore}.yml")
File.open(output_path, 'w') do |file|
file.write(
entity_class
.represent(model_class.new)
#!/usr/bin/env ruby
require 'openssl'
key = [ARGV[0]].pack("H*")
puts OpenSSL::HMAC.hexdigest(OpenSSL::Digest.new("sha1"), key, ARGV[1]).upcase
#! /bin/bash
rake db:schema:load RAILS_ENV=test; rspec --fail-fast spec/factories spec/requests/api/internal/v1/events_spec.rb spec/requests/organiser/events_spec.rb