<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
		xmlns:xhtml="http://www.w3.org/1999/xhtml"
>

<channel>
	<title>Aerialarts &#187; rspec</title>
	<atom:link href="http://aerial.st/tags/rspec/feed/" rel="self" type="application/rss+xml" />
	<link>http://aerial.st</link>
	<description></description>
	<lastBuildDate>Mon, 16 Jan 2012 09:56:44 +0000</lastBuildDate>
	<language>ja</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.1</generator>
		<xhtml:link rel="alternate" media="handheld" type="text/html" href="http://aerial.st/tags/rspec/feed/" />
		<item>
		<title>RSpec2で特定のテストを実行する</title>
		<link>http://aerial.st/archive/2011/10/19/run-specific-rspec2-examples/</link>
		<comments>http://aerial.st/archive/2011/10/19/run-specific-rspec2-examples/#comments</comments>
		<pubDate>Wed, 19 Oct 2011 13:41:56 +0000</pubDate>
		<dc:creator>ikm</dc:creator>
				<category><![CDATA[Tech]]></category>
		<category><![CDATA[rspec]]></category>

		<guid isPermaLink="false">http://aerial.st/?p=1168</guid>
		<description><![CDATA[Relishより、次のようにすることで特定のdescribe/context/itのみを実行することができる。 spec_helper.rbのRSpec.configureにfilter_runの設定を追加： RSpec.configure do &#124;c&#124; c.filter_run :focus => true end テストしたいdescribe/context/itに:focusオプションを追加： describe User do describe "#say", :focus => true do it "should return a String" do : end end end こうすることで:focus => trueを指定したテストのみが実行され、それ以外は無視される。複数個指定すればそれらすべてが実行されるし、ひとつも指定しなければ何もテストされない。テストコードが多い中で新規にテストを追加する場合などに便利だと思う。 上記のRelishのページに書かれている run_all_when_everything_filtered を設定すれば、:focusが１つも指定されていない場合に全テストを実行するというもの。]]></description>
		<wfw:commentRss>http://aerial.st/archive/2011/10/19/run-specific-rspec2-examples/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<xhtml:link rel="alternate" media="handheld" type="text/html" href="http://aerial.st/archive/2011/10/19/run-specific-rspec2-examples/" />
	</item>
		<item>
		<title>RSpec 1.3でカスタムマッチャ</title>
		<link>http://aerial.st/archive/2011/03/04/rspec-13-custom-matcher-move-file/</link>
		<comments>http://aerial.st/archive/2011/03/04/rspec-13-custom-matcher-move-file/#comments</comments>
		<pubDate>Fri, 04 Mar 2011 05:15:42 +0000</pubDate>
		<dc:creator>ikm</dc:creator>
				<category><![CDATA[Tech]]></category>
		<category><![CDATA[rspec]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[test]]></category>

		<guid isPermaLink="false">http://aerial.st/?p=965</guid>
		<description><![CDATA[ある処理で行われるファイルの移動が適切かどうかテストしたかったので、カスタムマッチャを作ってみた。使用したのはRSpec 1.3.1。 目標のspec lambda { foo }.should move_file(src, dest) チェックする項目 fooメソッドを実行する前にsrcにファイルが存在することをチェック（事前チェック） Foo#barを実行した後にsrcにファイルが存在しないことをチェック（事後チェック） Foo#barを実行した後にdestにファイルが存在することをチェック（事後チェック） srcとdestのMD5値が一致することをチェック（事後チェック） （1は要らないかも？） 実際のコード CustomFileMatchers::MoveFileのmatches?で具体的なテストを実行する。 使い方 describe文のなかでincludeして使う。 ためしにちゃんと判定できているかもspecで書いてみた。 （it文の内容が微妙かもしれない） まとめ 意外と簡単にできたし、specのコードがコンパクトかつそれだけで意味が通じるようになるのでカスタムマッチャはとても便利。 複数のチェック項目が通って一つの意味を成す場合にとても強力。 change.from.toのように条件の追加をメソッドチェインしたければCustomFileMatchers::MoveFileに引数をインスタンス変数に保存するようなメソッド（changeでいうところのfromやto）を追加して、matches?でそれらをチェックすればいいのだと思われる。 参考資料 RSpec をもっと理解したかったので、まとめを作りました &#8211; takihiroの日記 Chapter 17 Extending RSpec その２ &#8211; おもしろWEBサービス開発日記]]></description>
		<wfw:commentRss>http://aerial.st/archive/2011/03/04/rspec-13-custom-matcher-move-file/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<xhtml:link rel="alternate" media="handheld" type="text/html" href="http://aerial.st/archive/2011/03/04/rspec-13-custom-matcher-move-file/" />
	</item>
		<item>
		<title>watchrでautospecみたいなこと</title>
		<link>http://aerial.st/archive/2011/01/21/watchr-for-autospec-like/</link>
		<comments>http://aerial.st/archive/2011/01/21/watchr-for-autospec-like/#comments</comments>
		<pubDate>Fri, 21 Jan 2011 11:50:47 +0000</pubDate>
		<dc:creator>ikm</dc:creator>
				<category><![CDATA[Tech]]></category>
		<category><![CDATA[rspec]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[tips]]></category>

		<guid isPermaLink="false">http://aerial.st/?p=953</guid>
		<description><![CDATA[watchrで更新のあったファイルに対してrspecを実行する方法。 secondlifeさんの記事を読んで、取り急ぎやってみた。 $ gem install watchr $ gem install ruby-fsevent # Mac OSXの場合 $ gem install rev # Linux/*BSDの場合 $ cd （RAILSアプリのルートディレクトリ） $ vi spec.watchr watch('app/(.*)\.rb') { &#124;md&#124; system("ruby script/spec spec/#{md[1]}_spec.rb") } watch('spec/(.*)_spec\.rb') { &#124;md&#124; system("ruby script/spec #{md[0]}") } $ watchr spec.watchr autospecより汎用性があって便利かも。 追記 Rails3だとbundle exec rspecを使うのでこんな感じ？ watch('app/(.*)\.rb') { &#124;md&#124; system("bundle exec rspec spec/#{md[1]}_spec.rb") } watch('(lib/.*)\.rb') { &#124;md&#124; system("bundle exec rspec spec/#{md[1]}_spec.rb") } watch('(spec/.*)_spec\.rb') { &#124;md&#124; system("bundle exec rspec #{md[0]}") }]]></description>
		<wfw:commentRss>http://aerial.st/archive/2011/01/21/watchr-for-autospec-like/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		<xhtml:link rel="alternate" media="handheld" type="text/html" href="http://aerial.st/archive/2011/01/21/watchr-for-autospec-like/" />
	</item>
		<item>
		<title>Rails勉強会@東京第58回に行ってきた</title>
		<link>http://aerial.st/archive/2011/01/03/railstoyko-58/</link>
		<comments>http://aerial.st/archive/2011/01/03/railstoyko-58/#comments</comments>
		<pubDate>Mon, 03 Jan 2011 13:42:42 +0000</pubDate>
		<dc:creator>ikm</dc:creator>
				<category><![CDATA[Tech]]></category>
		<category><![CDATA[cucumber]]></category>
		<category><![CDATA[Rails]]></category>
		<category><![CDATA[railstokyo]]></category>
		<category><![CDATA[rspec]]></category>
		<category><![CDATA[test]]></category>

		<guid isPermaLink="false">http://aerial.st/?p=882</guid>
		<description><![CDATA[昨年12/18に行われたRails勉強会@東京第58回に行ってきた。 テストの話 「テストの話」で大まかに扱われるけど、細かく見ると次の3つの話題が出てくる。 どうやってテストを書くか うまいテストの仕方・資産としての残し方 テストの文化の浸透のさせ方・継続の仕方 今回は@moroさんをファシリテータとして、「rspecでテストをどう書くか」と「RelishでRspecの新機能を見る」の2点を行った。 話題がバラバラになりがちなので、進行をされた@moroさんはすごいなと思っていたんだけど、ここらへんをうまくカバーできるやり方を見つけたいと思う今日この頃。 で、その時の結論をうけた上で今覚えてる限りの結論。 どうやってテストを書くか （いつか書く） うまいテストの仕方・資産としての残し方 今回は出なかったけど、捨てるテスト、残すテストの話、かなぁ。 開発時の内部実装まで含めた、細かい挙動確認のためのテストで残しておくと後々リファクタリングすることができなくなるので、開発が一段落したらいっそ捨てるのもアリ。 それに対して外側からアプリケーションを叩いてそのINとOUTを見るためのテストは資産として残さなきゃいけない。 テストの文化の浸透のさせ方・継続の仕方 Hudsonを使って継続的にテストの実行とRCovによるカバレッジの集計をさせてそれを共有するのが良いらしい。Rubyではないけどサイボウズでの事例も興味深い。 あとはペアプロでTDDに慣らしていくとか。 あとこれはちょっと別かもしれないけど、「最初にテストを書かなきゃいけないという話だけど、なかなか難しい」という話が出てきた。それに対して@moroさんの話では、「最終的にテストを書いてチェックができればいいので、実装とテストのどちらが先になっても問題はない」ということだった。 自分の場合も、動作の確認がちゃんとできればいいやと思って実装してからテストを書くことは多い。もちろん実装の規模にもよるんだろうけど。 OmniAuthの話 （あとで書く） ActiveSupport 3系のソースを読む （あとで書く）]]></description>
		<wfw:commentRss>http://aerial.st/archive/2011/01/03/railstoyko-58/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<xhtml:link rel="alternate" media="handheld" type="text/html" href="http://aerial.st/archive/2011/01/03/railstoyko-58/" />
	</item>
		<item>
		<title>Rails3でRSPec2とmachinist2</title>
		<link>http://aerial.st/archive/2010/12/13/rspec2-and-machinist2-with-rails3/</link>
		<comments>http://aerial.st/archive/2010/12/13/rspec2-and-machinist2-with-rails3/#comments</comments>
		<pubDate>Mon, 13 Dec 2010 14:47:16 +0000</pubDate>
		<dc:creator>ikm</dc:creator>
				<category><![CDATA[machinist]]></category>
		<category><![CDATA[rails3]]></category>
		<category><![CDATA[rspec]]></category>

		<guid isPermaLink="false">http://aerial.st/?p=851</guid>
		<description><![CDATA[Rails3でRSpec2とmachinist2を使うための下準備。 $ alias r=rails $ r new testapp -T -d mysql $ cd testapp $ vi config/application.rb # Test::Unitにさよなら $ vi Gemfile # RSpec2とmachinist2を追加 $ bundle install $ r g rspec:install $ r g machinist:install $ vi config/application.rb # fixtureの代わりにblueprintを追加するように $ vi ~/.autotest # DBを毎回クリアする 各種ファイルの編集は下記の通り。 Test::Unitにさよなら -require 'rails/all' +require "active_record/railtie" +require "action_controller/railtie" +require "action_mailer/railtie" +require "active_resource/railtie" RSpec2とmachinist2を追加 RSpec2+Rails3+autotest環境の構築あたりを参考にやってみた。でもautotestが上手く動かない気がする。 source 'http://rubygems.org' gem 'rails', '3.0.3' gem 'mysql2' group :development, :test do gem 'rspec-rails' gem 'autotest' gem 'webrat' gem 'faker' gem 'machinist', [...]]]></description>
		<wfw:commentRss>http://aerial.st/archive/2010/12/13/rspec2-and-machinist2-with-rails3/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<xhtml:link rel="alternate" media="handheld" type="text/html" href="http://aerial.st/archive/2010/12/13/rspec2-and-machinist2-with-rails3/" />
	</item>
		<item>
		<title>Rails3でTest::Unitを無効化</title>
		<link>http://aerial.st/archive/2010/10/05/throw-away-test-unit-using-rails3/</link>
		<comments>http://aerial.st/archive/2010/10/05/throw-away-test-unit-using-rails3/#comments</comments>
		<pubDate>Tue, 05 Oct 2010 02:46:30 +0000</pubDate>
		<dc:creator>ikm</dc:creator>
				<category><![CDATA[未分類]]></category>
		<category><![CDATA[Rails]]></category>
		<category><![CDATA[rails3]]></category>
		<category><![CDATA[rspec]]></category>

		<guid isPermaLink="false">http://aerial.st/?p=751</guid>
		<description><![CDATA[Rails3でTest::Unitを使わないようにする方法。rspecの導入方法については参考資料を参照。 まずrails newコマンドで新規プロジェクトを作成する際に-Tオプションを付けて、testディレクトリを作成させないようになる。 $ rails new new_project -T 次にconfig/application.rbを次のように編集して、rails/test_unit/railtieを読み込まないようにする。こうすることでTest::Unitのテンプレート自動生成等を行わないようにする。 --- config/application.rb.org 2010-10-05 11:39:47.000000000 +0900 +++ config/application.rb 2010-10-05 11:41:59.000000000 +0900 @@ -1,6 +1,9 @@ require File.expand_path('../boot', __FILE__) -require 'rails/all' +require 'active_record/railtie' +require 'action_controller/railtie' +require 'action_mailer/railtie' +require 'active_resource/railtie' # If you have a Gemfile, require the gems listed there, including any gems # you've limited to :test, :development, or :production. 参考資料 Rails 3 と RSpec 2 と rake spec Rails3 で RSpec + RCov 日本語対応]]></description>
		<wfw:commentRss>http://aerial.st/archive/2010/10/05/throw-away-test-unit-using-rails3/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<xhtml:link rel="alternate" media="handheld" type="text/html" href="http://aerial.st/archive/2010/10/05/throw-away-test-unit-using-rails3/" />
	</item>
		<item>
		<title>Machinist+DatasetでFixture代替</title>
		<link>http://aerial.st/archive/2010/02/20/fixture-replacement/</link>
		<comments>http://aerial.st/archive/2010/02/20/fixture-replacement/#comments</comments>
		<pubDate>Fri, 19 Feb 2010 16:53:45 +0000</pubDate>
		<dc:creator>ikm</dc:creator>
				<category><![CDATA[未分類]]></category>
		<category><![CDATA[Rails]]></category>
		<category><![CDATA[rspec]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[test]]></category>

		<guid isPermaLink="false">http://aerial.st/?p=625</guid>
		<description><![CDATA[概要 Machinistは定義された条件下でテストデータを生成するプラグイン・gem。 DatasetはRubyのコードで記述したテストデータをDBに読み込むプラグイン・gem。 この2つを組み合わせることで（比較的）メンテナンスのしやすいfixtureの代替を構築することが可能になる。 流れとしては、Dataset上でMachinistを呼び出して複数のデータを生成して、それをDBに流し込むという感じ。 メリットは、 条件下でランダムなデータを生成してくれる（「特定のデータをfixture上に作って読み込む」というようなことも可能） リレーション先のデータも適宜生成してくれる（素敵！）。 デメリットは、 データがランダムなので、全条件を必ずカバーするのは苦手＆毎回同じデータが入ってくるとは限らない（回避できるかなぁ） fixtureに依存した書き方をしていると大幅な書き換えが必要かもしれない（レコード数によるテストなど。集計系では難しい…） 最終結果のコードをGithubにあげたので、そちらも参考に。 下準備 Machinist、Dataset、そして適当な文字列のデータを作ってくれるFakerをインストール・設定する。なおテストフレームワークにはRSpec on Railsを用いる。 YAMLに頼らないテストデータの作成を参考にさせていただきました。 Machinist $ cd RAILS_ROOT $ ruby script/plugin install git://github.com/notahat/machinist.git $ vi spec/blueprints.rb # 新規作成/下記参照 $ vi spec/spec_helper.rb # 下記参照 RAILS_ROOT/spec/blueprints.rbに追記： require 'machinist/active_record' require 'sham' RAILS_ROOT/spec/spec_helper.rbに追記： # 冒頭のほうに記述 require File.expand_path(File.dirname(__FILE__) + "/blueprints") # Spec::Runner.configureブロック内に以下を記述 # -> Shamで1度生成したデータはリスト形式でキャッシュされ、 # 以降はbeforeが呼ばれるたびにその先頭から順に取り出すようになる config.before(:all) { Sham.reset(:before_all) } config.before(:each) { Sham.reset(:before_each) } Dataset $ cd RAILS_ROOT $ ruby script/plugin install git://github.com/aiwilliams/dataset.git $ mkdir spec/datasets $ vi spec/spec_helper.rb # 下記参照 [...]]]></description>
		<wfw:commentRss>http://aerial.st/archive/2010/02/20/fixture-replacement/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<xhtml:link rel="alternate" media="handheld" type="text/html" href="http://aerial.st/archive/2010/02/20/fixture-replacement/" />
	</item>
		<item>
		<title>install rspec</title>
		<link>http://aerial.st/archive/2009/08/09/install-rspec/</link>
		<comments>http://aerial.st/archive/2009/08/09/install-rspec/#comments</comments>
		<pubDate>Sun, 09 Aug 2009 08:11:56 +0000</pubDate>
		<dc:creator>ikm</dc:creator>
				<category><![CDATA[Tech]]></category>
		<category><![CDATA[Rails]]></category>
		<category><![CDATA[rspec]]></category>

		<guid isPermaLink="false">http://aerial.st/?p=522</guid>
		<description><![CDATA[いつも忘れるのでメモ： $ ruby script/plugin install git://github.com/dchelimsky/rspec.git -r 'refs/tags/1.2.8' $ ruby script/plugin install git://github.com/dchelimsky/rspec-rails.git -r 'refs/tags/1.2.7.1' $ ruby script/generate rspec 追記 environment.rbでconfig.gemを設定してrake gems:installのが確実か。 config.gem "rspec", :lib => false, :version => "1.2.7" config.gem "rspec-rails", :lib => false, :version => "1.2.7.1"]]></description>
		<wfw:commentRss>http://aerial.st/archive/2009/08/09/install-rspec/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<xhtml:link rel="alternate" media="handheld" type="text/html" href="http://aerial.st/archive/2009/08/09/install-rspec/" />
	</item>
		<item>
		<title>Growlでautospecの結果を表示</title>
		<link>http://aerial.st/archive/2009/07/21/display-autospec-results-with-growl/</link>
		<comments>http://aerial.st/archive/2009/07/21/display-autospec-results-with-growl/#comments</comments>
		<pubDate>Mon, 20 Jul 2009 15:17:39 +0000</pubDate>
		<dc:creator>ikm</dc:creator>
				<category><![CDATA[growl]]></category>
		<category><![CDATA[Mac]]></category>
		<category><![CDATA[Rails]]></category>
		<category><![CDATA[rspec]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[tips]]></category>

		<guid isPermaLink="false">http://aerial.st/?p=493</guid>
		<description><![CDATA[Growlの準備 Growlをインストール インストーラと一緒に入っているExtra/growlnotify/install.shを実行する autotest + growl で楽々テストを参考に、Growlが「受信される通知を聞く」、「リモートアプリケーション登録を許可」するように環境設定パネルから設定する。 gem類の準備 バージョンも併記した。 まずはgemの準備。 $sudo gem install ZenTest # 4.1.1 $sudo gem install redgreen # 1.2.2, autospecの結果をコンソールで赤と緑で塗り分けてくれる。Growlだけなら不要 $sudo gem install ruby-growl # 1.0.1 RSpecとRSpec on Railsのインストール。 ruby script/plugin install git://github.com/dchelimsky/rspec.git -r 'refs/tags/1.2.7' # 1.2.7 ruby script/plugin install git://github.com/dchelimsky/rspec-rails.git -r 'refs/tags/1.2.7.1' # 1.2.7.1 ruby script/generate rspec 画像を拝借 cd ~ curl http://blog.internautdesign.com/files/rails_fail.png > .rails_fail.png curl http://blog.internautdesign.com/files/rails_ok.png > .rails_ok.png moroさんが勉強会で使ってたチェックとバツマークのが欲しいんだけど、どこにあるんだろう？ ~/.autotestの編集 ZenTestをインストールしたときについてくる設定ファイルのひな形をコピー。 x.x.xはインストールしたZenTestのバージョンで、ここでは4.1.1。 $ cp /Library/Ruby/Gems/1.8/gems/ZenTest-x.x.x/example_dot_autotest.rb ~/.autotest $ chmod 644 ~/.autotest 以下のように設定する # -*- ruby -*- # [...]]]></description>
		<wfw:commentRss>http://aerial.st/archive/2009/07/21/display-autospec-results-with-growl/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		<xhtml:link rel="alternate" media="handheld" type="text/html" href="http://aerial.st/archive/2009/07/21/display-autospec-results-with-growl/" />
	</item>
	</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/


Served from: aerial.st @ 2012-02-09 02:08:24 -->
