Skip to content

Instantly share code, notes, and snippets.

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
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
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
## _item.haml
...
= comment_form(item)
## comments_helper.rb
...
def comment_form(comment=nil)
partial 'comments/form',
:comment => comment,
:style => 'display: block'
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 => /.*/ }
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"],
iterate app/models/*.rb
read file and pull in these
has_many :items
has_many :folders
has_many :blocks
has_many :picoticker_blocks
has_one :login_cookie
Feature: Dream Resource Generation
In order to develop outside-in quickly
As a rails developer
I want to generate a restful resource and specs quickly
Scenario: Developer calls dream_resource with: user email:string
Given I have a new rails app
When I run the dream_resource generator with: user, args: "email:string"
Then the "user" controller should contain actions:
|action |
~/development/oss/dream_gens (alex.heaton): autospec
loading autotest/cucumber_rspec
Warning: $KCODE is NONE.
/Library/Ruby/Gems/1.8/gems/treetop-1.4.3/lib/treetop/ruby_extensions/string.rb:31: warning: method redefined; discarding old indent
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby /Library/Ruby/Gems/1.8/gems/rspec-1.3.0/bin/spec --autospec /Users/dreamr/development/oss/dream_gens/spec/dream_feature_generator_spec.rb /Users/dreamr/development/oss/dream_gens/spec/dream_resource_generator_spec.rb -O spec/spec.opts
..........
Finished in 0.226597 seconds
10 examples, 0 failures
require 'rubygems'
require 'spork'
Spork.prefork do
ENV["RAILS_ENV"] ||= 'test'
require File.expand_path(File.join(File.dirname(__FILE__),'..','config','environment'))
require 'spec/autorun'
require 'spec/rails'
require 'remarkable_rails'
require 'faker'