0
我RoR中新,我跟着一些教程就像Rails作爲殭屍,我必須在集成測試功能的問題:無法訪問內容JSON解析
test 'returns user by id' do
get "/users", {id: @user.id}, { :authorization => token_header(@user.authentication_token)}
assert_equal 200, response.status
user_response = JSON.parse(response.body, symbolize_names: true)
Rails.logger.debug "TEST: #{user_response}"
assert_equal @user.email, user_response[:email]
end
而且我得到這個錯誤:
ListingUsersTest#test_returns_user_by_id:
TypeError: no implicit conversion of Symbol into Integer
test/integration/listing_users_test.rb:23:in `[]'
test/integration/listing_users_test.rb:23:in `block in <class:ListingUsersTest>'
我以爲USER_RESPONSE是空的或零或類似的東西,但在我的日誌:
TEST: [{:id=>428186149, :email=>"[email protected]",...}]
所以我只是想知道如果我沒有錯過哈希結構的東西或..我不知道。