DevpecとDeclarativeがRSpecテストでうまくやっているのは本当に苦労しています。Rails 3.1でRSpecを使用したDeviseとDeclarative Testingのキー化エラー
https://github.com/stffn/declarative_authorization/issues/95
stringify_keys error after supplementing session variables in functional tests
これらの私の問題に対処しますが、どちらも私のために働いたソリューションを持っていた両方。
# practices_controller_spec.rb
it "assigns a new practice as @practice as owner" do
get_action(:new, @owner)
assigns(:practice).should be_a_new(Practice)
sign_out @owner
end
def get_action(action,user,*id)
sign_in user
get_with user, action, {:id => id}, session
end
# Spec test yields
Failure/Error: get_with user, action, {:id => id}, session
NoMethodError:
private method `stringify_keys' called for #<ActionController::TestSession:0x00000100d8a170>
Session looks like this: {"warden.user.user.key"=>["User", [1840], "$2a$04$2Rq4bHGp.tlIgKHE4PlRle"]}
このエラーを解決するための提案はありますか?
ご協力いただければ幸いです。ありがとう!私はそれがこれを行うことによって動作するようになった
UPDATE
:
def get_action(action,user,*id)
sign_in user
hashy = session['warden.user.user.key'][2]
get_with user, action, {:id => id}, {"warden.user.user.key"=>["User", [user.id],hashy]}, nil
エンド