Create an online store with unique design and features at minimal cost using our MarketAge solution
class User < ActiveRecord::Base (省略)... def password_required? super && provider.blank? end end <h2>Sign up</h2> <%= form_for(resource, as: resource_name, url: registration_path(resource_name)) do |f| %> (省略)... <% if f.object.password_required? %> <div class="field"> <%= f.label :password %> <% if @validatable %> <em>(<%= @minimum_password_length %> characters minimum)</em> <% end %><br /> <%= f.
— 環境 — rails-4.0.1 devise-3.2.2 rspec-rails-2.14.0 capybara-2.2.0 Controller Spec の場合 xhr メソッドの第二引数はアクション名を書きますが、Request Spec(結合テスト)の場合 xhr メソッドの第二引数には HTTP メソッド名(post や delete)に対応するパスを指定します。 Request Spec で Ajax リクエストをテストするコード spec/requests/comment_pages_spec.rb describe "Comment pages" do let(:user) { FactoryGirl.create(:user) } before { login user } subject { page } describe "Ajax request on Com
Rails で Devise で認証機能を作り、テストに RSpec を使う場合、sign_in, sign_out のテストヘルパーが使えます。詳細は以下ページのテストヘルパー(RSpec)の項目を参照。 Rails4 にて Devise でユーザー登録・ログイン認証・認可の機能を追加 | EasyRamble しかし、これらの sign_in, sign_out のヘルパーは、Capybara や Webrat を用いた integration tests(インテグレーションテスト)では動作せず、fuctional tests だけで動作するという注意点があります。サインインさせる場合は、代わりにフォームを埋めるか明示的にセッションをセットする必要がある。 以上の注意点より、spec/requests 内のインテグレーションテスト(結合テスト:RequestSpec)を行う場合は、工夫
The RSpec Bookをやってみるで、RSpec + Cucumberが良さそうなことはわかったのだけど、具体的にどう適用したらよいのかわからない。特にほとんどのアプリで最初に作るべきログイン機能の部分。 そこで、Rails Tutorial for Devise with RSpec and Cucumberをやってみる。 環境 RVM ruby 1.9.3p194 Rails 3.2.8 新しいプロジェクト作成 % rails new rails3-devise-rspec-cucumber -T「-T」は、Unit::Testを入れないためのオプション。理由はRSpecを入れるため。 Gemfileに以下のライブラリを追加。 rspec-rails cucumber-rails database_cleaner factory_girl_rails (参考:func09:has
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
リリース、障害情報などのサービスのお知らせ
最新の人気エントリーの配信
処理を実行中です
j次のブックマーク
k前のブックマーク
lあとで読む
eコメント一覧を開く
oページを開く