18 Apr '13, 2am

NowBrowsing: Test::Unit と RSpec と Shoulda - Rails 雑感 - Ruby on Rails with OIAX

昨日の記事 続・Rails 3.x 時代のテストフレームワーク では、Rails で使用できるテストフレームワークの基礎知識と相互関係についてまとめました。 今日は、Test::Unit と RSpec と Shoulda を具体的に比較してみたいと思います(Cucumber については、別の機会に…)。 例として「変数 @total に文字列 '100' をセットすると、式 @total.to_i は 100 を返す」というテストケースを考えましょう。 純粋な Test::Unit ではこのように書きます。 require 'test/unit' class SimpleTest < Test::Unit::TestCase def test_should_return_100 @total = '100' assert_equal(100, @total.to_i) end end Rails の ActiveSupport を読み込むと次のように書けるようになります。 require 'rubygems' require 'test/unit' require 'active_support' class SimpleTest < ActiveSupport::TestCase test "should return 100" do @total = '100' assert_equal(100, @total.to_i) end end 純粋な Test::Unit の場合は、test_should_return_100 のようにメソッド名の中でテストケースの説明をしなければなりませんが、ActiveSupport による拡張のおかげで "should return 100" のように空白区切りのフレーズとして書けるので、可読性が増しています。 RSpec の場合は、次のように記述します。 require 'rubygems' require 'rspec' describe '#to_i' do it "should return...

Full article: http://www.oiax.jp/rails/zakkan/test_unit_rspec_and_shoul...

Tweets

@_atton resque worker なるものが処理してくれる

oiax.jp 19 Apr '13, 7am

#!/usr/bin/env ruby require File.expand_path('../../config/application', __FILE__) Rails.application.require_environment! ...

Ruby on Rails Guides: Ruby On Rails Security Gu...

guides.rubyonrails.org 19 Apr '13, 1pm

The threats against web applications include user account hijacking, bypass of access control, reading or modifying sensit...

580k for this unit..what u all think? - Page 2

forums.condosingapore.com 26 Apr '13, 4am

Quote: Originally Posted by Pikachu1245 I believe it is worth if you have the holding power, be it for own stay or investm...

Double Shot #1110: Parser – A fresh parser for ...

afreshcup.com 18 Apr '13, 10am

is Mike Gunderloy's software development weblog, covering Ruby on Rails and whatever else I find interesting in the univer...

Ruby on Rails Guides: Action Controller Overview

guides.rubyonrails.org 17 Apr '13, 4am

class ClientsController < ActionController::Base # This action uses query string parameters because it gets run # by an HT...

“@0x6D6172696F: I wonder if there's many applic...

api.rubyonrails.org 21 Apr '13, 7pm

Class HTML::Sanitizer < Object actionpack/lib/action_controller/vendor/html-scanner/html/sanitizer.rb

Diary of a Rails rescue project, part 2: Testin...

everydayrails.com 16 Apr '13, 4pm

Diary of a Rails rescue project, part 2: Testing April 16, 2013 As mentioned previously , I’ve been spending spare cycles ...

Everyday Rails Testing with RSpec: Updates for ...

everydayrails.com 25 Apr '13, 2am

Everyday Rails Testing with RSpec: Updates for April, 2013 April 24, 2013 Last week I released another round of updates to...

What's New in Edge Rails #65

afreshcup.com 22 Apr '13, 12pm

is Mike Gunderloy's software development weblog, covering Ruby on Rails and whatever else I find interesting in the univer...

"rspec is a testing DSL. minitest is ruby."

blog.zenspider.com 18 Apr '13, 11pm

minitest version 4.7.2 has been released! Published 2013-04-18 @ 16:16 minitest provides a complete suite of testing facil...

attr_accessor_with_default #rails

apidock.com 18 Apr '13, 4pm

Method deprecated or moved This method is deprecated or moved on the latest stable version. The last existing version (v3....

“SSH公開鍵の設置 - Ruby on Rails with OIAX”

oiax.jp 12 Apr '13, 2pm

Generating public/private rsa key pair. Enter file in which to save the key (/home/kuroda/.ssh/id_rsa):

Single resource REST Rails routes via @pivotall...

pivotallabs.com 17 Apr '13, 3am

REST principles by default is a fantastic convention within Rails applications. The documentation for how to route HTTP re...

Простой способ backup для Rails проектов

rubyflow.ru 17 Apr '13, 5am

Простой способ backup для Rails проектов

@ahealthydesign @amilum reading a pretty good i...

humblelittlerubybook.com 20 Apr '13, 10pm

Like to write code in a functional style a la Haskell or Scheme? That's cool; Ruby does that. Really dig object orientatio...