Saturday, 15 June 2013

Rspec case for rails 4 patch :update -


I am using the device in my app, and trying to write a specific to update the email ID I am UI works, but imagination has failed. Before testing against the changed email id, I am reloading the user object.

One thing I do is that the updating user's statement is running in the database.

What is the correct way to write the device?

RSPEC space:

  this should be updated "email" @ user = subject courtal_user patch: update, id: @ user, user: {: email = & gt; "John.doe@example1.com"} @User.Reload is expected (user.mail). Eq ("john.doe@example1.com") End   

RSPC error log:

  1) User: Log in registration controller email to user Failure to update / error: expected (@ user.email) .to eq ("john.doe@example1.com") expected: "John.doe@example1.com" found: "john.doe@example.com" (Using ==)   

test.log:

  ActiveRecord :: SchemaMigration load (0.4ms) SELECT "schema_migrations". From "schema_migrations" (0.2ms) BEGIN (0.4ms) SAVEPOINT active_record_1 user existence (0.9ms) SELECT 1 from a "users" where "user" "email" = 'john.doe@example.com' LIMIT 1 "user" SQL (4.1ms) INSERT value ($ 1, $ 2, $ 3, $ 4, or $ 4) in ("created", "email", "encrypted_password", "first_name", "lastname", "updated" $ 5, $ 6) Back "ID" [["Created", Saturn, 22 June 2013 13:12:28 UTC + 00: 00], ["Email", "JOI DADO @ Example.com"], [ "Encrypted_password", "$ 2A $ 04 $ LIR Voxtex P.C.L.UGGAA MME EE2V / LLWWP 32GFXN NBJFG5TLE "], [" FIR UTC + 00: 00]] (0.1 ms) Release Release Active_Record_1User Load (T_Name), "John"], ["LastName", "Do" ] "ID" = 457 "user". "Id" ASC limit by 1 users, ["updated_at", Saturday, 22 June 2013 13:12:28 UTC + 00: 00] "Users" by "Users". Processing: HTML parameter as registration controller # update: {"id" "& Gt; "457", "user" = & gt; {"Email" = & gt; "John.doe@example1.com"}} User Load (0.6ms) SELECT "Users". * "Users" "WHERE" user "." Id "= $ 1 LIMIT 1 [[" ID ", 457]] User Existence (0.4ms) SELECT 1 From a" users "WHERE (" user "." Email "= 'john.doe@example1.com' and ' Users'. "ID"! = 457) Limit 1 Randered Device / Registration / Edit / Application (0.2 min) within html.slim 73ms in full 200 OK (view: 4.0 ms | "id" = $ 1 The range of 1 [["ID", 457]] (0.2 ms) rollback    

Try

  this should "update the email" @user = subject: current_user patch: update, id: @ user, user: {: email = & gt; "John.doe@example1.com"} @ user.reload.email.should == "john.doe@example1 .com "end   

or alternatively

  should" update the email "@user = subject.current_user {patch: update, id: @ User, user: {: email = & gt; "John.doe@example1.com"} @ user.reload}. (@User, Email) .to ("john.doe@example1.com") end < / Code>   

No comments:

Post a Comment