This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
User.admins # return all admins | |
User.editors # return all editors | |
User.admins.editors # return all users that are admins and editors | |
User.not.admins # return all users that are not admins | |
User.admins.or.editors # return all users that are admins or editors | |
class Job < ActiveRecord::Base | |
def search(options) | |
Job. | |
active.unless { options[:include_inactive] }. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require 'fileutils' | |
class TestFinder | |
attr_reader :prefix | |
def initialize(prefix) | |
@prefix = prefix | |
end | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Test::Unit::TestCase | |
# call-seq: | |
# should_delegate(method, :to => member) | |
# | |
# Generates a test asserting that +method+ returns the value of that method | |
# on +member+. | |
# | |
# Example: | |
# should_deleate :full_name, :to => :user | |
def self.should_delegate(method, opts) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require 'fileutils' | |
def usage | |
puts "Usage: schema -l [partial_model_name] OR schema <model_name>" | |
end | |
if ARGV.first == '-l' | |
def camelize(lower_case_and_underscored_word, first_letter_in_uppercase = true) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# completion for schema | |
_rails_tables() { | |
if [[ -n $words[2] ]]; then | |
compadd `schema -l ${words[2]}` | |
fi | |
} | |
compdef _rails_tables schema |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
notice: | |
api_key: api_key_value | |
session: | |
key: "" | |
data: | |
session_id: 12345 | |
user_id: 2 | |
flash: | |
notice: Logged in successfully |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0"?> | |
<notice version="2.0"> | |
<api-key>345263346</api-key> | |
<error> | |
<class>RuntimeError</class> | |
<message>RuntimeError: Example</message> | |
<backtrace> | |
<line file="app/models/groups.rb" number="3" method="find"/> | |
<line file="app/controller/groups_controller.rb" number="7" method="find"/> | |
</backtrace> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module ModelBuilder | |
def self.included(spec) | |
spec.before(:each) do | |
@created_tables = [] | |
@defined_constants = [] | |
end | |
spec.after(:each) { undefine_constants } | |
spec.after(:each) { drop_created_tables } | |
spec.send(:include, Helpers) | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class UsersControllerTest | |
# With context | |
context "on GET show, given the user exists" do | |
setup do | |
@user = Factory.stub(:user) | |
User.stubs(:find => @user) | |
get :show, :id => @user.to_param | |
end | |
should_respond_with :success |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
describe PostsController do | |
it "should show the given post on GET show" do | |
post = stub('a post', :to_param => '1') | |
Post.stubs(:find => post) | |
get :show, :id => post.to_param | |
Post.should have_received(:find).with(post.to_param) | |
should render_template(:show) | |
should assign_to(:post).with(post) |
OlderNewer