Continuing the from the previous post, here is a cheat sheet for RSpec’s assertion library: RSpec::Expectations. RSpec is a mature, feature-packed testing framework, but the documentation can be difficult to navigate. As an alternative to the official documentation, this cheat sheet contains short example code to demonstrate all the built-in expectation matchers. These examples were created with R
After creating cheat sheets for RSpec::Core and RSpec::Expectations, I think it is only fair to have a cheat sheet for Minitest too. Minitest also provides an optional RSpec-like DSL, which is not covered here. Minitest is a small (some might say “mini”) testing framework, where tests are written in “plain Ruby,” as opposed to using a custom DSL. It has a gentler learning curve than RSpec, and is
RSpec is a mature, feature-packed testing framework, but the documentation can be difficult to navigate. The official documentation is written as a set of Cucumber tests within Relish. It’s very comprehensive, but also quite sparse, and Cucumber tests are kind of unnatural to read. When I forget how to do something in RSpec, I usually just look for an example in a test I’ve written previously, so
テストを書かないようになってしまっていた。 大きなアプリケーションではないし一人で作ってるし… まぁいいか的な。 ただ、コードの量が増えていくにつれやっぱりちょっと辛い。 書き方すっかり忘れたので、RSpec再入門。 環境 Vagrant + CentOS (centos64box) Ruby 2.2.1 Rails 4.1.1 最終的なGemfile(テスト関係だけ) テスト用のDBの設定をお忘れなく。 gem 'pg' group :development, :test do gem 'rspec-rails' gem 'factory_girl_rails' gem 'guard-rspec' gem 'spring-commands-rspec' end group :test do gem 'faker' gem 'capybara' gem 'database_cleaner'
リリース、障害情報などのサービスのお知らせ
最新の人気エントリーの配信
処理を実行中です
j次のブックマーク
k前のブックマーク
lあとで読む
eコメント一覧を開く
oページを開く