うちのマンションにはドアポストと集合ポストの2種類がある。集合ポストは奥まったところにあるので確認を忘れがち。
面倒なので集合ポストをガムテで封印してこれを貼った。

ヌーは何か魔除けっぽい感じがする。
うちのマンションにはドアポストと集合ポストの2種類がある。集合ポストは奥まったところにあるので確認を忘れがち。
面倒なので集合ポストをガムテで封印してこれを貼った。

ヌーは何か魔除けっぽい感じがする。
iTunesとの音楽のシンクに必要。USBデバッグモードの設定を表示させるにはまずデベロッパーモードをオンにする必要があります。
How To Enable USB Debugging on Android 4.3 Phones and TabletsTechverse
![]()
Finally tap multiple times ( 10 times ) quickly on the Build number and eventually you will be able to see a message that developer options are enabled.
そしてその方法は・・・
「ビルドナンバーのところを10回ぐらい素早くタップしろ」

「assertありゃええねん」
前回のdecoratorのテストのassertをminitest-power_assertに変えてみた。# Gemfile:
group :test do
gem 'minitest-power_assert'
end
わざと間違えてみる。
# test/decorators/user_decorator_test.rb:
require 'test_helper'
class UserDecoratorTest < ActiveSupport::TestCase
def setup
ActiveDecorator::ViewContext.current = controller.view_context
@user = ActiveDecorator::Decorator.instance.decorate users(:jean)
end
test 'full_name' do
assert { @user.full_name == 'Hugh Jackman' }
end
end
$ rake test test/decorators/user_decorator_test.rb
Run options: --seed 52969
# Running:
F
Finished in 0.134274s, 7.4475 runs/s, 7.4475 assertions/s.
1) Failure:
UserDecoratorTest#test_full_name [/Users/komagata/code/active_decorator-test_unit/test/decorators/user_decorator_test.rb:10]:
assert { @user.full_name == 'Hugh Jackman' }
| | |
| | false
| "Jean Valjean"
#<User id: 758109964, first_name: "Jean", last_name: "Valjean", website: "http://jeanvaljean.com", created_at: "2014-07-01 15:35:12", updated_at: "2014-07-01 15:35:12">
1 runs, 1 assertions, 1 failures, 0 errors, 0 skips
こりゃええ!
active_decoratorがtest_unitでもrspecと同じくそのままじゃhelperを使ったdecoratorのtestが書けないんだけど下記のようにすれば動く。(active_decoratorのREADMEに書いてあるdecoratorのテストの例)
# test/test_helper.rb:
class ActiveSupport::TestCase
include ActionView::TestCase::Behavior
end
# test/decorators/user_decorater_test.rb:
require 'test_helper'
class UserDecoratorTest < ActiveSupport::TestCase
def setup
ActiveDecorator::ViewContext.current = controller.view_context
@user = ActiveDecorator::Decorator.instance.decorate users(:jean)
end
test 'full_name' do
assert_equal 'Jean Valjean', @user.full_name
end
test 'link' do
assert_equal '<a href="http://jeanvaljean.com">Jean Valjean</a>', @user.link
end
end
$ rake test test/decorators/user_decorator_test.rb
Run options: --seed 37850
# Running:
..
Finished in 0.032828s, 60.9236 runs/s, 60.9236 assertions/s.
2 runs, 2 assertions, 0 failures, 0 errors, 0 skips
全部のコードはこちら。
もっときれいな書き方があったらぜひ知りたいです。
direnvを入れると.envrcってファイル置いておくとそのディレクトリに移動したとき実行してくれる。
$ brew install direnv
$ vi ~/.zshenv
eval "$(direnv hook $0)"
railsプロジェクトに下記のファイルを置く。
$ vi .envrc
export PATH=$PWD/bin:$PATH
このディレクトリでのdirenv実行を許可する。
$ direnv allow .怖話はminitestに書き換えつつあるんですが、Bizerでは他の開発者に気を使ってrspecを使っています。
Bizerをrails4.1に上げたので、「ヒャッハー、デフォルトでtravel_toが使えるからtimecop削除できるぜー!」と思ったのですがrspecじゃそのままじゃ使えない。(クソがぁ
Before:
it 'coupon is expired.' do
# FIXME: travel_to in rails 4.1
Timecop.travel(2014, 5, 10, 0, 0, 0) do
expect(expired_coupon_user.free_by_coupon?).to be_false
end
end
After:
# spec/spec_helper.rb:
RSpec.configure do |config|
config.include ActiveSupport::Testing::TimeHelpers
end
it 'coupon is expired.' do
travel_to Time.new(2014, 5, 10, 0, 0, 0) do
expect(expired_coupon_user.free_by_coupon?).to be_false
end
end
今までTime.nowやDate.todayを内部で使うメソッドはテストしやすいように
def metrix(now = Time.now); ... end
みたいに書いてたんですが、デフォルトで気軽にtravel_toが使えるならやらなくていいかな!
C-t: カーソル部分のタグにジャンプ
C-o: 前いた場所に戻る(tagに限らずいつも使いまくるヤツ)
g C-t: タグ候補が複数ある場合に候補一覧を表示
この3つだけでクッソはかどる
IDEでは当然の機能ですが、クラスやメソッドの定義に飛べるのって便利ですよね。vimやemacsでは設定すればできるんだろうけどやってる人あんまり見ない。
開いてるbuffer内のものしか飛べないとか、明示的にtag生成コマンド実行とか論外。
そんな折、Gemfileのgemを含めて保存時自動tag生成してくれるvim-tagsというpluginがとても良かったのでご紹介。
$ brew install ctags
# ~/.vimrc:
Bundle 'szw/vim-tags'
let g:vim_tags_project_tags_command = "/usr/local/Cellar/ctags/5.8/bin/ctags -f tags -R . 2>/dev/null"
let g:vim_tags_gems_tags_command = "/usr/local/Cellar/ctags/5.8/bin/ctags -R -f Gemfile.lock.tags `bundle show --paths` 2>/dev/null"
set tags+=tags,Gemfile.lock.tags
macデフォのctagsはbsdで色々違うのでbrewで入れてfullpath指定。
ファイル保存時にtagsファイルを生成。ちょっと遅くなるので非同期実行するvim-dispatch pluginとの連携も試してみたいと思います。
とにかく機能が細かくgemに分割される昨今。これははかどる!
2.5 Cookies serializer
Applications created before Rails 4.1 uses Marshal to serialize cookie values into the signed and encrypted cookie jars. If you want to use the new JSON-based format in your application, you can add an initializer file with the following content:
Rails.application.config.action_dispatch.cookies_serializer = :hybrid
cookieのserializerがrubyのMarshalからJSONに変わったって部分。
これcookieがバージョンまたいでないと発生しないからテスト面倒だねえ・・・。
EngineYardCloudのEnvironmentをのぞいてみたらruby2.1.2に対応してたので怖話をアップデートしました。
stackのversionが上がる時ほど警戒は必要無いとは思いますが、clone environmentしてそちらをアップデートしてみて動作確認してから本アップデートをかけるのが正義。
ruby2.0.0-p247からのアップデートだったんですが、何の問題も無く完了しました。最新は気持ちいい。
Early AccessにはWebサーバーのpumaも来てるのでrails4.1系にしてpumaが正式版になったらこっちも変えたらかなり速くなるんじゃないかなと期待しております!