Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files

Work on rating tests

  • Loading branch information...
brtjkzl committed Oct 17, 2018
1 parent 5fbe36a commit cd9a620796ccac9b37794cbb503d92fbce47102a
Showing with 27 additions and 4 deletions.
  1. +1 −1 Procfile.dev
  2. +4 −1 test/api/api_games_test.rb
  3. +22 −2 test/api/api_ratings_test.rb
@@ -1,2 +1,2 @@
web: bin/rails server -p 3000
rails: bin/rails server -p 3000
webpack: bin/webpack-dev-server
@@ -8,8 +8,11 @@ class ApiGamesTest < ActionDispatch::IntegrationTest
stub_response(%r(api-endpoint.igdb.com/games), 200, igdb_games_response_body)

get api_games_path(search: "witcher")
response_body = JSON.parse(@response.body)

JSON.parse(@response.body).each do |game|
assert_not_empty response_body

response_body.each do |game|
assert_equal ["id", "name", "cover", "platforms"], game.keys

game["platforms"].each do |platform|
@@ -3,10 +3,30 @@
class ApiRatingsTest < ActionDispatch::IntegrationTest
include ApiTestHelper

fixtures :user_games

test "GET /api/ratings (filter[id])" do
# get api_ratings_path("filter[id]": "1,2,3")
skip

# TODO replace fixtures with factory bot

get api_ratings_path("filter[id]": Game.first.id)
response_body = JSON.parse(@response.body)

assert_not_empty response_body

response_body.each do |rating|
assert_equal ["id", "score", "votes"], rating.keys
end
end

test "GET /api/rating/:id" do
# TODO remove - it's game id not rating it

# assert_equal 2, @response.body
skip
# get api_rating_path(Game.first.id)

# response_body = JSON.parse(@response.body)
# assert_equal ["id", "score", "votes"], response_body.keys
end
end

0 comments on commit cd9a620

Please sign in to comment.
You can’t perform that action at this time.