Skip to content

Instantly share code, notes, and snippets.

$ cd sample
$ ant debug install
$ cd ../sampletest
$ ant test
test:
[echo] Running tests ...
[exec]
[exec] com.sample.GreeterTest:
[exec] Failure in testExpectAGreetingAfterSubmittingAName:
enum = Enumerator.new do |yielder|
yielder << "a"
yielder << "b"
yielder << "c"
end
enum.next # "a"
enum.next # "b"
enum.next # "c"
enum.next # StopIteration: iteration reached an end
@jccarbonfive
jccarbonfive / use_zone.rb
Created July 5, 2012 18:56
Time.use_zone usage
>> Time.zone
=> (GMT+00:00) UTC
>> Time.use_zone('America/Los_Angeles') { puts Time.zone }
(GMT-08:00) America/Los_Angeles
=> nil
>> Time.zone
=> (GMT+00:00) UTC
@jccarbonfive
jccarbonfive / 0.rb
Last active December 12, 2015 03:08
require 'spec_helper'
describe 'Signing in', vcr: { match_requests_on: [:path] } do
before do
@user = create :user
visit '/users/sign_in'
fill_in 'Email', with: @user.email
fill_in 'Password', with: @user.password
click_button 'Sign in'
@jccarbonfive
jccarbonfive / 0.rb
Last active December 11, 2015 11:08
class Account < ActiveRecord::Base
attr_accessible :name,
:account_type,
:balance
def self.import(file, account_importer)
account_importer.import file
end
end
class Account < ActiveRecord::Base
attr_accessible :name,
:account_type,
:balance
def self.import(file, account_importer = CsvAccountImporter.new)
account_importer.import file
end
end
@jccarbonfive
jccarbonfive / 0.rb
Last active December 11, 2015 11:08
require 'spec_helper'
describe 'Importing accounts' do
context 'given a CSV file of accounts' do
before do
visit '/'
within '#new_accounts' do
attach_file 'File', Rails.root.join('spec', 'fixtures', 'accounts.csv')
click_button 'Import'
end
$ cucumber features/pig_latin.feature
Using the default profile...
.F-
(::) failed steps (::)
Exit status was 1 but expected it to be 0. Output:
/Users/jared/Projects/translator/lib/translator.rb:12:in `initialize': wrong number of arguments (0 for 1) (ArgumentError)
Feature: Pig Latin
In order to amuse others or conceal the meaning of some text
As a user
I want to be able to translate from English to Pig Latin
Scenario: Translating English to Pig Latin
Given a file of English text
When I ask to translate it to Pig Latin
Then I should see it in Pig Latin
class Loan < ActiveRecord::Base
def self.pending
where state: 'pending'
end
def self.delinquent
where('expires_on < ?', Time.zone.today)
.where('repaid = ?', false)
end
end