samedi 9 mai 2015

Ruby on Rails Testing Errors

I'm back with a followup question on some testing I'm doing. The project is located here on github, Sprint 6 fork to be specifc. I've got two test files "user_controller_test.rb and "day_controller_test.rb".

The two errors I'm getting with my understanding of them are listed below.

1 "No Route matches" in the day_controller_test. I'm getting this as I can't seem to get the date to be anything other than ":date=>nil". Also even though I make a "get :index" call, it requests the show action and not the index action which I'm at a loss for.

get(:index, { "date" => Time.now.strftime("%Y-%m-%d"), "activity" => "calories","mode" => "daily"})

2 "Can't convert nil to float" in the "user_controller_test". This error points to line 44 in my profile view where I try to format a value to correctly display it.

<p>Current weight: <%= "%.2f" % @weight %> <%= @weightScale %></p>

For the first error I've tried referencing "date" as ":date" instead as well as passing it a static date in the correct format. Nothing I've tried has worked. To test if it will set it a value in a different situation, I made the hash equal to "params:" Which correctly stores the date.

For the second error I believe it's something with the way I'm am trying to get the data. I've overrided some functions in the "test_helper.rb" file to circumvent the "Fitbit API" which is where the data actually comes from.

If you guys have any ideas on how I can fix these two errors I would highly appreciate it!

Aucun commentaire:

Enregistrer un commentaire