This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require 'rubygems' | |
| require 'capybara' | |
| require 'capybara/dsl' | |
| require "selenium-webdriver" | |
| Capybara.run_server = false | |
| Capybara.app_host = 'http://financials.morningstar.com' | |
| mimes = [ | |
| "text/plain", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Driver program for this hidden yahoo financie api from here | |
| # http://greenido.wordpress.com/2009/12/22/yahoo-finance-hidden-api/ | |
| # | |
| # | |
| require "csv" | |
| require "net/http" | |
| require "uri" | |
| def uri(symbols, format) | |
| res= "http://download.finance.yahoo.com/d/quotes.csv?" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require "rspec" | |
| class Person | |
| # Run the tests. | |
| # For funzies, implement #salutation, #goodbye | |
| end | |
| module IntegrationCheck |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Ruby hash w/ Javascript dot notation | |
| # | |
| # | |
| # | |
| # The Code | |
| # | |
| class Hash |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # spec/stub_sync.rb | |
| # StubSync keeps track of the instance and class methods that are stubbed by the | |
| # class under test. | |
| # | |
| # Say Wha!?!?!?! | |
| # | |
| # Why would you stub the class under test, thats just crazy! | |
| # Yes it is! Crazy like a fox. | |
| # |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Background | |
| Raise.com is built on top of Spree. We have in-lined spree, and have decorators | |
| on the models to beat the band. We want to move away from Spree altogeher. | |
| This involves taking the models from Spree, moving them to the Raise | |
| base app. This merge has the potential to create lots of big classes. Big classes | |
| are difficult to maintain. One of the first steps towards returning classes/models to | |
| being "right sized." is splitting the business logic and the persistence. | |
| What I did |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Splitting Rails models let me count the ways | |
| # | |
| # Assume that I start with the base class and tests | |
| # | |
| class Transactions < ActiveRecord::Base | |
| # contains :amount | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Example 1 | |
| # This is cool! | |
| if x = true | |
| puts x | |
| end | |
| # => true | |
| # Example 2 | |
| # Statement modifiers with local variable assignment can explode! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| names = %w[SK Steve Pedro Anthony Milo Xiping] | |
| Person = Struct.new :name | |
| module Helloable | |
| def hello_all_the_names | |
| each { |person| puts "Helloable | Hello #{person.name}" } | |
| end | |
| end | |
| # An interesting way to add functionality to an array is to extend it |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Integer vs Float div by zero gotchas | |
| # | |
| # | |
| 1 / 0 = [answer] | |
| 1.0 / 0 = [answer] | |
| 1 / 0.0 = [answer] | |
| 0 / 0.0 = [answer] | |
| # String concatenation vs interpolation | |
| x = 5 |