You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session. Dismiss alert
 
  
  Run this test once, and VCR will record the HTTP request to fixtures/vcr_cassettes/synopsis.yml. Run it again, and VCR will replay the response from iana.org when the HTTP request is made. This test is now fast (no real HTTP requests are made anymore), deterministic (the test will continue to pass, even if you are offline, or iana.org goes down for maintenance) and accurate (the response will cont
Rails プラグイン Gem を作る方法の紹介です。現在の Rails では、プラグインを Gem としてビルドします。通常の Ruby Gem と異なるのは、Rails プラグイン Gem は Rails のコアフレームワーク自体を拡張することができる点です。Rails 自身を拡張して機能を追加したい場合は、Rails プラグインとして Gem を作成すると良いでしょう。 通常の Ruby Gem の作り方は、以下を参照お願いいたします。 Gemの作り方(Ruby Gem) | EasyRamble また、Rails でライブラリとして組み込むことができる gem には、通常の Ruby Gem、Rails プラグイン、Rails エンジンの3種類があります。それぞれの違いについては、以下の解説がとても分かりやすいです。 Gem、Railtieプラグイン、Engine(full/mou
 
      
  I’ve recently journeyed back into the world of Rails development after an extended stay in more functional languages. One aspect of Ruby that always delights me is its focus on readability. With this focus, along with the ability to fold certain structures, I set out to improve a wordy test. The original test looked like this: select_multiple_from "Which of these apply to you?", [ "I read the New
 
      
  TL; DR 予め作っておいた Docker イメージを box として指定する rake assets:precompile で生成されたファイルをキャッシュする test-queue で RSpec の実行を並列化する Database Cleaner の代わりに DatabaseRewinder を使う 概要 業務では,WAF として Ruby on Rails,テストフレームワークとしては RSpec,CI として wercker を使用しています.今のところ,社内のエンジニアは1人しかおらず,開発規模もそれほど大きくないので,特に CI ツールに課金をすることはしていないのですが,溜まっている pull request を同時に develop branch に merge した場合や,他の人が push した場合に,build queue が溜まってしまうことがしばしばありまし
 
      
  What? RSpec API is constantly evolving towards as DRY and readable DSL as possible. Though, there are several things (tricks and additional methods) that could make your specs even DRYer. Warning: While reading, you may feel a temptation to say something like “instead of using this, you’d better redesign your code for testability!” Let’s imagine it was already said, OK? UPD Aug 15, 2017: Gem sahar
Pagination のテストのために、最初は以下のようなコードを書いていたのですが、一つのページ内に複数のPagination を表示するページなので、一番上のブロックのみを確認することにしました。 find("//*[@class='pagination']//a[text()='2']").click expect(page.status_code).to eq(200) これに、以下のように *[@class='pagination'] の末尾に [1] を追加したのですが Capybara::ElementNotFound になってしまいます。 find("//*[@class='pagination'][1]//a[text()='2']").click expect(page.status_code).to eq(200) Test 環境ではなく Development 環境
 
      
  1日1gemとは 最近好きなgemってありますか? という質問に自分が答えられるように始めたgemを紹介する記事 rspec/rspec-its https://github.com/rspec/rspec-its 何をするの? rspec3 で core から無くなった、 its を復活させる gem 正確には、 its が別gemに分離した サンプル require_relative '../lib/hoge' RSpec.describe Hoge do let(:message){ 'hello' } subject { Hoge.new(message) } # こんな風に書き換えられる #it { expect(subject.message).to eq(message) } its(:message) { is_expected.to eq(message) } # ネスト
# インスタンス変数を使う場合 before do @user = User.new(name: 'Taro', email: 'taro@example.com') end it 'is valid' do expect(@user).to be_valid end # letを使う場合 let(:user) { User.new(name: 'Taro', email: 'taro@example.com') } it 'is valid' do expect(user).to be_valid end RSpecを使い慣れている人であれば、おそらくletを使うことが多いと思いますが、初心者の人には違いやメリットがよくわからないと思います。 また、使い慣れている人であっても具体的な違いをぱっと即答できる人は少ないんじゃないでしょうか? ネットを調べていたところ、Stack Overfl
 
      
  Whether I type "rspec" or "rake spec" in the terminal, it just hangs and never finishes the testing suite. I've commented out tests, ran test files individually, but it still just stops. Closest I got to having it finish was uninstalling and reinstalling rspec-rails. First time I run it, I get it to finish. Second time, I get this: $ rake spec /Users/edmac/.rvm/rubies/ruby-2.1.3/bin/ruby -I/Users/
In both cases, you can’t write anything else instead of (1)—so, it is part of “test framework language”. And (2) is description you provide, it can be anything, it is a parameter. So, what is the difference? RSpec uses Ruby language structures to designate parts of “test definition language”, which helps to write, read and validate code. Try writing ti "performs something" and you’ll be stopped ea
こんにちは、黒曜(@kokuyouwind)です。 最近見つけた面白いポケストップは「シーサーに似た守り神(メイドインタイランド)」です。 PokemonGOは飽きてきて、代わりに最新作のサン・ムーンが欲しくなってきました。 アローラロコンかわいいよアローラロコン。あとミミッキュ。 さて、Misocaに入社して一年弱が経ち、RSpecの書き方にも大分慣れてきたのですが、油断すると冗長で複雑なSpecを書いてしまいがちです。 既存のSpecが複雑だと新しいexampleを追加するときにも書きづらくなってしまうため、気づいたらなるべくリファクタリングするように心がけています。 今回は、最近自分が「こういう書き方だと読みやすく保守もしやすいのではないか」と思っているRSpecの書き方について紹介していきたいと思います。 Specを記述する対象と文脈に着目して分割する 最近書くSpecでは、大体
 
      
  Using RSpec Nested Transactions to speed up tests touching the database Fri, 05 Aug 2016 22:24:00 +0000 (Updated at Mon, 08 Aug 2016 13:05:00 +0000) TLDR: This article proposes savepoints to implement nested transactions, which are supported by PostgreSQL, Oracle, Microsoft SQL Server, MySQL (with InnoDB but I think some statements would automatically cause an implicit commit, so I'm not sure it w
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
リリース、障害情報などのサービスのお知らせ
最新の人気エントリーの配信
処理を実行中です
j次のブックマーク
k前のブックマーク
lあとで読む
eコメント一覧を開く
oページを開く
