0
我想要運行一個控制器測試: 控制器代碼是Rspec的控制器測試分配二維散列失敗
def aix_service_accounts
@no_dn_users= Hash.new
record = 0
@no_dn_users[record]= Hash.new
@no_dn_users[record]['aix_username'] ="abc"
end
的rspec的代碼是
it "should show aix_service_accounts" do
get :aix_service_accounts
expect(assigns(:no_dn_users[0]['aix_username'])).to eq 'abc'
end
結果是
Failures:
1)AixController應顯示aix_service_accounts Failu RE /錯誤:期待(受讓人(:no_dn_users [0] [ 'aix_username'])),以EQ 'ABC'
expected: "abc"
got: {"marked_for_same_origin_verification"=>true, "no_dn_users"=>{0=>{"aix_username"=>"abc"}}}
(compared using ==)
Diff:
@@ -1,2 +1,3 @@
-"abc"
+"marked_for_same_origin_verification" => true,
+"no_dn_users" => {0=>{"aix_username"=>"abc"}},
# ./spec/controllers/aix_controller_spec.rb:29:in `block (2 levels) in <top (required)>'
莫非
任何人的幫助,並說明理由給我?謝謝!
感謝泰倫引用,你是絕對正確的。 –