Skip to content

Instantly share code, notes, and snippets.

@caser
caser / gist:7694610
Created November 28, 2013 16:31
Stripe error dump
Stripe::InvalidRequestError in DowngradesController#create
Invalid request. Hint: check the encoding for your request parameters and URL (http://en.wikipedia.org/wiki/percent-encoding). For assistance, email support@stripe.com.
Rails.root: /home/vagrant/code/twiki
Application Trace | Framework Trace | Full Trace
app/controllers/downgrades_controller.rb:8:in `create'
Request
Parameters:
%html{html_attrs("en-US")}
%head
%title Twiki
= stylesheet_link_tag "application", :media => "all"
= javascript_include_tag "application"
= csrf_meta_tags
%body
.container
%h2.text-center Twiki: Social, Markdown Wikis
.row-fluid
.hero-unit.span8.offset2
.row-fluid.span8.offset2
%h4 Create and share Markdown Wikis
.row-fluid.span4.offset4
%p
= link_to "Sign In", new_user_session_path, class: 'btn btn-primary btn-block'
class Section
include Mongoid::Document
include Mongoid::Timestamps
# TODO - decide if this should be before_save or before_update
before_save :save_old_version
attr_accessible :title, :content
# Define fields
@caser
caser / gist:7590765
Last active December 29, 2015 01:09
Wiki

RSpec output:

Failures:

  1) WikisController PUT #update with invalid attributes does not change @wiki's attributes with an invalid author
     Failure/Error: @wiki.title.should_not eq("The best wiki ever.")
       
       expected: value != "The best wiki ever."
            got: "The best wiki ever."
 
@caser
caser / gist:7582382
Created November 21, 2013 14:25
RSpec for wiki controller
Failures:
1) WikisController POST #create with invalid attributes re-renders the new method
Failure/Error: post :create, wiki: attributes_for(:invalid_wiki)
Mongoid::Errors::Validations:
Problem:
Validation of Wiki failed.
Summary:
The following errors were found: Author can't be blank, Title can't be blank
@caser
caser / gist:7564912
Created November 20, 2013 15:21
controller spec users
require 'spec_helper'
describe UsersController do
describe "GET #index" do
it "populates an array of users" do
user = create(:user)
get :index
assigns(:users).should eq([user])
end
@caser
caser / gist:7452069
Last active December 28, 2015 05:48
potential resources
Resources:
• user
⁃ create
⁃ read
⁃ update
⁃ change email
⁃ change password
⁃ delete
• wiki
⁃ create
@caser
caser / gist:7256196
Created October 31, 2013 20:07
Sign Up
Feature: Sign up
In order to sign up for a free account
A user
Should provide a user name, password, and email address
Scenario: Signs up for a free account
Given I am on the "sign up" page
And I fill in "username" with "casey"
And I fill in "password" with "secret"
And I fill in "email" with "casey@email.me"
@caser
caser / casey_redis.rb
Created October 24, 2013 21:18
casey_redis.rb
# config/initializers/redis.rb
require 'rubygems'
require 'redis'
REDIS = Redis.new()
class User
attr_accessor :name, :id
def initialize(name, id)