Skip to content

Instantly share code, notes, and snippets.

View aphexddb's full-sized avatar
💭
We are all made of stars

Gardiner Allen aphexddb

💭
We are all made of stars
View GitHub Profile
@aphexddb
aphexddb / factory_girl_spec.rb
Last active December 18, 2015 03:09
To make sure that your models are valid you can automatically test all of your factories with the following code
require 'spec_helper'
describe 'validate FactoryGirl factories' do
FactoryGirl.factories.each do |factory|
context "with factory for :#{factory.name}" do
subject { FactoryGirl.build(factory.name) }
it "is valid" do
is_valid = subject.valid?
is_valid.should be_true, subject.errors.full_messages.join(',')
@aphexddb
aphexddb / Rails API Design.md
Last active December 17, 2015 19:58
Creating a flexible, modern API in Rails 3

This is a guide to creating a basic API in Rails for consumption by Ember.js or your favorite framework. Key areas are support of CORS requests and Jbuilder for creating a self-documenting API.

Add these gems to your Gemfile

gem 'rack-cors', :require => 'rack/cors'

gem 'jbuilder'

=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('Link Text') # Click either a link or a button
click('Button Value')