Skip to content

Instantly share code, notes, and snippets.

View ZachBeta's full-sized avatar

Zach Morek ZachBeta

View GitHub Profile
=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 June 10, 2012 16:32
Rake task to create fixtures from test database in Rails 3.1
#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|
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:2820114
Created May 28, 2012 17:06
Zachary[0,4]
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 April 25, 2012 18:37 — forked from thommahoney/gist:2491946
RailsConf 2012 Lightning Talks
5 min:
~Objective-C + Rails:
Communicating w/rails from iOS/mac OS
Dan Hassin
1 min:
~Painless Javascript
koting hatduklgg
with wind tunnel
<!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>
@ZachBeta
ZachBeta / _form.html.erb
Created August 14, 2011 02:58
nested form error
<%= 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>