Skip to content

Instantly share code, notes, and snippets.

@cmilfont
Last active August 29, 2015 14:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cmilfont/71814ed0c6efa09314e6 to your computer and use it in GitHub Desktop.
Save cmilfont/71814ed0c6efa09314e6 to your computer and use it in GitHub Desktop.
Incomplete, but an idea about that DHH wrote https://gist.github.com/dhh/4849a20d2ba89b34b201
#RSPEC
require 'spec_helper'
describe EmployeesController do
let(:employee_params) { ... }
describe "POST create" do
it "should create bla bla bla" do
employee = mock_model(Employee, id: 666)
Employee.should_receive(:create).with(employee_params).and_return employee
post :create, employee: employee_params
end
end
end
#RAILS CONTROLLER
class EmployeesController < ApplicationController
def create
@employee = Employee.create(employee_params)
respond_with @employee
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment