Skip to content

Instantly share code, notes, and snippets.

View patricksrobertson's full-sized avatar

Patrick Robertson patricksrobertson

View GitHub Profile

OpenIdAuthentication

Provides a thin wrapper around the excellent ruby-openid gem from JanRan. Be sure to install that first:

gem install ruby-openid

To understand what OpenID is about and how it works, it helps to read the documentation for lib/openid/consumer.rb from that gem.

@patricksrobertson
patricksrobertson / Questions
Created August 9, 2011 15:42
Frozen Rails Give-away
Day job: Senior Developer at Velir
Your Rails contributions (if any): Maintainer of an official rails plugin, bug reports
What's your Ruby/Rail experience?: I have been using Rails since 2004.
How do you use GitHub?: I use GitHub for all my professional work & personal Ruby work, and use it to contribute/maintain open source project I participate in.
Background:
Given the following user:
| first name | last name | email |
| Fred | Friend | [email protected] |
Scenario: I follow a User from their profile
Given I am logged in
When I go to the profile page for "[email protected]"
And I press "Follow"
Then I should be following "Fred Friend"
describe "GET /users" do
it "lists users if you are logged in" do
user1 = Factory(:user, name: "Elliot Stabler")
user2 = Factory(:user, name: "Olivia Benson")
login_user(user1)
login_user(user2)
visit users_path
page.should_have content(user1.name)
require 'uri'
class IoraBot::Hangout < IoraBot::Observer
def matcher
/^(hangout|standup)(.*)$/mi
end
def handle(message, match_data)
person = message[:user][:name].split(' ')[0]
command = match_data[1]
if command == 'standup'
reply = "All: time for standup: #{link('iora_standup')}"
class User < ActiveRecord::Base
has_many :cars
end
class Color < ActiveRecord::Base
belongs_to :car
delegate :name, :to => :car, :prefix => true
end
class Car < ActiveRecord::Base
@patricksrobertson
patricksrobertson / something.rb
Created March 1, 2012 12:34
Testing Rails internals
class User < ActiveRecord::Base
validates :name, presence: true
end
#spec
require 'spec_helper'
Describe User do
it { should validate_presence_of :name } #AMG RAILS IS WORKING!!!!!!!!
it { should_not validate_presence_of :nickname }
@patricksrobertson
patricksrobertson / domPresenter.js
Created March 1, 2012 15:15
dom interaction presenter pattern?
Iora.Presenters.Patients.Edit = function() {
this.initialize.apply(this, arguments);
};
_.extend(Iora.Presenters.Patients.Edit.prototype, function() {
checkSomeBox: function() {
//dom manipulation here
}
});
#rails c production
Patient.all.each do |patient|
Rails.cache.delete("#{Rails.env}-patient-#{patient.id}")
end
@patricksrobertson
patricksrobertson / bb_fetch_spec.js.coffee
Created July 22, 2012 11:27
stubbing Backbone.fetch
collection = new Backbone.Collection
model = new Backbone.Model {title: 'fun times'}
fetchStub = sinon.collection.stub(collection, 'fetch').yieldsTo 'success', model