Ich versuche, einen Controller-Test auszuführen: der Controller-Code istRspec Controller Test zweidimensionales Hash zuordnen nicht
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
Der rspec Code ist
it "should show aix_service_accounts" do
get :aix_service_accounts
expect(assigns(:no_dn_users[0]['aix_username'])).to eq 'abc'
end
Das Ergebnis ist
Failures:
1) AixController sollte aix_service_accounts Failu zeigen re/Fehler: erwarten (Abtretungsempfänger (: no_dn_users [0] [ 'aix_username'])) Gl '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)>'
Könnte jemand helfen und erklären, der Grund für mich.? Vielen Dank!
Dank Taryn mit Referenzierung, sind Sie absolut richtig. –