Skip to content

Instantly share code, notes, and snippets.

@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'
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
class Account < ActiveRecord::Base
attr_accessible :name,
:account_type,
:balance
def self.import(file, account_importer)
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
$ rake test:pattern[point]
Test 'test_point.c'
-------------------
Compiling point.c...
Linking test_point.out...
Running test_point.out...
-------------------------
OVERALL UNIT TEST SUMMARY
#include "point.h"
struct point MakePoint(int x, int y)
{
struct point pt;
pt.x = x;
pt.y = y;
return pt;
}
$ gem install ceedling