Skip to content

Instantly share code, notes, and snippets.

View roykolak's full-sized avatar

Roy Kolak roykolak

  • Detective.io
  • Chicago, IL USA
View GitHub Profile
Store = function(client) {
return {
addBuddyWaiting: function(buddy, callback) {
client.rpush('buddies', buddy, callback);
},
getBuddiesWaiting: function(callback) {
client.lrange('buddies', 0, -1, callback);
}
};
};
Store = function(client) {
return {
addBuddyWaiting: function(buddy, callback) {
client.rpush(buddies, buddy, callback);
},
getBuddiesWaiting: function(callback) {
client.lrange('buddies', 0, -1, callback);
}
};
};
syntax on
set tabstop=2 softtabstop=2 shiftwidth=2 expandtab smarttab
set number
set nofoldenable
set cursorline
set showmatch
set hlsearch
set vb
set smartindent
set spell
class AppointmentObserver < ActiveRecord::Observer
def after_save(appointment)
user = appointment.user
return unless user.notifiable?
if appointment.initial?
MailService.welcome_email(user).deliver
elsif appointment.second_visit? && !user.has_logged_in?
MailService.second_chance_email(user).deliver
sdasdf
sadf
sadf
@roykolak
roykolak / mobile_login.rb
Created May 8, 2011 21:57
An example of using switch_driver in a capybara spec
require File.dirname(__FILE__) + '/../acceptance_helper'
feature "Logging in on mobile site", %q{
In order to access my site on the go,
As a user,
I want to log into my site
} do
switch_driver :mobile
@roykolak
roykolak / helper.rb
Created May 8, 2011 21:50
Creating a custom Capybara driver.
# spec/acceptance/support/helper.rb
# ... Other config stuff
Capybara.register_driver :mobile do |app|
Capybara::RackTest::Driver.new(app, :headers => {'HTTP_USER_AGENT' => 'Mobile'})
end
def switch_driver(driver)
before(:each) do
@roykolak
roykolak / gist:942774
Created April 26, 2011 18:11
Just a simple method to switch capybara to a different driver and then change back to the default
feature 'viewing the webpage' do
switch_driver :webkit
scenario 'viewing from a webkit browser' do
...
end
end
scenario "Viewing appointment notes" do
when 'I visit an appointment details page' do
visit my_appointment_path(fitting)
end
within('.primary') do
then 'I should see appointment notes from my dispenser' do
find('.quote').should have_content(fitting.notes)
find('.quote').should have_content(user.dispenser.first_name)
end
# BAD
scenario "When I click on an appointment, I am taken to that appointment's details" do
visit my_appointments_path
find('li.appointment:first-child .block_link').click
current_path.should == my_appointment_path(fittings.last)
page.should have_css('li.appointment .selected')
end