RSpec expect change: it "should increment the count" do expect{Foo.bar}.to change{Counter.count}.by 1 end Is there a way to expect change in two tables? expect{Foo.bar}.to change{Counter.count}.by 1 and change{AnotherCounter.count}.by 1

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 環境
Using rails, devise, rspec & factorygirl: Trying to create some tests for my site. I'm using the confirmable model for devise so when I create a user using FactoryGirl, the user isn't confirmed. This is my factories.rb: FactoryGirl.define do factory :user do full_name "Aren Admin" email "aren@example.com" password "arenaren" password_confirmation "arenaren" role_id ADMIN end end And this is my rsp
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
I'm working on a reset_password method in a Rails API app. When this endpoint is hit, an ActiveJob is queued that will fire off a request to Mandrill (our transactional email client). I'm currently trying to write the tests to ensure that that the ActiveJob is queued correctly when the controller endpoint is hit. def reset_password @user = User.find_by(email: params[:user][:email]) @user.send_rese
When writing a request spec, how do you set sessions and/or stub controller methods? I'm trying to stub out authentication in my integration tests - rspec/requests Here's an example of a test require File.dirname(__FILE__) + '/../spec_helper' require File.dirname(__FILE__) + '/authentication_helpers' describe "Messages" do include AuthenticationHelpers describe "GET admin/messages" do before(:each
It's my understanding that Rails' testing environment is torn down and rebuilt before each test...so how do I test a controller that requires that a user be logged in and that user can't be created without Device's confirmable module getting in the way? Devise's recommended method (below) creates a new user which is then sent an email by Devise's confirmable module. How do I get around this so I'm
I tend to use before blocks to set instance variables. I then use those variables across my examples. I recently came upon let(). According to RSpec docs, it is used to ... to define a memoized helper method. The value will be cached across multiple calls in the same example but not across examples. How is this different from using instance variables in before blocks? And also when should you use
Im using spork 0.9.2 and rspec 3.0.0. When trying to run test rspec --drb I have an exception C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/spork-0.9.2/lib/spork/test_framework/rspec.rb:11:in run_tests: uninitialized constant RSpec::Core::CommandLine (NameError) But when changing rspec version back to 2.6 - everything is OK. Has anyone faced the same issue? Is it possible to work around?
リリース、障害情報などのサービスのお知らせ
最新の人気エントリーの配信
処理を実行中です
j次のブックマーク
k前のブックマーク
lあとで読む
eコメント一覧を開く
oページを開く