This file contains 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
$ cd sample | |
$ ant debug install | |
$ cd ../sampletest | |
$ ant test | |
test: | |
[echo] Running tests ... | |
[exec] | |
[exec] com.sample.GreeterTest: | |
[exec] Failure in testExpectAGreetingAfterSubmittingAName: |
This file contains 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
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 |
This file contains 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
>> 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 |
This file contains 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 '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' |
This file contains 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 Account < ActiveRecord::Base | |
attr_accessible :name, | |
:account_type, | |
:balance | |
def self.import(file, account_importer) | |
account_importer.import file | |
end | |
end |
This file contains 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 Account < ActiveRecord::Base | |
attr_accessible :name, | |
:account_type, | |
:balance | |
def self.import(file, account_importer = CsvAccountImporter.new) | |
account_importer.import file | |
end | |
end |
This file contains 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 '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 |
This file contains 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
$ 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) |
This file contains 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
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 |
This file contains 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 Loan < ActiveRecord::Base | |
def self.pending | |
where state: 'pending' | |
end | |
def self.delinquent | |
where('expires_on < ?', Time.zone.today) | |
.where('repaid = ?', false) | |
end | |
end |
NewerOlder