MARUGOSHI.ORG

Bundler with Rails2

Bundler can use on Rails2 with to abide by the document, but I received deprecated warning with rake command.

rake/rdoctask is deprecated.  Use rdoc/task instead (in RDoc 2.4.2+)

Found articles said the warning can erase with downgrade rake to 0.8.7 but bundler depends on rake 0.9.2 but it can work with fixing what warning message said.

$ git diff Rakefile 
diff --git a/Rakefile b/Rakefile
index 3bb0e85..4602927 100644
--- a/Rakefile
+++ b/Rakefile
@@ -5,6 +5,6 @@ require(File.join(File.dirname(__FILE__), 'config', 'boot'))
 
 require 'rake'
 require 'rake/testtask'
-require 'rake/rdoctask'
+require 'rdoc/task'
 
 require 'tasks/rails'
cat Gemfile
<snip>
gem "rdoc"
<snip>

Rails3 + Omniauth + RSpec + Capybara

Omniauth provides mock for test so writing test is pretty easily done, I have nothing more to say.

describe "Sessions" do
  before(:all) do
    OmniAuth.config.test_mode = true
  end

  describe "sign in" do
    OmniAuth.config.mock_auth[:twitter] = { 
      "uid" => "12345",
      "provider" => "twitter",
      "user_info" => {
        "nickname" => "marugoshi",
      },  
    }    
    visit "/auth/twitter"
    it "should save provider user" do
      # implement
    end
  end

  after(:all) do
    click_link_or_button "Sign Out"
    OmniAuth.config.test_mode = false
  end
end

Let's fork and customize gems

This article had a good influence on me, but I’m ashamed that I don’t know how to fork gems in github. Thankfully, the article contains how to do it and I want to add more details.

Fork

First, fork some repository.

[email protected]:marugoshi/rails.git

Switch branch

I prefer stable version of rails rather than head so make local branch from stable branch.

$ git clone [email protected]:marugoshi/rails.git rails
$ cd rails
$ git checkout -b 3-0-stable origin/3-0-stable

Then specify git repository path and branch in Gemfile.

$ cat Gemfile
gem "rails", :git => "http://github.com/marugoshi/rails.git", :branch => "3-0-stable"

If original remote ripository’s changed

It can easy to track.

$ git remote add upsteam git://github.com/rails/rails.git
$ git fetch
$ git merge upstream/master