Skip to content

Instantly share code, notes, and snippets.

Avatar

Zach Morek ZachBeta

View GitHub Profile
View capybara cheat sheet
=Navigating=
visit('/projects')
visit(post_comments_path(post))
=Clicking links and buttons=
click_link('id-of-link')
click_link('Link Text')
click_button('Save')
click_on('Link Text') # Click either a link or a button
click_on('Button Value')
@ZachBeta
ZachBeta / fixtures.rake
Created Jun 10, 2012
Rake task to create fixtures from test database in Rails 3.1
View fixtures.rake
#put in lib/tasks/fixtures.rake
namespace :db do
namespace :fixtures do
desc 'Create YAML test fixtures from data in an existing database.
Defaults to development database. Set RAILS_ENV to override.'
task :dump => :environment do
sql = "SELECT * FROM %s"
skip_tables = ["schema_migrations"]
ActiveRecord::Base.establish_connection(:development)
(ActiveRecord::Base.connection.tables - skip_tables).each do |table_name|
View a_rose_by_any_other_name.rb
require 'test/unit'
class ARoseByAnyOtherName < Test::Unit::TestCase
def test_should_not_be_zack
assert_not_equal "Zachary"[0,4],"Zack"
# I'm not Zack Morris
# though I did have a huge crush on Kelly Kapowski
assert_not_equal "Zach Morek","Zack Morris"
end
def test_should_not_be_zac
assert_not_equal "Zachary"[0,4],"Zac"
View gist:2820114
require 'test/unit'
class ARoseByAnyOtherName < Test::Unit::TestCase
def test_should_not_be_zack
assert_not_equal "Zachary"[0,4],"Zack"
# I'm not Zack Morris
# though I did have a huge crush on Kelly Kapowski
assert_not_equal "Zach Morek","Zack Morris"
end
def test_should_not_be_zac
assert_not_equal "Zachary"[0,4],"Zac"
@ZachBeta
ZachBeta / gist:2492052
Created Apr 25, 2012 — forked from thommahoney/gist:2491946
RailsConf 2012 Lightning Talks
View gist:2492052
5 min:
~Objective-C + Rails:
Communicating w/rails from iOS/mac OS
Dan Hassin
1 min:
~Painless Javascript
koting hatduklgg
with wind tunnel
View application.html.erb
<!DOCTYPE html>
<html>
<head>
<title><%= content_for?(:title) ? yield(:title) : "TimeTracker" %></title>
<%= stylesheet_link_tag "application" %>
<%= javascript_include_tag :defaults, :cache => true %>
<%= csrf_meta_tag %>
<%= yield(:head) %>
</head>
<body>
View _form.html.erb
<%= form_for(@task) do |f| %>
<% if @task.errors.any? %>
<div id="error_explanation">
<h2><%= pluralize(@task.errors.count, "error") %> prohibited this task from being saved:</h2>
<ul>
<% @task.errors.full_messages.each do |msg| %>
<li><%= msg %></li>
<% end %>
</ul>
You can’t perform that action at this time.