Skip to content

Commit

Permalink
fix: entry fixture was incorrect
Browse files Browse the repository at this point in the history
Update the fixture to be under `data`
* Add a test coverage that would have captured this
  • Loading branch information
troyizzle committed Feb 21, 2023
1 parent b3e6c21 commit 3be4ac9
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 51 deletions.
105 changes: 54 additions & 51 deletions test/fixtures/entry.json
Original file line number Diff line number Diff line change
@@ -1,57 +1,60 @@
{
"type": "new_wager",
"id": "134928677",
"attributes": {
"amount_bet_cents": 2000,
"amount_to_win_cents": 6000,
"amount_won_cents": 0,
"code": null,
"correlated_entry": false,
"created_at": "2023-02-16T16:38:38-05:00",
"eligible_for_refund": false,
"is_gift": false,
"parlay_count": 2,
"payout_multipliers": {
"0": 3
},
"payouts": {
"2": {
"amount": 6000,
"multiplier": 3
}
},
"pick_protection": false,
"promo_tag": false,
"promotion_id": null,
"refund_allowed_until": null,
"result": "pending",
"reverted_payouts": {
"2": {
"amount": 6000,
"multiplier": 3
}
},
"ruleset_id": 1,
"sport": "NBA1H",
"updated_at": "2023-02-16T16:38:38-05:00",
"user_id": 1224768,
"uuid": null
},
"relationships": {
"predictions": {
"data": [
{
"type": "prediction",
"id": "520195535"
},
{
"type": "prediction",
"id": "520195536"
"data": {
"type": "new_wager",
"id": "134928677",
"attributes": {
"amount_bet_cents": 2000,
"amount_to_win_cents": 6000,
"amount_won_cents": 0,
"code": null,
"correlated_entry": false,
"created_at": "2023-02-16T16:38:38-05:00",
"eligible_for_refund": false,
"is_gift": false,
"parlay_count": 2,
"payout_multipliers": {
"0": 3
},
"payouts": {
"2": {
"amount": 6000,
"multiplier": 3
}
},
"pick_protection": false,
"promo_tag": false,
"promotion_id": null,
"refund_allowed_until": null,
"result": "pending",
"reverted_payouts": {
"2": {
"amount": 6000,
"multiplier": 3
}
]
},
"ruleset_id": 1,
"sport": "NBA1H",
"updated_at": "2023-02-16T16:38:38-05:00",
"user_id": 1224768,
"uuid": null
},
"promotion": {
"data": null
"relationships": {
"predictions": {
"data": [
{
"type": "prediction",
"id": "520195535"
},
{
"type": "prediction",
"id": "520195536"
}
]
},
"promotion": {
"data": null
}
}

}
}
11 changes: 11 additions & 0 deletions test/prizepicks/objects/test_entry.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# frozen_string_literal: true
require 'test_helper'

module Project
class TestEntry < Minitest::Test
def test_entry
entry = PrizePicks::Entry.new(read_fixture('entry'))
assert_equal 6000, entry.amount_to_win_cents
end
end
end
4 changes: 4 additions & 0 deletions test/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ def stub_request(path, response:, method: :get, body: {})
def stub_response(fixture:, status: 200, headers: { 'Content-Type' => 'application/json' })
[status, headers, File.read("test/fixtures/#{fixture}.json")]
end

def read_fixture(fixture)
JSON.parse(File.read("test/fixtures/#{fixture}.json"))
end
end
end

Expand Down

0 comments on commit 3be4ac9

Please sign in to comment.