Skip to content

Instantly share code, notes, and snippets.

View ajsharp's full-sized avatar

Alex Sharp ajsharp

View GitHub Profile
# put this in ~/.inputrc
# Edit commands in Vi mode
set editing-mode vi
set keymap vi
# run this file in RAILS_ROOT with watchr
#
# .watchr template file for rspec test suite
#
# watch all the spec files
watch( '^spec/(.*)/(.*)\.rb' ) { |md|
system("spec #{md[0]} --drb --colour --format progress")
}
# watch the associated files in a rails project
# also see the example from the jQuery site: http://docs.jquery.com/Attributes/removeAttr#name
$("#form-id input, #form-id select").removeAttr("disabled");
# New way of handling both HTML and AJAX requests RESTfully in the view templates
# Below are the (uncommitted) changes I've made to the contacts views
# contacts/index.html.erb
<%= render :partial => 'patients/patientnav', :locals => {:page => "demographics"} %>
<div id="patient_section" class="casecontent">
<%= render :partial => "index" %>
</div>
<%= render :partial => 'patients/patientnavend' %>
# the restrict_access_to method would operate essentially identical to
# a before_filter, I just like how it reads a little better than a before filter
class PatientsController < ApplicationController
restrict_access_to [:therapists, :accountants, :practice_admins], :on => :all
before_filter :check_patient_signoff
end
class BillingController < ApplicationController
# at the top of any controller example, you need to add in the stub_request_before_filters
# method, which will take care of everything that ApplicationController requires before
# passing the request on to the actual requested Controller#action.
#
# The stub_request_before_filters method is defined in lib/optimis_test_helpers.rb
# and is included in spec/spec_helper.rb
describe PatientsController do
before(:each) do
stub_request_before_filters
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
describe PatientVisitsController do
before(:each) do
stub_request_before_filters
end
describe "GET index /patients/1/patient_visits" do
before(:each) do
@patient = mock_model Patient
# Method to provide some syntactic sugar to use a hash of options instead of normal
# arguments, where you want an ArgumentError thrown if the proper keys aren't passed
# in, but you want the syntactic sugar of hash keys.
#
# Example
# =======
# require_options!({ :name => "John Doe", :age => 24 }, :name, :age, :sex)
# # => raises an ArgumentError
#
def require_options!(opts, *required_options)
module OptimisMatchers
def self.generate_matcher(matcher_name, url)
OptimisMatchers::module_eval do
Spec::Matchers.define matcher_name do
match do |actual|
actual.redirect_url == url
end
failure_message_for_should do |actual|
require 'rubygems'
require 'yaml'
require 'net/http'
require 'uri'
require 'json'
require 'httparty'
class NotifyCampfire
include HTTParty