サクサク読めて、アプリ限定の機能も多数!
トップへ戻る
猫
yohfee.hatenadiary.org
初めてやったので忘れてもいいようにメモ。 先日のZenraプラグインのためにフォークしたTermtterですが、Pull Requestするの忘れてるうちに何回かコミットされてるのと、別のプラグインを作ってみようかと思うところで、整理しておこうかというわけです。 参照:Fork a repo - GitHub Help % git remote add jugyo git://github.com/jugyo/termtter.git % git fetch % git merge jugyo/master こんだけ。簡単だね。pullでもいいみたいだしrebaseでもいいのかな?そういえばPro Gitまだ読み途中だったっけ…
すでに前回のすごいぞRSpec(shared example group編) - ぷろぐらまねがで登場してるけどあらためてletを調べるよ。rspec-core(2.5.1)/features/helper_methods/let.featureを参考に。 let 要するにメモ化するわけで、同一サンプル内だと同じオブジェクトを使いまわせるのだな。違うサンプルでは改めて評価される。さらに遅延評価なので実際に評価されるのは最初にメソッドが呼ばれたときだ。 $count = 0 describe 'let' do let(:count) { $count += 1 } it 'memoizes the value' do count.should == 1 count.should == 1 end it 'is not cached across examples' do count.shou
ちょっと前に話題になったRSpecのスライドがステキだったよね。でもRSpecはまだまだ底知れない気がするので自分でもいろいろと調べてみようと思った次第。 まずはrspec-core(2.5.1)/features/example_groups/shared_example_group.featureを参考にshared example groupについて調べてみたよ。 例1:テストを共有できる require "set" shared_examples_for 'a collection' do subject { described_class.new [7, 2, 4] } its(:size) { should eq 3 } it { should include 7 } it { should_not include 9 } end describe Array do it_be
例のごとく既出だけど今回はattribute of subjectについて。rspec-core(2.5.1)/features/subject/attribute_of_subject.feature参考。「it { subject.first.size.should eq 2 }」とかするのやだよね。そんなときはitsを使えばステキになるよって話。 基本的にはシンボルか文字列で指定する describe Array do context 'when first created' do its(:size) { should eq 0 } its('size') { should eq 0 } end end % rspec -cfs attribute_of_subject_spec_1.rb Array when first created size should == 0 size
シリーズ(?)の途中ですが軽く脱線。 route_toマッチャを使うと出来るみたい。名前付きじゃなくてもroute_toマッチャ使うんだけどね。ルーティング可能かどうかだけならbe_routableマッチャでよさげ。 spec:routingタスクでルーティングだけテストできる。 % rake spec:routing routes to the pages controller GET root_path should be routable should route to {:controller=>"pages", :action=>"home"} GET service_path should be routable should route to {:controller=>"pages", :action=>"service"} Finished in 0.12806 seco
helpers do def partial(template, *args) options = args.last.is_a?(Hash) ? args.pop : {} options.merge!(:layout => false) if collection = options.delete(:collection) then collection.inject([]) do |buffer, member| buffer << haml(template, options.merge(:layout => false, :locals => {template => member})) end.join("\n") else haml(template, options) end end end -# items.haml = partial :item, :collectio
http://regional.rubykaigi.org/sapporo03 ※書き方マズイとことかあったら指摘してください ※柴田さんのが見つからなかったので知ってる方は教えてください 「高速な乗除算の実現と性能評価」 村田 賢太(@mrkn) - 株式会社ジェネティックラボ && Ruby 札幌 http://www.ustream.tv/recorded/11235561 「Rubyの未来/未来のRuby」 まつもと ゆきひろ(@yukihiro_matz) - (株)ネットワーク応用通信研究所 http://www.ustream.tv/recorded/11236338 「北のRails開発現場から'10(仮)」 前田 智樹(@tmaeda) - 株式会社アンタス、Ruby札幌 http://www.ustream.tv/recorded/11240321 「Rubyの教えてく
もはや何もいうまい。 全裸で形態素解析をするスクリプト - すぎゃーんメモ ゆーすけべー日記 全裸の肩に乗れ!pyZenraモジュールを作ってみた - Keep on moving 全裸のアレの PHP 版を作った - Memo あとでGemとかTermtterプラグインとか作ろうかしら。
ローカルでは動いてんのにHerokuにPushしたら "invalid byte sequence in US-ASCII"って出た。 環境変数LANGが設定されないからっぽいのでconfig.ruにでも書いとけばいんでない? Encoding.default_external = 'utf-8' require 'app' run Sinatra::Application
このページを最初にブックマークしてみませんか?
『@yohfee.blog!』の新着エントリーを見る
j次のブックマーク
k前のブックマーク
lあとで読む
eコメント一覧を開く
oページを開く