Skip to content

Instantly share code, notes, and snippets.

View novohispano's full-sized avatar

Jorge Téllez novohispano

View GitHub Profile
exports.makeMeal = function (meal) {
return "Preparing " + meal
}
var serveDrink = function (drink) {
return "Serving " + drink
}
class Phoenix
attr_reader :name, :age, :lives
def initialize(name)
@name = name
@age = 0
@alive = true
@lives = 1
end
class Centaur
attr_reader :name, :breed
def initialize(name, breed)
@name = name
@breed = breed
@standing = true
@actions = 0
end
class BeerSong
def verses(beginning, ending = 0)
song = ""
beginning.downto(ending).each do |n|
song << verse(n) + "\n"
end
song
end
def verse(n)
require 'minitest/autorun'
require 'minitest/pride'
require_relative 'beer_song'
class BeerSongTest < MiniTest::Unit::TestCase
def beer_song
@beer_song = ::BeerSong.new
end
module ObjectCreationMethods
def new_ci_source(overrides = {})
defaults = {name: "testrepo", owner: "blairtest", active:false}
CiSource.new(defaults.merge(overrides))
end
def create_ci_source(overrides = {})
ci_source = new_ci_source(overrides)
@novohispano
novohispano / item_spec.rb
Created January 30, 2014 23:17
Example of Model Testing
require 'spec_helper'
describe Item do
it "should exist" do
item = Item.new
expect item
end
it "should have a name" do
item = Item.new(name: "hammer")
@novohispano
novohispano / user.rb
Created January 21, 2014 22:33
Rails Model Testing Exercise
class User < ActiveRecord::Base
has_many :orders
validates :name, presence: true
validates :email, presence: true, uniqueness: true
end
@novohispano
novohispano / beer-song.rb
Last active January 2, 2016 20:49
Beer Song excercism solution.
require 'forwardable'
class BeerSong
def verse(number)
fragments = build_fragments(number)
Verse.new(fragments).to_s
end
def verses(start, ending = 0)
song = ""
@novohispano
novohispano / item.rb
Created January 9, 2014 23:00
Testing with Darryl
class Item < ActiveRecord::Base
has_many :order_items
has_many :orders, through: :order_items
validates :name, presence: true, uniqueness: true
validates :description, presence: true, uniqueness: true
end