Skip to content

Instantly share code, notes, and snippets.

View practicingruby's full-sized avatar

Gregory Brown practicingruby

View GitHub Profile

When a user signs up successfully, they will be sent to the dashboard. We will send them an email confirming the sign up.

test "A successful signup" do
  simulated_user.visit do
    sign_up(email: "guybush@threepwood.com",
            name:  "Guybush Threepwood",
            password: "ilikerootbeer")

 current_page.is("/dashboard")

Signup

  • Users need to sign up to use our app because [purpose]. We don't want to scare users with a long form though, so we'll simply ask for the minimum information. In our case that's the name, email and a password.

  • We don't ask users to confirm the password because they can easily reset it using the Forgot Password? link.

  • All fields are required, so the user will not be signed up if they fail to provide any of the required information.

  • Emails are unique, so using an email that already exists also results in an error.

@practicingruby
practicingruby / calc.rb
Created July 12, 2012 15:22
Code Golf RPN Calculator!
p((_=[gets.split,[],"+-**/"])[0].map{|__|__=~/[0-9\.]+/?_[1]<<__.to_f : _[2][__]?_[1]<<_[1].pop.send(__,_[1].pop):0}[0][0])
class Blog
attr_reader :entries
attr_writer :post_maker
def initialize
@entries = []
end
def title
"Underwater Basketweaving"
class Blog
attr_reader :entries
attr_accessor :post_class
def initialize
@entries = []
end
def title
"Underwater Basketweaving"
@practicingruby
practicingruby / gist:1232567
Created September 21, 2011 16:34 — forked from stevemorris/gist:1232537
Circuitry
module Circuitry
extend self
def []=(name, definition)
circuits[name] = definition
end
def [](name)
circuits[name]
end
require "minitest/autorun"
# inspired by some code from Chris Wanstrath (shared w. me by Ryan Smith)
# https://gist.github.com/25455
#
# heavily modified by Gregory Brown at this point..
def context(*args, &block)
return super unless (name = args.first) && block
module PlayingCards
class Card
attr_accessor :rank, :suit
def initialize(a_rank, a_suit)
@rank = parse_rank a_rank
@suit = parse_suit a_suit
end
module Measurable
def area
width * height
end
attr_reader :width, :height
end
class Rectangle
include Measurable
## Extract Class (http://refactoring.com/catalog/extractClass.html)
class Person
attr_accessor :name, :office_area_code, :office_number
def telephone_number
[office_area_code, office_number].join('-')
end
end