Puppet や Chef で構築したサーバを RSpec でテストする で書いた仕組みを使いやすくするために serverspec という名前で gem 化してみた。 rubygems.org にも登録してあるので、gem install でインストールできる。 $ gem install serverspec インストールした... 続きを読む
Puppet マニフェストをリファクタリングするからテスト書くぞ、ってことで、 puppet-lxc-test-box に書いたように、テストするためのシステムコンテナを簡単に作る仕組みをつくったので、今度は実際にテストコードを書くためのベースをつくってみた。 rspec-lxc... 続きを読む
gems ディレクトリの */spec/**/*_spec.rb ファイルに対して 'it .* do' を grep する。 cd ~/.rvm/gems/ruby-1.9.3-p327/gems find */spec -type f -name '*_spec.rb' | xargs grep -ho 'it .* do' | sort | uniq | less みたいな感じ。以下のような出力が得ら... 続きを読む
Migrations are a necessary part of any Rails project. At some point, you need to modify the structure of your database, normalize data that exists within those tables, or refactor the architecture entirely. The migrations for these tasks can ... 続きを読む
Thursday, September 9, 2010 RSpec #stub vs. #stub! Confused by #stub vs. #stub!? Consider #stub! deprecated and use #stub. #stub is simply an alias for #stub!. #stub! was defined in the API at a time when RSpec's authors weren't clear on the ... 続きを読む
Accessibility View text version Categories Technology Upload Details Uploaded via SlideShare as Adobe PDF Usage Rights © All Rights Reserved Statistics Favorites 1 Downloads 0 Comments 0 Embed Views 0 Views on SlideShare 562 Total Views 562 C... 続きを読む
Revisions ed306c moro September 18, 2012 72d02c r7kamura September 18, 2012 bf7608 r7kamura September 18, 2012 Private Gist All pages are served over SSL and all pushing and pulling is done over SSH. No one may fork, clone, or view it unless ... 続きを読む
DRY原則に従おうとすればするほど、テストコードはどんどん読みづらくなる。 The RSpec Bookに答えがあるかと思って読んでみたが、「あるある」と一言述べているだけだった。辛い。 テストコードが読みづらくなる例を示すために、1つRubyのライブラリをつくった... 続きを読む
TDD, Ruby, Rspec私がRSpec使ってテスト書く時はこんな感じで書いてるよ〜ってのを書いてみた。*1 テストを書く順番についてTDDでコードを書く場合、先にテストを書く事になります。そして、そのテストを書く順番ですが、私は下記のような順番で書くように意識... 続きを読む
rspec-2.11 がリリースされましたね。いくつかの変更点の中に、今後は should ではなく expect を推奨し、デフォルトでは expect のみが有効化されるようになる、というものがありました。http://myronmars.to/n/dev-blog/2012/06/rspecs-new-expectation-synta... 続きを読む
Rails で使う RSpec の小さな拡張を作っています。RSpec のテストがたくさん付いている、オープンソースの Rails3 アプリがあると機能説明の画像などで使えて便利なのですが、これといって思い浮かびません。GitHub などで公開されていて、手軽に入手できる Rai... 続きを読む
RSpec has featured a readable english-like syntax for setting expectations for a long time: some_spec.rb 1 2 foo.should eq(bar) foo.should_not eq(bar) RSpec 2.11 will include a new variant to this syntax: some_spec.rb 1 2 expect(foo).to eq(ba... 続きを読む
Supports stubbing a chain of methods. Each argument represents a method name to stub, and each one returns a proxy object that can accept more stubs, until the last, which returns whatever is passed to +and_return_. Examples # with this in an... 続きを読む
Dismiss Octotip: You've activated the file finder by pressing t Start typing to filter the file list. Use ↑ and ↓ to navigate, enter to view files. 続きを読む
rspec-parameterized | RubyGems.org | your community gem host tomykaira/rspec-parameterized次のような spec が書けます。 describe "plus" do where(:a, :b, :answer) do [ [1 , 2 , 3], [5 , 8 , 13], [0 , 0 , 0] ] end with_them do it "should do addi... 続きを読む
Statistics Favorites 0 Downloads 0 Comments 0 Embed Views 0 Views on SlideShare 0 Total Views 0 地獄Spec — Presentation Transcript 地獄のRSpec逃げちゃだめだ、逃げちゃだめだ・・・ おおはら@Drecom Co., Ltd. 警告このプレゼンを見てから7日以内にs... 続きを読む
RSpec の DSL には、 example と言うメソッドがあり、そこを経由して現在実行中の example の情報を得ることができる。 def add(*args) args.inject(:+) end describe "add" do before do p example.class #=> RSpec::Core::Example end subject { add(*args) }... 続きを読む
ruby, 俺メモ rspecを初めて使ったので、モックを使うメモ gemのmailを使ってGmailを送るメソッドがある。 require "mail" # ... def send_alert_to_gmail(content) mail = Mail.new mail.from = CONFIG['email'] mail.to = CONFIG['to'] mail.charset = "UTF8"... 続きを読む
I'm fairly new to RoR and recently started learning BDD/Rspec for testing my application. I've been looking for a way to spec an AJAX request, but so far I haven't found much documentation on this at all. Anyone know how to do this? I'm using... 続きを読む
komagata/lokka - GitHub おことわり: この文章は tomykaira が勝手に主張しているもので、他の lokka comitters には一切関知していません。 最近 lokka に手をいれています。(何回も確認不十分なコミットを打ってログを汚しているだけにしかみえませんが。) f... 続きを読む