Skip to content

Instantly share code, notes, and snippets.

View vinhnglx's full-sized avatar
👓
Code is fun

Vincent Nguyen vinhnglx

👓
Code is fun
View GitHub Profile
@vinhnglx
vinhnglx / omniauth_macros.rb
Created October 6, 2015 01:18 — forked from kinopyo/omniauth_macros.rb
Integration test with Omniauth. This example is using twitter, and assume you've installed rspec and capybara. Official document is here: https://github.com/intridea/omniauth/wiki/Integration-Testing
# in spec/support/omniauth_macros.rb
module OmniauthMacros
def mock_auth_hash
# The mock_auth configuration allows you to set per-provider (or default)
# authentication hashes to return during integration testing.
OmniAuth.config.mock_auth[:twitter] = {
'provider' => 'twitter',
'uid' => '123545',
'user_info' => {
'name' => 'mockuser',
require 'rails_helper'
RSpec.describe TodosController, :type => :controller do
context "GET index" do
#context "POST create" do
#context "GET show" do
#context "PATCH update" do (or PUT update)
#context "DELETE destroy" do
#context "GET new" do
require 'oauth'
require 'oauth2'
class ContactImporter
def initialize(importer)
@importer = importer
end
def authorize_url
case @importer
module DefaultValues
def has_default_values(default_values = {})
class_attribute :default_values
self.default_values = default_values
after_initialize :assign_default_values
include InstanceMethods
config.generators.stylesheet_engine = :sass
# ====================
# Spell: Dynamic Proxy
# ====================
# Forward to another object any messages that don’t match a method.
class MyDynamicProxy
def initialize(target)
@target = target
end