Skip to content

Instantly share code, notes, and snippets.

Avatar

Gregory Brown practicingruby

View GitHub Profile
View signup.feature.md

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")
View signup.feature.md

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 Jul 12, 2012
Code Golf RPN Calculator!
View calc.rb
p((_=[gets.split,[],"+-**/"])[0].map{|__|__=~/[0-9\.]+/?_[1]<<__.to_f : _[2][__]?_[1]<<_[1].pop.send(__,_[1].pop):0}[0][0])
View gist:1764006
class Blog
attr_reader :entries
attr_writer :post_maker
def initialize
@entries = []
end
def title
"Underwater Basketweaving"
View gist:1763981
class Blog
attr_reader :entries
attr_accessor :post_class
def initialize
@entries = []
end
def title
"Underwater Basketweaving"
View gist:1232567
module Circuitry
extend self
def []=(name, definition)
circuits[name] = definition
end
def [](name)
circuits[name]
end
View test-spec-mini.rb
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
View card.rb
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
View inheritance.rb
module Measurable
def area
width * height
end
attr_reader :width, :height
end
class Rectangle
include Measurable
View refactoring patterns
## 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
You can’t perform that action at this time.