Skip to content

Instantly share code, notes, and snippets.

require 'bundler/inline'
gemfile(true) do
source 'https://rubygems.org'
gem 'rom', github: 'rom-rb/rom'
gem 'rom-sql', github: 'rom-rb/rom-sql'
gem 'rom-repository', github: 'rom-rb/rom-repository'
gem 'sqlite3'
end
@cflipse
cflipse / stubbing_with_arguments_spec.rb
Created December 14, 2011 19:28 — forked from adomokos/stubbing_with_arguments_spec.rb
Stubbing with arguments - examples used in my "(More) Specific Stubbing with RSpec" blog post
class GivesCreditToPreferredCustomers
LOOK_BACK_PERIOD = 3
def self.for_large_orders(sales_amount, added_credit)
# the has_large_purchases scope now takes two arguments
preferred_customers = Customer.has_large_purchases(sales_amount, LOOK_BACK_PERIOD)
preferred_customers.each do |customer|
customer.add_credit added_credit
end
end
end
# Depends on working pdftk, gm (GraphicsMagick), and pdftotext (Poppler) commands.
# Splits a pdf into batches of N pages, creates their thumbnails and icons,
# as specified in the Job options, gets the text for every page, and merges
# it all back into a tar archive for convenient download.
#
# See <tt>examples/process_pdfs_example.rb</tt> for more information.
class ProcessPdfs < CloudCrowd::Action
# Split up a large pdf into single-page pdfs. Batch them into 'batch_size'
# chunks for processing. The double pdftk shuffle fixes the document xrefs.
describe Tweet do
describe "basic fetching of tweets" do
describe "(search conditions)" do
attr_reader :new_search
before do
@new_search = mock(Twitter::Search, :null_object => true)
Twitter::Search.should_receive(:new).and_return(new_search)
end
after do
Tweet.fetch_new_tweets