Skip to content

Instantly share code, notes, and snippets.

View jedschneider's full-sized avatar

Jed Schneider jedschneider

View GitHub Profile
C:\ABC_TABLET\apps\ruby\bin\ruby.exe C:\ABC_TABLET\apps\ruby\bin\gem update --system
C:\ABC_TABLET\apps\ruby\bin\rake db:abort_if_pending_migrations
class Hello
def hi
puts "hello world"
end
end
@jedschneider
jedschneider / ReleaseFormLifeCycleTest.rb
Created April 9, 2010 17:49
a little integration test trick
require 'test_helper'
class ReleaseFormLifeCycleTest < ActionController::IntegrationTest
context "a release form lifecycle" do
setup do
@admin = Factory(:administrator)
login
end
should "sign a new release, go to the clients page, revoke, and prompt for a new release" do
@client = create_client
class ScreenerTest < ActiveSupport::TestCase
context "a screener" do
context "yes/no questions" do
setup {@screener = Factory.build(:screener, :answers => [Factory(:answer)])}
should "not allow blank answers for yes/no questions" do
assert_equal false, @screener.valid?
end
should "define the error message for invalidly answered yes/no questions" do
@screener.save
assert_equal "All yes/no answers must be answered yes or no",
class Answer< ActiveRecord::Base
validate :my_custom_validation
def my_custom_validation
errors.add "All whammies, no money" if value.blank?
end
end
class Survey<ActiveRecord::Base
has_many :answers
Hardware:
Hardware Overview:
Model Name: iMac
Model Identifier: iMac6,1
Processor Name: Intel Core 2 Duo
Processor Speed: 2.16 GHz
Number Of Processors: 1
Total Number Of Cores: 2
Hardware:
Hardware Overview:
Model Name: MacBook Pro
Model Identifier: MacBookPro4,1
Processor Name: Intel Core 2 Duo
Processor Speed: 2.4 GHz
Number Of Processors: 1
Total Number Of Cores: 2
# from http://github.com/dchelimsky/railsconf2010-app
Then /^I (should|should not) see the following cards in the "([^"]*)" swimlane:$/ do |see, swimlane_name, expected_cards|
swimlane = Swimlane.find_by_name(swimlane_name)
within("#swimlane-#{swimlane.id}") do
expected_cards.hashes.each do |row|
should_or_should_not = see.gsub(/ /, '_')
page.__send__(should_or_should_not, have_content(row["title"])) # Cleverness warning!
end
end
Then /^I should see the following cards:$/ do |expected_cards|
expected_cards.hashes.each do |row|
page.should have_content(row["Title"])
end
end