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
require 'bundler/inline' | |
## | |
# Get dependencies | |
gemfile do | |
source 'https://rubygems.org' | |
gem 'pg' | |
gem 'activerecord', require: 'active_record' | |
gem 'benchmark-ips' | |
gem 'pry' |
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 Scoring | |
def self.included(base) | |
base.class_eval do | |
let(:__score_keeper) { ScoreKeeper.new } | |
extend ScoreHelpers | |
include ScoreMatchers | |
end | |
end | |
class ScoreKeeper |
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
# ARCHFLAGS may or may not matter - I set mine up this way just in case. | |
~$ echo $ARCHFLAGS | |
-arch i386 -arch x86_64 | |
# Be sure to compile ruby with --enable-shared | |
~$ rvm install 1.9.1 --debug --reconfigure -C --enable-shared=yes | |
# Test to ensure that --enable-shared worked | |
~$ ruby -e "require 'rbconfig'; puts Config::CONFIG['ENABLE_SHARED']" | |
yes |
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
# something like ... | |
# I think this goes in specs/support/whatever.rb | |
def it_should_be_invalid_without(*fields) | |
object_name = described_class.name.underscore | |
fields.each do |field| | |
it "should fail if #{field} is missing" do | |
instance_variable_get("@#{object_name}").send(:"#{field}=", nil) | |
instance_variable_get("@#{object_name}").should_not be_valid_for_create |
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 SomeController | |
before_filter :find_product | |
before_filter :sanitise_segment | |
def show | |
@product.reviews.for_segment(@segment).order_by(sort_order) | |
end | |
def show_extended_detail |
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 Schedule | |
def initialize(service) | |
@service = service | |
end | |
attr_accessor :schedule | |
def day | |
(1..23).map { [] } |