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
| master>rails new yammy | |
| [... nothing to see here ...] | |
| master>cd yammy | |
| master>rails g model Dummy name:string | |
| invoke active_record | |
| create db/migrate/20110114203601_create_dummies.rb | |
| create app/models/dummy.rb | |
| invoke test_unit | |
| create test/unit/dummy_test.rb | |
| create test/fixtures/dummies.yml |
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
| ctrl-z | |
| bg | |
| touch /tmp/stdout | |
| touch /tmp/stderr | |
| gdb -p $! | |
| # In GDB | |
| p dup2(open("/tmp/stdout", 1), 1) | |
| p dup2(open("/tmp/stderr", 1), 2) |
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 'test_helper' | |
| class Admin::ArticlesControllerTest < ActionController::TestCase | |
| setup do | |
| @article = articles(:one) | |
| @typus_user = AdminUser.first | |
| @request.session[:typus_user_id] = @typus_user.id | |
| @request.env['HTTP_REFERER'] = '/admin/articles' | |
| 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
| # config/initializers/anything.rb | |
| Warden::Manager.after_set_user do |user, auth, opts| | |
| puts "Hello" | |
| debugger | |
| puts "Hi" | |
| end | |
| # fire up server |
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 | |
| require 'rubygems' | |
| require 'hpricot' | |
| require 'open-uri' | |
| require 'fileutils' | |
| prefix = Time.new.strftime("%F") | |
| FileUtils.mkdir(prefix) unless File.exists?(prefix) |
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
| class String | |
| def car | |
| self.match(/\s*(\S+)/) ? $1 : nil | |
| end | |
| def cbr(sep = ' ') | |
| self.split(sep).at(0) | |
| 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
| class TenCommandments | |
| # Had to change this method name, it didn't read well in my test suite. | |
| # t.should be_thou_shalt_not_kill??? Give me a break. Not idiomatic Ruby! | |
| # *I* would't be caught dead with those specs on. | |
| # def thou_shalt_not_kill | |
| # true | |
| # end | |
| # Much more idiomatic. Now my specs read like butter too. |
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 'spec_helper' | |
| describe Gig do | |
| before do | |
| @gig = Gig.new | |
| @gig.save | |
| end | |
| it "should belong to a user and validate the presence of a user" do |
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
| # A sample Guardfile | |
| # More info at https://github.com/guard/guard#readme | |
| guard 'rspec', :version => 2, | |
| :cli => '--colour --drb --format documentation --fail-fast', | |
| :all_after_pass => false, | |
| :all_on_start => false, | |
| :keep_failed => false, | |
| :notify => true do | |
| watch(%r{^spec/.+_spec\.rb$}) |
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 'spec_helper' | |
| describe Users::OmniauthCallbacksController do | |
| include Devise::TestHelpers | |
| before :each do | |
| @user = Factory.create(:user) | |
| request.env["devise.mapping"] = Devise.mappings[:user] | |
| end |