 
  
  — 環境 — rails-4.0.1 rspec-rails-2.14.0 capybara-2.2.0 RSpec メンテナの方に –profile オプションを教えてもらった それで、RSpec のテストが時間かかって遅い〜とつぶやいたところ、RSpec のメンテナの方からアドバイスを頂けました。Myron Marston さんありがとうございます!ブログでツイートと情報のシェアも承諾頂きました。 @takafumir The `–profile` option can be used to print out the slowest examples. — Myron Marston (@myronmarston) March 18, 2014 訳:– profile オプションを使うと遅いサンプルをリストアップできるよ。 ヘルプを見てみますと…
 
      
  Know of any guides to writing performance tests using Rspec? Does Rspec have the capability to run specs in benchmarking or profiling mode similar to the way Rails has performance tests that run in these modes (http://guides.rubyonrails.org/ performance_testing.html)? On Jan 16, 2011, at 8:29 PM, Evan wrote: Know of any guides to writing performance tests using Rspec? There’s nothing built in as o
 
      
  When I first embarked on creating an API for a project, I couldn’t find a ton of resources on how to test it with RSpec, so I decided to write a blog post about it. Let’s say we’re building an app that allows users to list their second bedrooms to short-term guests. We all love Airbnb :) This would be an application with many models that have complex associations, but let’s focus on what a host ca
rspec-expectations ships with a number of built-in matchers. Each matcher can be used with expect(..).to or expect(..).not_to to define positive and negative expectations respectively on an object. Most matchers can also be accessed using the (...).should and (...).should_not syntax; see using should syntax for why we recommend using expect. e.g. expect(result).to eq(3) expect(list).not_to be_empt
まとめ sidekiqを2つのRailsアプリケーションで使ってみて、テストの書き方と残し方について思うところがあったので書いてみます。 特別な事情がなければsidekiq/testingを使うべき(sidekiq/testing/inlineは使わない) 非同期処理そのもののユニットテストはMyWorker.new.performで書けばよい 非同期処理をキックする側のユニットテストはMyWorker.jobs.sizeを検証するだけにする エンドツーエンドテストでは「全ての非同期ジョブを実行する」というようなstepやメソッドを作ってそれを呼ぶ sidekiq/testingとsidekiq/testing/inlineについて sidekiqのwikiには、テストのための仕組みとしてsidekiq/testingとsidekiq/testing/inlineの2つがあり、**「どちら
Grape は Ruby で API を書くのに便利なフレームワークです。 Grape 自体については fakestarbaby 氏がすでにすてきなエントリを書いてくださっています。 Grape | API生成マイクロフレームワーク #Rails #Gems #Ruby #grape #api_builders - Qiita ここではどうやってテストを書くのかということについて書いてみたいと思います。 想定 RSpec の受け入れテストの request_spec を使うよ API は JSON を返すよ API 用のサブドメイン(api.foobar.com)を切っているよ JSON のテストは json_expressions を使うよ(参考) OAuth 2.0 の Provider になって Web Application Flow とかで認証しちゃったり モックは Factor
 
      
  5) RedirectsController#redirect_region without valid region ID responds with a 404 Failure/Error: subject { get :redirect_region, params } NoMethodError: undefined method `cache' for nil:NilClass # /usr/local/rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/actionview-4.2.5.1/lib/action_view/template/resolver.rb:151:in `cached' # /usr/local/rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/actionview-4.2
On Rails 4.0.0.rc1, Ruby 2.0.0, after I run a migration, I see the following error when I try to run a test through rspec: /Users/peeja/.rbenv/versions/2.0.0-p0/lib/ruby/gems/2.0.0/gems/activerecord-4.0.0.rc1/lib/active_record/migration.rb:376:in `check_pending!': Migrations are pending; run 'rake db:migrate RAILS_ENV=test' to resolve this issue. (ActiveRecord::PendingMigrationError) That doesn't
 
      
  Railsアプリで、ActiveRecord::Base.transactionを使って、 トランザクションを明示的に張り、異常がある場合にロールバックする、 という実装は大いに有りますよね。 僕はRSpecを使ってテストしています。 RSpecを使って、DBがロールバックされることを確認する方法を書いておきます。 例えば、コントローラに次のような処理を書いたとします。 モデルの変更後、メールを送信する、という処理で、ここでは、メールの送信に失敗した場合は、 変更をロールバックする、という仕様とします。(その仕様は果たして妥当か?はここでは考えない。) def save_and_send_mail(model) begin ActiveRecord::Base.tansaction do model.save! SomeMailer.something.deliver end rescue
An RSpec cheatsheet in the form of a Rails app. Learn how to expertly test Rails apps from a model codebase A small yet comprehensive reference for developers who want to know how to test Rails apps using RSpec. Here you'll find in-depth examples with detailed documentation explaining how to test with RSpec and related testing gems, which you can then apply to your own projects. This application w
■ [rails][ruby] delayed_job なタスクを rspec でテスト 最近、非同期処理を実現するときは redis + resque がとてもかわいいんだけど、rails とべったりな処理をするときは相変わらず delayed_job を使っている。delayed_job に限らないけど、非同期な処理をするメソッドのテストは割と大変…かと思っていたら手段はあるみたい。 非同期処理の中が動いていることを確認 config/initializer/delayed_job_config.rb とかに以下の処理を追加。 Delayed::Worker.delay_jobs = !Rails.env.test? これで Rails.env.test? な時には delay を書いていても通常の処理を同じになるので、いつも通り期待する動きを rspec で書けば良い。 非同期処理と
![[rails][ruby] delayed_job なタスクを rspec でテスト - HsbtDiary(2011-02-28)](https://cdn-ak-scissors.b.st-hatena.com/image/square/8cab6183abe73ade0ce0a24c302ac36ee5c17b43/height=288;version=1;width=512/https%3A%2F%2Fwww.hsbt.org%2Fdiary%2Ftheme%2Fogimage.png) 
      
  At thoughtbot we’ve been experimenting with using JSON Schema, a widely-used specification for describing the structure of JSON objects, to improve workflows for documenting and validating JSON APIs. Describing our JSON APIs using the JSON Schema standard allows us to automatically generate and update our HTTP clients using tools such as heroics for Ruby and Schematic for Go, saving loads of time
 
      
  リリース、障害情報などのサービスのお知らせ
最新の人気エントリーの配信
処理を実行中です
j次のブックマーク
k前のブックマーク
lあとで読む
eコメント一覧を開く
oページを開く
