Skip to content

Instantly share code, notes, and snippets.

require 'rubygems'
require 'active_support'
APPD = "#{File.dirname(__FILE__)}/.."
MODD = "#{File.dirname(__FILE__)}/../spec/models"
FACTD = "#{File.dirname(__FILE__)}/../spec/factories"
class SpecGenerator
ASSOCIATION_CONVERSION_TABLE = [
["has_many", "have_many"],
ActionController::Routing::Routes.draw do |map|
map.resources :communities
SprocketsApplication.routes(map)
# Translate::Routes.translation_ui(map) if RAILS_ENV != "production"
# map.root :controller => 'folders', :action => 'index'
# map.connect '/icons/:key', :controller => :icons, :action => :show
#
# map.connect 'assets/:id/:style/:filename', :controller => 'uploads', :action => 'download', :conditions => { :method => :get }, :requirements => { :filename => /.*/ }
## _item.haml
...
= comment_form(item)
## comments_helper.rb
...
def comment_form(comment=nil)
partial 'comments/form',
:comment => comment,
:style => 'display: block'
module FactoryHelper
def rand_obj(array, obj)
array.delete(obj)
array[rand(array.size-1)]
end
def generate_name
name = Faker::Name.name.split(' ')
[name[0], name[1]]
end
class Multistage
class << self
[:development, :test, :cucumber, :staging, :production].each do |env|
self.send(:define_method, "#{env}?") do
ENV["RAILS_ENV"] == env.to_s
end
end
end
Factory.define :picoticker_block do |f|
f.association :user
f.association :folder
f.association :community
f.url "http://rss.tek.com/cmsrss/rss.do?cn=tektronix&lc=en&ct=feed&from=rss"
end
describe "pulling" do
it "should pull items from picoticker and create items" do
user = Factory.create(:user)
picoticker_block = Factory.create(:picoticker_block)
picoticker_block.user = user
picoticker_block.pull!
picoticker_block.picoticker_items.should_not be_empty
end
end
@dreamr
dreamr / gist:719605
Created November 29, 2010 05:12
enki_ticket_6_patch.diff
From 9fbf4ca64382f48bc2df3397fbfe267172581149 Mon Sep 17 00:00:00 2001
From: James OKelly <[email protected]>
Date: Sun, 28 Nov 2010 21:10:07 -0800
Subject: [PATCH] removed pending spec on /pages route, works as intended
---
spec/controllers/pages_routing_spec.rb | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/spec/controllers/pages_routing_spec.rb b/spec/controllers/pages_routing_spec.rb
@dreamr
dreamr / gist:719608
Created November 29, 2010 05:20
JSON specs (DESTROY) failing for comment and post
1) Admin::CommentsController handling DELETE to destroy, JSON request renders comment as json
Failure/Error: response.should contain(/#{Regexp.escape(@comment.to_json)}/)
expected the following element's content to match /\{"comment":\{"body_html":null,"created_at":null,"author":"xavier","body":null,"updated_at":null,"post_id":null,"author_email":null,"author_url":null\}\}/:
{"comment":{"comment":{"created_at":null,"body_html":null,"body":null,"author":"xavier","updated_at":null,"post_id":null,"author_email":null,"author_url":null}},"undo_path":"/admin/undo_items/%23%5BRSpec::Mocks::Mock:0x82b32e8c%20@name=%22undo_item%22%5D/undo","undo_message":"hello"}
# ./spec/controllers/admin/comments_controller_spec.rb:129
2) Admin::PostsController handling DELETE to destroy, JSON request renders post as json
Failure/Error: response.should contain(/#{Regexp.escape(@post.to_json)}/)
expected the following element's content to match /\{"post":\{"cached_tag_list":null,"slug":null,"body_html
@dreamr
dreamr / gist:719629
Created November 29, 2010 05:53
enki_ticket_8.diff
From cfbcb70ab0a17ed97355166b4cfcab3a9f323d67 Mon Sep 17 00:00:00 2001
From: James OKelly <[email protected]>
Date: Sun, 28 Nov 2010 21:51:59 -0800
Subject: [PATCH] fixed two failing json specs in admin/posts and admin/comments
---
app/controllers/admin/pages_controller.rb | 10 ++++++----
app/controllers/admin/posts_controller.rb | 10 ++++++----
2 files changed, 12 insertions(+), 8 deletions(-)