MARUGOSHI.ORG

I'm Maoto Tokuyama, husband, father and web developer.

  • Facbook

20
Oct
2011

Wordrobe - tiny app for memorizing words

Today I deployed my tiny application for memorizing english words for Japanese(include me).

Wordrobe

Wordrobe

This is so-called weekend application, I had built it during without daily working hours. I want to implove application as long as time allows. If you want to see codes, I already pushed to Github publicly. Source code is here. I must confess that I didn’t write any test codes.

15
Oct
2011

Request Spec + Capybara-webkit + Rails3-jquery-autocomplete

This is a tips for not only related with autocomplete but more comprehensive with JavaScipt keydown event. Codes use keydown event, it’s not enough only fill_in, it needs executing keydown event.

1
2
3
4
5
6
7
8
it "should enable click tag", js => true do
  fill_in "entry[tag_list]", :with => "ta"
  page.execute_script %Q{ $('#entry_tag_list').trigger("focus") }
  page.execute_script %Q{ $('#entry_tag_list').trigger("keydown") }
  sleep(3)
  selector = '.ui-menu-item a:contains(\"tag name\")'
  page.execute_script " $('#{selector}').trigger(\"mouseenter\").click();"
end

10
Oct
2011

How to use seeds during test

Ocassionally I want to use seed data with feature test like Request Spec and I find a good answer.

1
2
3
4
5
6
# {Rails.root}/spec/spec_helper.rb

Dir[Rails.root.join("spec/support/**/*.rb")].each {|f| require f}

Rspec.configure do |config|
end
1
2
3
# {Rails.root}/spec/support/ext/seeds.rb

require Rails.root.join("db", "seeds")

23
Jun
2011

Bundler with Rails2

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

1
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 and so it can work with fixing what warning message said.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
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>

16
Apr
2011

Rails3 + Omniauth + RSpec + Capybara

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

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
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