Skip to content

Instantly share code, notes, and snippets.

View onethirtyfive's full-sized avatar

Joshua Morris onethirtyfive

View GitHub Profile
Error:
Scenario: Visiting landing page # features/landing.feature:5
Given I am on the landing page # features/step_definitions/web_steps.rb:15
undefined method `visit' for #<Cucumber::Rails::World:0x63cc072> (NoMethodError)
./features/step_definitions/web_steps.rb:15:in `/^(?:|I )am on (.+)$/'
features/landing.feature:6:in `Given I am on the landing page'
Then I should see a welcome message # features/landing.feature:7
From features/support/env.rb:
a typical, if short Rails 3.0 'rake routes' output for a resource defined in routes with 'resources :posts'
[22:15][me@localhost:rails_project(master)]$ rake routes
(in /home/me/Code/rails_project)
GET /posts(.:format) {:controller=>"posts", :action=>"index"}
posts POST /posts(.:format) {:controller=>"posts", :action=>"create"}
new_post GET /posts/new(.:format) {:controller=>"posts", :action=>"new"}
GET /posts/:id(.:format) {:controller=>"posts", :action=>"show"}
PUT /posts/:id(.:format) {:controller=>"posts", :action=>"update"}
post DELETE /posts/:id(.:format) {:controller=>"posts", :action=>"destroy"}
test: for #content_tag method should support tags with haml. (TestTagHelpers) [test/test_tag_helpers.rb:52]:
expected following output to contain a <p class='test' id='test1'>Test 1</p> tag:
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
<style type="text/css">
body { text-align:center;font-family:helvetica,arial;font-size:22px;
color:#888;margin:20px}
#c {margin:0 auto;width:500px;text-align:left}
@onethirtyfive
onethirtyfive / gist:1079730
Created July 13, 2011 04:42
How to query this database with DM query language?
Here's the relevant part of the schema, simplified, showing relations:
CREATE TABLE "units" (
"id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
"name" VARCHAR(50)
);
CREATE TABLE "champions" (
"unit_id" INTEGER NOT NULL,
"title" VARCHAR(50),
@onethirtyfive
onethirtyfive / gist:1083182
Created July 14, 2011 19:06
Class-Table Inheritance Meta-model for DataMapper
# This example is an alternative to implementing polymorphic associations
# using an ActiveRecord-esque 'type' column. In this model, there are many
# 'units.' Unit is an abstract supertype. Descendants are modeled referencing
# a unit by 'unit_id', a foreign key to the primary key in the units model.
# Note: This approach maintains referential integrity in the database via
# descendants' FK to unit.id; however, it is the application's responsibility
# to ensure that no two descendants reference the same unit. This is an
# intrinsic limitation of the "Class Table Inheritance" approach, but it's
# a lot better than maintaining "type" data that is opaque to the data store.
source 'http://rubygems.org'
RAILS_VERSION = '~> 3.1.0.rc4'
DM_VERSION = '~> 1.1.0'
RSPEC_VERSION = '~> 2.6.0'
CUCUMBER_VERSION = '~> 1.0.0'
gem 'activesupport', RAILS_VERSION, :require => 'active_support'
gem 'actionpack', RAILS_VERSION, :require => 'action_pack'
gem 'actionmailer', RAILS_VERSION, :require => 'action_mailer'
@onethirtyfive
onethirtyfive / gist:1141150
Created August 12, 2011 00:17
Grape presenters?
# lib/api/presenters/detailed_post.rb
module API
module Presenters
class DetailedPost
include ActiveModel::Serializers::JSON
include ActiveModel::Serializers::Xml
attr_accessor :post
delegate :attributes, :to => :post
letters = ['a', 'b', 'c', 'd']
letters.each do |letter|
puts letter
end
=> prints each letter. easy.
# below, '' is an empty string.
# result_string is initially '', the argument passed to inject.
@onethirtyfive
onethirtyfive / provider_example.js
Created August 25, 2011 17:44 — forked from mbbx6spp/provider_example.js
Illustration of provider idiom in Javascript for sharing with fellow Code PaLOUsa 2011 conference attendee from this morning #CPL11
/*
* Javascript provider idiom illustrated
* @author Susan Potter
* @date 2011-01-28
*/
// FinEnv "interface"
var FinEnv = function () {
return {
println: function (output) {
@onethirtyfive
onethirtyfive / keybase.md
Created September 15, 2016 20:26
keybase.md

Keybase proof

I hereby claim:

  • I am onethirtyfive on github.
  • I am onethirtyfive (https://keybase.io/onethirtyfive) on keybase.
  • I have a public key whose fingerprint is AB42 5AB2 8DD7 9A67 27AA 2CFE FF30 B1CA 93CB 1225

To claim this, I am signing this object: