triviacrack 0.2.0 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/workflows/ci.yml +1 -1
- data/.github/workflows/publish.yml +40 -0
- data/.gitignore +1 -1
- data/.ruby-version +1 -0
- data/Gemfile +1 -1
- data/Gemfile.lock +76 -0
- data/README.md +1 -1
- data/lib/triviacrack/api/common.rb +12 -12
- data/lib/triviacrack/api/question.rb +42 -1
- data/lib/triviacrack/errors/request_error.rb +11 -1
- data/lib/triviacrack/parsers/game_parser.rb +6 -0
- data/lib/triviacrack/version.rb +1 -1
- data/spec/api/game_spec.rb +17 -4
- data/spec/api/login_spec.rb +7 -3
- data/spec/api/profile_spec.rb +12 -3
- data/spec/api/question_spec.rb +50 -4
- data/spec/api/user_spec.rb +12 -3
- data/spec/data/game_duel.json +336 -0
- data/spec/parsers/game_parser_spec.rb +26 -0
- data/triviacrack.gemspec +9 -7
- metadata +24 -19
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 5bf3db9c78ce358e4846d74bd34c2f453b9d1ee738c92d0c74a82ce6de2eff9e
|
|
4
|
+
data.tar.gz: 021c5fae4ed5bfbbf4bc127aee09a7285a5221c3a54f446831cf4c9cef776002
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 4e73ff2b4e29891d487533087c4cb56f727ac7cce2bfcd120a2adeef9d24c2aac8ca5fdfb49a340948bad5f270314a928fc5053090be441650697dbaa645f3ef
|
|
7
|
+
data.tar.gz: 559151f2cc7808cabc84b97a304548c8e91c556b47ef2968dccfa7fc30acdf084c40a86dd42e3adb009e143f46eca88efbcd730bb38d37f2d59a9c84bd9284cb
|
data/.github/workflows/ci.yml
CHANGED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
name: Publish
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
tags:
|
|
6
|
+
- 'v*'
|
|
7
|
+
|
|
8
|
+
jobs:
|
|
9
|
+
build:
|
|
10
|
+
runs-on: ubuntu-latest
|
|
11
|
+
|
|
12
|
+
steps:
|
|
13
|
+
- uses: actions/checkout@v1
|
|
14
|
+
|
|
15
|
+
- uses: actions/setup-ruby@v1
|
|
16
|
+
with:
|
|
17
|
+
ruby-version: 3.0.2
|
|
18
|
+
|
|
19
|
+
- name: Bundle Install
|
|
20
|
+
run: |
|
|
21
|
+
gem install bundler
|
|
22
|
+
bundle install --jobs 4 --retry 3
|
|
23
|
+
|
|
24
|
+
- name: Run RSpec and Code Coverage
|
|
25
|
+
uses: paambaati/codeclimate-action@v2.4.0
|
|
26
|
+
env:
|
|
27
|
+
CC_TEST_REPORTER_ID: 79d8e81f3c0ccfce30d983b4454d2f042d2883fa64b23527c3a94587930b37be
|
|
28
|
+
with:
|
|
29
|
+
coverageCommand: bundle exec rspec
|
|
30
|
+
|
|
31
|
+
- name: Publish to RubyGems
|
|
32
|
+
run: |
|
|
33
|
+
mkdir -p $HOME/.gem
|
|
34
|
+
touch $HOME/.gem/credentials
|
|
35
|
+
chmod 0600 $HOME/.gem/credentials
|
|
36
|
+
printf -- "---\n:rubygems_api_key: ${GEM_HOST_API_KEY}\n" > $HOME/.gem/credentials
|
|
37
|
+
gem build *.gemspec
|
|
38
|
+
gem push *.gem
|
|
39
|
+
env:
|
|
40
|
+
GEM_HOST_API_KEY: ${{secrets.RUBYGEMS_API_KEY}}
|
data/.gitignore
CHANGED
data/.ruby-version
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
3.0.2
|
data/Gemfile
CHANGED
data/Gemfile.lock
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
PATH
|
|
2
|
+
remote: .
|
|
3
|
+
specs:
|
|
4
|
+
triviacrack (0.5.0)
|
|
5
|
+
faraday (~> 1.7.2)
|
|
6
|
+
|
|
7
|
+
GEM
|
|
8
|
+
remote: https://rubygems.org/
|
|
9
|
+
specs:
|
|
10
|
+
diff-lcs (1.4.4)
|
|
11
|
+
docile (1.4.0)
|
|
12
|
+
faraday (1.7.2)
|
|
13
|
+
faraday-em_http (~> 1.0)
|
|
14
|
+
faraday-em_synchrony (~> 1.0)
|
|
15
|
+
faraday-excon (~> 1.1)
|
|
16
|
+
faraday-httpclient (~> 1.0.1)
|
|
17
|
+
faraday-net_http (~> 1.0)
|
|
18
|
+
faraday-net_http_persistent (~> 1.1)
|
|
19
|
+
faraday-patron (~> 1.0)
|
|
20
|
+
faraday-rack (~> 1.0)
|
|
21
|
+
multipart-post (>= 1.2, < 3)
|
|
22
|
+
ruby2_keywords (>= 0.0.4)
|
|
23
|
+
faraday-em_http (1.0.0)
|
|
24
|
+
faraday-em_synchrony (1.0.0)
|
|
25
|
+
faraday-excon (1.1.0)
|
|
26
|
+
faraday-httpclient (1.0.1)
|
|
27
|
+
faraday-net_http (1.0.1)
|
|
28
|
+
faraday-net_http_persistent (1.2.0)
|
|
29
|
+
faraday-patron (1.0.0)
|
|
30
|
+
faraday-rack (1.0.0)
|
|
31
|
+
fuubar (2.5.1)
|
|
32
|
+
rspec-core (~> 3.0)
|
|
33
|
+
ruby-progressbar (~> 1.4)
|
|
34
|
+
json (2.5.1)
|
|
35
|
+
multipart-post (2.1.1)
|
|
36
|
+
rake (13.0.6)
|
|
37
|
+
rspec (3.10.0)
|
|
38
|
+
rspec-core (~> 3.10.0)
|
|
39
|
+
rspec-expectations (~> 3.10.0)
|
|
40
|
+
rspec-mocks (~> 3.10.0)
|
|
41
|
+
rspec-core (3.10.1)
|
|
42
|
+
rspec-support (~> 3.10.0)
|
|
43
|
+
rspec-expectations (3.10.1)
|
|
44
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
|
45
|
+
rspec-support (~> 3.10.0)
|
|
46
|
+
rspec-its (1.3.0)
|
|
47
|
+
rspec-core (>= 3.0.0)
|
|
48
|
+
rspec-expectations (>= 3.0.0)
|
|
49
|
+
rspec-mocks (3.10.2)
|
|
50
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
|
51
|
+
rspec-support (~> 3.10.0)
|
|
52
|
+
rspec-support (3.10.2)
|
|
53
|
+
ruby-progressbar (1.11.0)
|
|
54
|
+
ruby2_keywords (0.0.5)
|
|
55
|
+
simplecov (0.21.2)
|
|
56
|
+
docile (~> 1.1)
|
|
57
|
+
simplecov-html (~> 0.11)
|
|
58
|
+
simplecov_json_formatter (~> 0.1)
|
|
59
|
+
simplecov-html (0.12.3)
|
|
60
|
+
simplecov_json_formatter (0.1.3)
|
|
61
|
+
|
|
62
|
+
PLATFORMS
|
|
63
|
+
ruby
|
|
64
|
+
|
|
65
|
+
DEPENDENCIES
|
|
66
|
+
bundler (~> 2.2.27)
|
|
67
|
+
fuubar (~> 2.5.1)
|
|
68
|
+
json (~> 2.5.1)
|
|
69
|
+
rake (~> 13.0.6)
|
|
70
|
+
rspec (~> 3.10.0)
|
|
71
|
+
rspec-its (~> 1.3.0)
|
|
72
|
+
simplecov (~> 0.21.2)
|
|
73
|
+
triviacrack!
|
|
74
|
+
|
|
75
|
+
BUNDLED WITH
|
|
76
|
+
2.2.27
|
data/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# Triviacrack  [](https://codeclimate.com/github/davidkus/triviacrack) [](https://codeclimate.com/github/davidkus/triviacrack)
|
|
1
|
+
# Triviacrack [](https://badge.fury.io/rb/triviacrack)  [](https://codeclimate.com/github/davidkus/triviacrack) [](https://codeclimate.com/github/davidkus/triviacrack)
|
|
2
2
|
|
|
3
3
|
A Ruby interface for the Trivia Crack API.
|
|
4
4
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
require "
|
|
1
|
+
require "faraday"
|
|
2
2
|
|
|
3
3
|
require "triviacrack/errors/request_error"
|
|
4
4
|
|
|
@@ -13,13 +13,13 @@ module TriviaCrack
|
|
|
13
13
|
# url - The URL of the TriviaCrack API resource.
|
|
14
14
|
# parameters - The parameters to send with the request.
|
|
15
15
|
#
|
|
16
|
-
# Returns a
|
|
16
|
+
# Returns a Faraday Response object with the server's response.
|
|
17
17
|
# Raises TriviaCrack:Errors::RequestError if the request fails.
|
|
18
18
|
def get(url, parameters: nil)
|
|
19
|
-
response =
|
|
19
|
+
response = Faraday.get "#{API_HOST}#{url}", params: parameters,
|
|
20
20
|
headers: default_headers
|
|
21
21
|
|
|
22
|
-
check_response response
|
|
22
|
+
check_response url, response
|
|
23
23
|
end
|
|
24
24
|
|
|
25
25
|
# Internal: Makes a POST request to the Trivia Crack API using the set of
|
|
@@ -28,13 +28,13 @@ module TriviaCrack
|
|
|
28
28
|
# url - The URL of the TriviaCrack API resource.
|
|
29
29
|
# parameters - The parameters to send with the request.
|
|
30
30
|
#
|
|
31
|
-
# Returns a
|
|
31
|
+
# Returns a Faraday Response object with the server's response.
|
|
32
32
|
# Raises TriviaCrack:Errors::RequestError if the request fails.
|
|
33
33
|
def post(url, parameters: nil)
|
|
34
|
-
response =
|
|
34
|
+
response = Faraday.post "#{API_HOST}#{url}", body: parameters,
|
|
35
35
|
headers: default_headers
|
|
36
36
|
|
|
37
|
-
check_response response
|
|
37
|
+
check_response url, response
|
|
38
38
|
end
|
|
39
39
|
|
|
40
40
|
private
|
|
@@ -59,14 +59,14 @@ module TriviaCrack
|
|
|
59
59
|
# Internal: Checks the response's code to see if the request was
|
|
60
60
|
# successful
|
|
61
61
|
#
|
|
62
|
-
# response -
|
|
62
|
+
# response - Faraday response returned by the API.
|
|
63
63
|
#
|
|
64
64
|
# Returns the response object.
|
|
65
65
|
# Raises TriviaCrack:Errors::RequestError if the request failed.
|
|
66
|
-
def check_response(response)
|
|
67
|
-
if not response.
|
|
68
|
-
raise TriviaCrack::Errors::RequestError.new(response.
|
|
69
|
-
"Request to
|
|
66
|
+
def check_response(url, response)
|
|
67
|
+
if not response.status.between? 200, 299
|
|
68
|
+
raise TriviaCrack::Errors::RequestError.new(response.status, url, response.body),
|
|
69
|
+
"Request to #{API_HOST}#{url} failed with code #{response.status}."
|
|
70
70
|
end
|
|
71
71
|
|
|
72
72
|
response
|
|
@@ -11,7 +11,7 @@ module TriviaCrack
|
|
|
11
11
|
|
|
12
12
|
# Public: Uses the Trivia Crack API to answer the given question.
|
|
13
13
|
#
|
|
14
|
-
#
|
|
14
|
+
# game_id - The ID of the TriviaCrack::Game.
|
|
15
15
|
# question - The TriviaCrack::Question.
|
|
16
16
|
# answer - The index of the answer to be submitted.
|
|
17
17
|
#
|
|
@@ -38,6 +38,47 @@ module TriviaCrack
|
|
|
38
38
|
[game, answer == question.correct_answer]
|
|
39
39
|
end
|
|
40
40
|
|
|
41
|
+
# Public: Uses the Trivia Crack API to answer duel questions for the game.
|
|
42
|
+
#
|
|
43
|
+
# game_id - The ID of the TriviaCrack::Game.
|
|
44
|
+
# questions - The array of TriviaCrack::Question to answer
|
|
45
|
+
# answer_map - Hash of question ID / answer indices.
|
|
46
|
+
#
|
|
47
|
+
# Examples
|
|
48
|
+
#
|
|
49
|
+
# answers = {}
|
|
50
|
+
# for question in game.questions do
|
|
51
|
+
# answers[question.id] = <some answer index> // 0, 1, 2 or 3
|
|
52
|
+
# end
|
|
53
|
+
# answer_questions game.id, game.questions, answers
|
|
54
|
+
#
|
|
55
|
+
# Returns the update TriviaCrack::Game object, as well as a map
|
|
56
|
+
# with an entry for each question ID and a boolean indicating if
|
|
57
|
+
# the question was answered successfully.
|
|
58
|
+
# Raises TriviaCrack::Errors::RequestError if the request fails
|
|
59
|
+
def answer_questions(game_id, questions, answer_map)
|
|
60
|
+
answers = []
|
|
61
|
+
correct_answers = {}
|
|
62
|
+
|
|
63
|
+
for question in questions do
|
|
64
|
+
answer = {
|
|
65
|
+
id: question.id,
|
|
66
|
+
answer: answer_map[question.id],
|
|
67
|
+
category: question.category.upcase
|
|
68
|
+
}
|
|
69
|
+
answers << answer
|
|
70
|
+
correct_answers[question.id] = answer_map[question.id] == question.correct_answer
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
response =
|
|
74
|
+
post "/api/users/#{@session.user_id}/games/#{game_id}/answers",
|
|
75
|
+
parameters: { type: questions.first.type.upcase, answers: answers }.to_json
|
|
76
|
+
|
|
77
|
+
game = TriviaCrack::Parsers::GameParser.parse response.body
|
|
78
|
+
|
|
79
|
+
[game, correct_answers]
|
|
80
|
+
end
|
|
81
|
+
|
|
41
82
|
end
|
|
42
83
|
end
|
|
43
84
|
end
|
|
@@ -7,11 +7,21 @@ module TriviaCrack
|
|
|
7
7
|
# Public: The HTTP status code returned by the Trivia Crack server.
|
|
8
8
|
attr_reader :code
|
|
9
9
|
|
|
10
|
+
#Public: The URL that was requested.
|
|
11
|
+
attr_reader :url
|
|
12
|
+
|
|
13
|
+
#Public: The response body that was returned by the Trivia Crack server.
|
|
14
|
+
attr_reader :body
|
|
15
|
+
|
|
10
16
|
# Public: Initializes a RequestError.
|
|
11
17
|
#
|
|
12
18
|
# code - The HTTP status code returned by the Trivia Crack server.
|
|
13
|
-
|
|
19
|
+
# url - The URL that was requested.
|
|
20
|
+
# body - The response body that was returned by the Trivia Crack server.
|
|
21
|
+
def initialize(code, url, body)
|
|
14
22
|
@code = code
|
|
23
|
+
@url = url
|
|
24
|
+
@body = body
|
|
15
25
|
end
|
|
16
26
|
end
|
|
17
27
|
end
|
|
@@ -31,6 +31,12 @@ module TriviaCrack
|
|
|
31
31
|
question = TriviaCrack::Parsers::QuestionParser.parse q_data
|
|
32
32
|
questions << question
|
|
33
33
|
end
|
|
34
|
+
if raw_data["spins_data"]["spins"][0]["type"] == "DUEL"
|
|
35
|
+
q_data = raw_data["spins_data"]["spins"][0]["tie_break_question"]
|
|
36
|
+
q_data["type"] = raw_data["spins_data"]["spins"][0]["type"]
|
|
37
|
+
question = TriviaCrack::Parsers::QuestionParser.parse q_data
|
|
38
|
+
questions << question
|
|
39
|
+
end
|
|
34
40
|
end
|
|
35
41
|
|
|
36
42
|
if raw_data["available_crowns"]
|
data/lib/triviacrack/version.rb
CHANGED
data/spec/api/game_spec.rb
CHANGED
|
@@ -5,10 +5,10 @@ describe TriviaCrack::API::Game do
|
|
|
5
5
|
let(:session) { TriviaCrack::Session.new session_id: "session", user_id: 1 }
|
|
6
6
|
let(:client) { (Class.new(APIStub) { include TriviaCrack::API::Game }).new session }
|
|
7
7
|
|
|
8
|
-
let(:response) { double(
|
|
8
|
+
let(:response) { double(status: code, body: raw_data) }
|
|
9
9
|
|
|
10
|
-
before { allow(
|
|
11
|
-
before { allow(
|
|
10
|
+
before { allow(Faraday).to receive(:get) { response } }
|
|
11
|
+
before { allow(Faraday).to receive(:post) { response } }
|
|
12
12
|
|
|
13
13
|
describe "#get_games" do
|
|
14
14
|
|
|
@@ -27,12 +27,17 @@ describe TriviaCrack::API::Game do
|
|
|
27
27
|
let(:code) { 400 }
|
|
28
28
|
|
|
29
29
|
it { expect{ subject }.to raise_error TriviaCrack::Errors::RequestError }
|
|
30
|
+
it { expect{ subject }.to raise_error(an_instance_of(TriviaCrack::Errors::RequestError)
|
|
31
|
+
.and having_attributes(code: 400)) }
|
|
32
|
+
it { expect{ subject }.to raise_error(an_instance_of(TriviaCrack::Errors::RequestError)
|
|
33
|
+
.and having_attributes(url: "/api/users/#{session.user_id}/dashboard")) }
|
|
30
34
|
end
|
|
31
35
|
end
|
|
32
36
|
|
|
33
37
|
describe "#get_game" do
|
|
38
|
+
let(:game_id) { 123 }
|
|
34
39
|
|
|
35
|
-
subject { client.get_game
|
|
40
|
+
subject { client.get_game game_id }
|
|
36
41
|
|
|
37
42
|
let(:raw_data) { SpecData.get "game.json" }
|
|
38
43
|
|
|
@@ -47,6 +52,10 @@ describe TriviaCrack::API::Game do
|
|
|
47
52
|
let(:code) { 400 }
|
|
48
53
|
|
|
49
54
|
it { expect{ subject }.to raise_error TriviaCrack::Errors::RequestError }
|
|
55
|
+
it { expect{ subject }.to raise_error(an_instance_of(TriviaCrack::Errors::RequestError)
|
|
56
|
+
.and having_attributes(code: code)) }
|
|
57
|
+
it { expect{ subject }.to raise_error(an_instance_of(TriviaCrack::Errors::RequestError)
|
|
58
|
+
.and having_attributes(url: "/api/users/#{session.user_id}/games/#{game_id}")) }
|
|
50
59
|
end
|
|
51
60
|
end
|
|
52
61
|
|
|
@@ -67,6 +76,10 @@ describe TriviaCrack::API::Game do
|
|
|
67
76
|
let(:code) { 400 }
|
|
68
77
|
|
|
69
78
|
it { expect{ subject }.to raise_error TriviaCrack::Errors::RequestError }
|
|
79
|
+
it { expect{ subject }.to raise_error(an_instance_of(TriviaCrack::Errors::RequestError)
|
|
80
|
+
.and having_attributes(code: code)) }
|
|
81
|
+
it { expect{ subject }.to raise_error(an_instance_of(TriviaCrack::Errors::RequestError)
|
|
82
|
+
.and having_attributes(url: "/api/users/#{session.user_id}/games")) }
|
|
70
83
|
end
|
|
71
84
|
end
|
|
72
85
|
end
|
data/spec/api/login_spec.rb
CHANGED
|
@@ -4,9 +4,9 @@ describe TriviaCrack::API::Login do
|
|
|
4
4
|
|
|
5
5
|
let(:client) { (Class.new(APIStub) { include TriviaCrack::API::Login }).new }
|
|
6
6
|
|
|
7
|
-
let(:response) { double(
|
|
7
|
+
let(:response) { double(status: code, body: raw_data) }
|
|
8
8
|
|
|
9
|
-
before { allow(
|
|
9
|
+
before { allow(Faraday).to receive(:post) { response } }
|
|
10
10
|
|
|
11
11
|
describe "#login" do
|
|
12
12
|
|
|
@@ -25,10 +25,14 @@ describe TriviaCrack::API::Login do
|
|
|
25
25
|
its(:session_id) { is_expected.to eq "session123" }
|
|
26
26
|
end
|
|
27
27
|
|
|
28
|
-
context 'given that the request
|
|
28
|
+
context 'given that the request fails' do
|
|
29
29
|
let(:code) { 400 }
|
|
30
30
|
|
|
31
31
|
it { expect{ subject }.to raise_error TriviaCrack::Errors::RequestError }
|
|
32
|
+
it { expect{ subject }.to raise_error(an_instance_of(TriviaCrack::Errors::RequestError)
|
|
33
|
+
.and having_attributes(code: code)) }
|
|
34
|
+
it { expect{ subject }.to raise_error(an_instance_of(TriviaCrack::Errors::RequestError)
|
|
35
|
+
.and having_attributes(url: '/api/login')) }
|
|
32
36
|
end
|
|
33
37
|
end
|
|
34
38
|
end
|
data/spec/api/profile_spec.rb
CHANGED
|
@@ -5,13 +5,14 @@ describe TriviaCrack::API::Profile do
|
|
|
5
5
|
let(:session) { TriviaCrack::Session.new session_id: "session", user_id: 1 }
|
|
6
6
|
let(:client) { (Class.new(APIStub) { include TriviaCrack::API::Profile }).new session }
|
|
7
7
|
|
|
8
|
-
let(:response) { double(
|
|
8
|
+
let(:response) { double(status: code, body: raw_data) }
|
|
9
9
|
|
|
10
|
-
before { allow(
|
|
10
|
+
before { allow(Faraday).to receive(:get) { response } }
|
|
11
11
|
|
|
12
12
|
describe "#get_profile" do
|
|
13
|
+
let(:user_id) { 111 }
|
|
13
14
|
|
|
14
|
-
subject { client.get_profile
|
|
15
|
+
subject { client.get_profile user_id }
|
|
15
16
|
|
|
16
17
|
let(:raw_data) { SpecData.get "profile.json" }
|
|
17
18
|
|
|
@@ -26,6 +27,10 @@ describe TriviaCrack::API::Profile do
|
|
|
26
27
|
let(:code) { 400 }
|
|
27
28
|
|
|
28
29
|
it { expect{ subject }.to raise_error TriviaCrack::Errors::RequestError }
|
|
30
|
+
it { expect{ subject }.to raise_error(an_instance_of(TriviaCrack::Errors::RequestError)
|
|
31
|
+
.and having_attributes(code: code)) }
|
|
32
|
+
it { expect{ subject }.to raise_error(an_instance_of(TriviaCrack::Errors::RequestError)
|
|
33
|
+
.and having_attributes(url: "/api/users/#{session.user_id}/profiles/#{user_id}")) }
|
|
29
34
|
end
|
|
30
35
|
end
|
|
31
36
|
|
|
@@ -46,6 +51,10 @@ describe TriviaCrack::API::Profile do
|
|
|
46
51
|
let(:code) { 400 }
|
|
47
52
|
|
|
48
53
|
it { expect{ subject }.to raise_error TriviaCrack::Errors::RequestError }
|
|
54
|
+
it { expect{ subject }.to raise_error(an_instance_of(TriviaCrack::Errors::RequestError)
|
|
55
|
+
.and having_attributes(code: code)) }
|
|
56
|
+
it { expect{ subject }.to raise_error(an_instance_of(TriviaCrack::Errors::RequestError)
|
|
57
|
+
.and having_attributes(url: "/api/users/#{session.user_id}/profiles/#{session.user_id}")) }
|
|
49
58
|
end
|
|
50
59
|
end
|
|
51
60
|
end
|
data/spec/api/question_spec.rb
CHANGED
|
@@ -5,9 +5,9 @@ describe TriviaCrack::API::Question do
|
|
|
5
5
|
let(:session) { TriviaCrack::Session.new session_id: "session", user_id: 1 }
|
|
6
6
|
let(:client) { (Class.new(APIStub) { include TriviaCrack::API::Question }).new session }
|
|
7
7
|
|
|
8
|
-
let(:response) { double(
|
|
8
|
+
let(:response) { double(status: code, body: raw_data) }
|
|
9
9
|
|
|
10
|
-
before { allow(
|
|
10
|
+
before { allow(Faraday).to receive(:post) { response } }
|
|
11
11
|
|
|
12
12
|
describe "#answer_question" do
|
|
13
13
|
|
|
@@ -17,7 +17,7 @@ describe TriviaCrack::API::Question do
|
|
|
17
17
|
let(:question) { double(id: 1, correct_answer: 1, type: "NORMAL", category: "SPORTS") }
|
|
18
18
|
let(:game_id) { 22 }
|
|
19
19
|
|
|
20
|
-
context 'given that the question was
|
|
20
|
+
context 'given that the question was answered correctly' do
|
|
21
21
|
let(:code) { 200 }
|
|
22
22
|
let(:answer) { 1 }
|
|
23
23
|
|
|
@@ -26,7 +26,7 @@ describe TriviaCrack::API::Question do
|
|
|
26
26
|
it { expect(subject[1]).to be true }
|
|
27
27
|
end
|
|
28
28
|
|
|
29
|
-
context 'given that the question was
|
|
29
|
+
context 'given that the question was answered incorrectly' do
|
|
30
30
|
let(:code) { 200 }
|
|
31
31
|
let(:answer) { 0 }
|
|
32
32
|
|
|
@@ -40,6 +40,52 @@ describe TriviaCrack::API::Question do
|
|
|
40
40
|
let(:answer) { 1 }
|
|
41
41
|
|
|
42
42
|
it { expect{ subject }.to raise_error TriviaCrack::Errors::RequestError }
|
|
43
|
+
it { expect{ subject }.to raise_error(an_instance_of(TriviaCrack::Errors::RequestError)
|
|
44
|
+
.and having_attributes(code: code)) }
|
|
45
|
+
it { expect{ subject }.to raise_error(an_instance_of(TriviaCrack::Errors::RequestError)
|
|
46
|
+
.and having_attributes(url: "/api/users/#{session.user_id}/games/#{game_id}/answers")) }
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
describe "#answer_questions" do
|
|
51
|
+
|
|
52
|
+
subject { client.answer_questions game_id, questions, answers }
|
|
53
|
+
|
|
54
|
+
let(:raw_data) { SpecData.get "answer.json" }
|
|
55
|
+
let(:question_one) { double(id: 1, correct_answer: 1, type: "DUEL", category: "SPORTS") }
|
|
56
|
+
let(:question_two) { double(id: 2, correct_answer: 2, type: "DUEL", category: "ART") }
|
|
57
|
+
let(:questions) { [question_one, question_two] }
|
|
58
|
+
let(:game_id) { 22 }
|
|
59
|
+
|
|
60
|
+
context 'given that the questions were answered correctly' do
|
|
61
|
+
let(:code) { 200 }
|
|
62
|
+
let(:answers) { {1 => 1, 2 => 2} }
|
|
63
|
+
|
|
64
|
+
it { expect(TriviaCrack::Parsers::GameParser).to receive(:parse).once; subject }
|
|
65
|
+
it { expect(subject[0]).to be_a TriviaCrack::Game }
|
|
66
|
+
it { expect(subject[1][1]).to be true }
|
|
67
|
+
it { expect(subject[1][2]).to be true }
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
context 'given that a question was answered incorrectly' do
|
|
71
|
+
let(:code) { 200 }
|
|
72
|
+
let(:answers) { {1 => 1, 2 => 3} }
|
|
73
|
+
|
|
74
|
+
it { expect(TriviaCrack::Parsers::GameParser).to receive(:parse).once; subject }
|
|
75
|
+
it { expect(subject[0]).to be_a TriviaCrack::Game }
|
|
76
|
+
it { expect(subject[1][1]).to be true }
|
|
77
|
+
it { expect(subject[1][2]).to be false }
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
context 'given that the request fails' do
|
|
81
|
+
let(:code) { 400 }
|
|
82
|
+
let(:answers) { {1 => 1, 2 => 2} }
|
|
83
|
+
|
|
84
|
+
it { expect{ subject }.to raise_error TriviaCrack::Errors::RequestError }
|
|
85
|
+
it { expect{ subject }.to raise_error(an_instance_of(TriviaCrack::Errors::RequestError)
|
|
86
|
+
.and having_attributes(code: code)) }
|
|
87
|
+
it { expect{ subject }.to raise_error(an_instance_of(TriviaCrack::Errors::RequestError)
|
|
88
|
+
.and having_attributes(url: "/api/users/#{session.user_id}/games/#{game_id}/answers")) }
|
|
43
89
|
end
|
|
44
90
|
end
|
|
45
91
|
end
|
data/spec/api/user_spec.rb
CHANGED
|
@@ -5,13 +5,14 @@ describe TriviaCrack::API::User do
|
|
|
5
5
|
let(:session) { TriviaCrack::Session.new session_id: "session", user_id: 1 }
|
|
6
6
|
let(:client) { (Class.new(APIStub) { include TriviaCrack::API::User }).new session }
|
|
7
7
|
|
|
8
|
-
let(:response) { double(
|
|
8
|
+
let(:response) { double(status: code, body: raw_data) }
|
|
9
9
|
|
|
10
|
-
before { allow(
|
|
10
|
+
before { allow(Faraday).to receive(:get) { response } }
|
|
11
11
|
|
|
12
12
|
describe "#get_user_id" do
|
|
13
|
+
let(:username) { "example.2" }
|
|
13
14
|
|
|
14
|
-
subject { client.get_user_id
|
|
15
|
+
subject { client.get_user_id username }
|
|
15
16
|
|
|
16
17
|
let(:raw_data) { SpecData.get "search.json" }
|
|
17
18
|
|
|
@@ -25,6 +26,10 @@ describe TriviaCrack::API::User do
|
|
|
25
26
|
let(:code) { 400 }
|
|
26
27
|
|
|
27
28
|
it { expect{ subject }.to raise_error TriviaCrack::Errors::RequestError }
|
|
29
|
+
it { expect{ subject }.to raise_error(an_instance_of(TriviaCrack::Errors::RequestError)
|
|
30
|
+
.and having_attributes(code: code)) }
|
|
31
|
+
it { expect{ subject }.to raise_error(an_instance_of(TriviaCrack::Errors::RequestError)
|
|
32
|
+
.and having_attributes(url: "/api/search?username=#{username}")) }
|
|
28
33
|
end
|
|
29
34
|
end
|
|
30
35
|
|
|
@@ -45,6 +50,10 @@ describe TriviaCrack::API::User do
|
|
|
45
50
|
let(:code) { 400 }
|
|
46
51
|
|
|
47
52
|
it { expect{ subject }.to raise_error TriviaCrack::Errors::RequestError }
|
|
53
|
+
it { expect{ subject }.to raise_error(an_instance_of(TriviaCrack::Errors::RequestError)
|
|
54
|
+
.and having_attributes(code: code)) }
|
|
55
|
+
it { expect{ subject }.to raise_error(an_instance_of(TriviaCrack::Errors::RequestError)
|
|
56
|
+
.and having_attributes(url: "/api/users/#{session.user_id}")) }
|
|
48
57
|
end
|
|
49
58
|
end
|
|
50
59
|
end
|
|
@@ -0,0 +1,336 @@
|
|
|
1
|
+
{
|
|
2
|
+
"id": 1119,
|
|
3
|
+
"safeOpponentSelectionType": "RANDOM",
|
|
4
|
+
"spins_data": {
|
|
5
|
+
"spins": [
|
|
6
|
+
{
|
|
7
|
+
"type": "DUEL",
|
|
8
|
+
"second_chance_available": false,
|
|
9
|
+
"questions": [
|
|
10
|
+
{
|
|
11
|
+
"question": {
|
|
12
|
+
"id": 17881223,
|
|
13
|
+
"category": "HISTORY",
|
|
14
|
+
"text": "The Suffrage movement pertained to what?",
|
|
15
|
+
"answers": [
|
|
16
|
+
"Prohibition",
|
|
17
|
+
"Racial Equality",
|
|
18
|
+
"Women's Rights",
|
|
19
|
+
"Right To Unionize"
|
|
20
|
+
],
|
|
21
|
+
"correct_answer": 2,
|
|
22
|
+
"media_type": "NORMAL",
|
|
23
|
+
"author": {
|
|
24
|
+
"id": 82565321,
|
|
25
|
+
"name": "anniesparkles",
|
|
26
|
+
"username": "anniesparkles",
|
|
27
|
+
"fb_show_picture": false,
|
|
28
|
+
"fb_show_name": false,
|
|
29
|
+
"gender": "UNSPECIFIED"
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
"question": {
|
|
35
|
+
"id": 53333638,
|
|
36
|
+
"category": "GEOGRAPHY",
|
|
37
|
+
"text": "Where is Slovakia?",
|
|
38
|
+
"answers": [
|
|
39
|
+
"Oceania",
|
|
40
|
+
"Africa",
|
|
41
|
+
"Europe",
|
|
42
|
+
"Asia"
|
|
43
|
+
],
|
|
44
|
+
"correct_answer": 2,
|
|
45
|
+
"media_type": "NORMAL",
|
|
46
|
+
"author": {
|
|
47
|
+
"id": 204000197,
|
|
48
|
+
"name": "martingres",
|
|
49
|
+
"username": "martingres",
|
|
50
|
+
"fb_show_picture": false,
|
|
51
|
+
"fb_show_name": false,
|
|
52
|
+
"gender": "UNSPECIFIED"
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
"question": {
|
|
58
|
+
"id": 62181053,
|
|
59
|
+
"category": "ARTS",
|
|
60
|
+
"text": "Who has painted the Sistine Chapel?",
|
|
61
|
+
"answers": [
|
|
62
|
+
"Michelangelo",
|
|
63
|
+
"Van Gogh",
|
|
64
|
+
"Picasso",
|
|
65
|
+
"Mezzosin"
|
|
66
|
+
],
|
|
67
|
+
"correct_answer": 0,
|
|
68
|
+
"media_type": "NORMAL",
|
|
69
|
+
"author": {
|
|
70
|
+
"id": 223909199,
|
|
71
|
+
"facebook_id": "843171349124950",
|
|
72
|
+
"name": "Kristina Marie Poulsen",
|
|
73
|
+
"username": "kp89facebook",
|
|
74
|
+
"facebook_name": "Kristina Marie Poulsen",
|
|
75
|
+
"fb_show_picture": true,
|
|
76
|
+
"fb_show_name": true,
|
|
77
|
+
"gender": "female"
|
|
78
|
+
},
|
|
79
|
+
"translator": {
|
|
80
|
+
"id": 252287897,
|
|
81
|
+
"name": "ragingraids",
|
|
82
|
+
"username": "ragingraids",
|
|
83
|
+
"fb_show_picture": false,
|
|
84
|
+
"fb_show_name": false,
|
|
85
|
+
"gender": "UNSPECIFIED"
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
"question": {
|
|
91
|
+
"id": 51360542,
|
|
92
|
+
"category": "SPORTS",
|
|
93
|
+
"text": "What two Allstars have the number of 23?",
|
|
94
|
+
"answers": [
|
|
95
|
+
"Steph Curry And Blake Griffen",
|
|
96
|
+
"Lebron James And Michael Jordan",
|
|
97
|
+
"Chris Paul And Jr Smith",
|
|
98
|
+
"Clay Thompson And Kevin Love"
|
|
99
|
+
],
|
|
100
|
+
"correct_answer": 1,
|
|
101
|
+
"media_type": "NORMAL",
|
|
102
|
+
"author": {
|
|
103
|
+
"id": 200488852,
|
|
104
|
+
"name": "mitchelldonegan06",
|
|
105
|
+
"username": "mitchelldonegan06",
|
|
106
|
+
"fb_show_picture": false,
|
|
107
|
+
"fb_show_name": false,
|
|
108
|
+
"gender": "UNSPECIFIED"
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
},
|
|
112
|
+
{
|
|
113
|
+
"question": {
|
|
114
|
+
"id": 11817577,
|
|
115
|
+
"category": "ENTERTAINMENT",
|
|
116
|
+
"text": "Which pop star calls her fans \"Monsters\"?",
|
|
117
|
+
"answers": [
|
|
118
|
+
"Madonna",
|
|
119
|
+
"Lady Gaga",
|
|
120
|
+
"Britney Spears",
|
|
121
|
+
"Christina Aguilera"
|
|
122
|
+
],
|
|
123
|
+
"correct_answer": 1,
|
|
124
|
+
"media_type": "NORMAL",
|
|
125
|
+
"author": {
|
|
126
|
+
"id": 51771646,
|
|
127
|
+
"facebook_id": "",
|
|
128
|
+
"name": "linda.tsacalides",
|
|
129
|
+
"username": "linda.tsacalides",
|
|
130
|
+
"facebook_name": "UNSPECIFIED",
|
|
131
|
+
"fb_show_picture": false,
|
|
132
|
+
"fb_show_name": false,
|
|
133
|
+
"gender": "female"
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
},
|
|
137
|
+
{
|
|
138
|
+
"question": {
|
|
139
|
+
"id": 54733278,
|
|
140
|
+
"category": "SCIENCE",
|
|
141
|
+
"text": "Which is NOT a blood type?",
|
|
142
|
+
"answers": [
|
|
143
|
+
"Ab",
|
|
144
|
+
"Oa",
|
|
145
|
+
"O",
|
|
146
|
+
"B"
|
|
147
|
+
],
|
|
148
|
+
"correct_answer": 1,
|
|
149
|
+
"media_type": "NORMAL",
|
|
150
|
+
"author": {
|
|
151
|
+
"id": 114837290,
|
|
152
|
+
"name": "rocat26",
|
|
153
|
+
"username": "rocat26",
|
|
154
|
+
"fb_show_picture": false,
|
|
155
|
+
"fb_show_name": false,
|
|
156
|
+
"gender": "female"
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
],
|
|
161
|
+
"tie_break_question": {
|
|
162
|
+
"id": 51774,
|
|
163
|
+
"category": "HISTORY",
|
|
164
|
+
"text": "Which historical figure is famous for being short?",
|
|
165
|
+
"answers": [
|
|
166
|
+
"Napoleon",
|
|
167
|
+
"Stalin",
|
|
168
|
+
"Bismark",
|
|
169
|
+
"Julius Caesar"
|
|
170
|
+
],
|
|
171
|
+
"correct_answer": 0,
|
|
172
|
+
"media_type": "NORMAL",
|
|
173
|
+
"author": {
|
|
174
|
+
"id": 23831917,
|
|
175
|
+
"facebook_id": "100006890463075",
|
|
176
|
+
"name": "Igor Gardella Trifunovic",
|
|
177
|
+
"username": "kider.jo",
|
|
178
|
+
"facebook_name": "Igor Gardella Trifunovic",
|
|
179
|
+
"fb_show_picture": true,
|
|
180
|
+
"fb_show_name": true,
|
|
181
|
+
"gender": "UNSPECIFIED"
|
|
182
|
+
},
|
|
183
|
+
"translator": {
|
|
184
|
+
"id": 100940141,
|
|
185
|
+
"facebook_id": "100002352524111",
|
|
186
|
+
"name": "Abigail Morgan",
|
|
187
|
+
"username": "almangel21",
|
|
188
|
+
"facebook_name": "Abigail Morgan",
|
|
189
|
+
"fb_show_picture": true,
|
|
190
|
+
"fb_show_name": true,
|
|
191
|
+
"gender": "female"
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
]
|
|
196
|
+
},
|
|
197
|
+
"available_crowns": [
|
|
198
|
+
"SCIENCE",
|
|
199
|
+
"HISTORY",
|
|
200
|
+
"ENTERTAINMENT",
|
|
201
|
+
"SPORTS"
|
|
202
|
+
],
|
|
203
|
+
"my_player_number": 1,
|
|
204
|
+
"player_one": {
|
|
205
|
+
"charges": 3,
|
|
206
|
+
"crowns": [
|
|
207
|
+
"GEOGRAPHY",
|
|
208
|
+
"ARTS"
|
|
209
|
+
]
|
|
210
|
+
},
|
|
211
|
+
"player_two": {
|
|
212
|
+
"charges": 0,
|
|
213
|
+
"crowns": [
|
|
214
|
+
"SCIENCE"
|
|
215
|
+
]
|
|
216
|
+
},
|
|
217
|
+
"round_number": 2,
|
|
218
|
+
"crown_events": [
|
|
219
|
+
{
|
|
220
|
+
"timestamp": 1583628928756,
|
|
221
|
+
"userId": 123,
|
|
222
|
+
"category": "SCIENCE",
|
|
223
|
+
"won": true
|
|
224
|
+
}
|
|
225
|
+
],
|
|
226
|
+
"sub_status": "P1_PLAYING_TURN",
|
|
227
|
+
"previous_sub_status": "P1_PLAYING_TURN",
|
|
228
|
+
"statistics": {
|
|
229
|
+
"player_one_statistics": {
|
|
230
|
+
"category_questions": [
|
|
231
|
+
{
|
|
232
|
+
"category": "HISTORY",
|
|
233
|
+
"correct": 1,
|
|
234
|
+
"incorrect": 0,
|
|
235
|
+
"worst": false
|
|
236
|
+
},
|
|
237
|
+
{
|
|
238
|
+
"category": "SCIENCE",
|
|
239
|
+
"correct": 2,
|
|
240
|
+
"incorrect": 0,
|
|
241
|
+
"worst": false
|
|
242
|
+
},
|
|
243
|
+
{
|
|
244
|
+
"category": "ARTS",
|
|
245
|
+
"correct": 3,
|
|
246
|
+
"incorrect": 0,
|
|
247
|
+
"worst": false
|
|
248
|
+
},
|
|
249
|
+
{
|
|
250
|
+
"category": "ENTERTAINMENT",
|
|
251
|
+
"correct": 0,
|
|
252
|
+
"incorrect": 1,
|
|
253
|
+
"worst": true,
|
|
254
|
+
"performance": 0
|
|
255
|
+
},
|
|
256
|
+
{
|
|
257
|
+
"category": "SPORTS",
|
|
258
|
+
"correct": 2,
|
|
259
|
+
"incorrect": 0,
|
|
260
|
+
"worst": false
|
|
261
|
+
},
|
|
262
|
+
{
|
|
263
|
+
"category": "GEOGRAPHY",
|
|
264
|
+
"correct": 1,
|
|
265
|
+
"incorrect": 0,
|
|
266
|
+
"worst": false
|
|
267
|
+
}
|
|
268
|
+
],
|
|
269
|
+
"correct_answers": 9,
|
|
270
|
+
"incorrect_answers": 1,
|
|
271
|
+
"challenges_won": 0,
|
|
272
|
+
"questions_answered": 10,
|
|
273
|
+
"crowns_won": 2
|
|
274
|
+
},
|
|
275
|
+
"player_two_statistics": {
|
|
276
|
+
"category_questions": [
|
|
277
|
+
{
|
|
278
|
+
"category": "HISTORY",
|
|
279
|
+
"correct": 0,
|
|
280
|
+
"incorrect": 1,
|
|
281
|
+
"worst": false
|
|
282
|
+
},
|
|
283
|
+
{
|
|
284
|
+
"category": "SCIENCE",
|
|
285
|
+
"correct": 1,
|
|
286
|
+
"incorrect": 0,
|
|
287
|
+
"worst": false
|
|
288
|
+
}
|
|
289
|
+
],
|
|
290
|
+
"correct_answers": 1,
|
|
291
|
+
"incorrect_answers": 1,
|
|
292
|
+
"challenges_won": 0,
|
|
293
|
+
"questions_answered": 2,
|
|
294
|
+
"crowns_won": 1
|
|
295
|
+
}
|
|
296
|
+
},
|
|
297
|
+
"is_random": true,
|
|
298
|
+
"unread_messages": 0,
|
|
299
|
+
"last_turn": "03/07/2020 19:56:48 EST",
|
|
300
|
+
"status_version": 13,
|
|
301
|
+
"my_level_data": {
|
|
302
|
+
"level": 16,
|
|
303
|
+
"points": 152,
|
|
304
|
+
"goal_points": 168,
|
|
305
|
+
"progress": 11,
|
|
306
|
+
"level_up": true
|
|
307
|
+
},
|
|
308
|
+
"opponent_selection_type": "RANDOM",
|
|
309
|
+
"nudge_available": false,
|
|
310
|
+
"opponent": {
|
|
311
|
+
"id": 321,
|
|
312
|
+
"alerts_count": 0,
|
|
313
|
+
"username": "aaa",
|
|
314
|
+
"facebook_id": "123",
|
|
315
|
+
"facebookId": {
|
|
316
|
+
"value": "",
|
|
317
|
+
"defined": false
|
|
318
|
+
},
|
|
319
|
+
"facebook_name": "a b",
|
|
320
|
+
"fb_show_picture": true,
|
|
321
|
+
"fb_show_name": true,
|
|
322
|
+
"allow_og_posts": true,
|
|
323
|
+
"photo_url": "",
|
|
324
|
+
"level_data": {
|
|
325
|
+
"level": 6
|
|
326
|
+
},
|
|
327
|
+
"is_friend": false,
|
|
328
|
+
"league_name": "APPRENTICE_1"
|
|
329
|
+
},
|
|
330
|
+
"game_status": "ACTIVE",
|
|
331
|
+
"language": "EN",
|
|
332
|
+
"created": "03/07/2020 19:30:03 EST",
|
|
333
|
+
"type": "NORMAL",
|
|
334
|
+
"my_turn": true,
|
|
335
|
+
"expiration_date": "03/09/2020 07:56:48 EST"
|
|
336
|
+
}
|
|
@@ -110,5 +110,31 @@ describe TriviaCrack::Parsers::GameParser do
|
|
|
110
110
|
its(:my_statistics) { is_expected.to be_a TriviaCrack::GameStatistics }
|
|
111
111
|
its(:opponent_statistics) { is_expected.to be_a TriviaCrack::GameStatistics }
|
|
112
112
|
end
|
|
113
|
+
|
|
114
|
+
context 'when given data from the games API and the game is a duel' do
|
|
115
|
+
let(:raw_data) { SpecData.get "game_duel.json" }
|
|
116
|
+
|
|
117
|
+
it { is_expected.to be_a TriviaCrack::Game }
|
|
118
|
+
its(:id) { is_expected.to be 1119 }
|
|
119
|
+
its(:opponent) { is_expected.to be_a TriviaCrack::User }
|
|
120
|
+
its('opponent.id') { is_expected.to be 321 }
|
|
121
|
+
its(:game_status) { is_expected.to be :active }
|
|
122
|
+
its(:language) { is_expected.to be :en }
|
|
123
|
+
its(:created) { is_expected.to be_a Time }
|
|
124
|
+
its(:last_turn) { is_expected.to be_a Time }
|
|
125
|
+
its(:type) { is_expected.to be :normal }
|
|
126
|
+
its(:expiration_date) { is_expected.to be_a Time }
|
|
127
|
+
its(:my_turn) { is_expected.to be true }
|
|
128
|
+
its(:round_number) { is_expected.to be 2 }
|
|
129
|
+
its(:is_random) { is_expected.to be true }
|
|
130
|
+
its(:unread_messages) { is_expected.to be 0 }
|
|
131
|
+
its(:status_version) { is_expected.to be 13 }
|
|
132
|
+
its(:available_crowns) { is_expected.to contain_exactly(:entertainment, :science, :history, :sports) }
|
|
133
|
+
its('questions.size') { is_expected.to eq(7) }
|
|
134
|
+
its('questions.first') { is_expected.to be_a TriviaCrack::Question }
|
|
135
|
+
its('questions.first.id') { is_expected.to be 17881223 }
|
|
136
|
+
its(:my_statistics) { is_expected.to be_a TriviaCrack::GameStatistics }
|
|
137
|
+
its(:opponent_statistics) { is_expected.to be_a TriviaCrack::GameStatistics }
|
|
138
|
+
end
|
|
113
139
|
end
|
|
114
140
|
end
|
data/triviacrack.gemspec
CHANGED
|
@@ -18,13 +18,15 @@ Gem::Specification.new do |spec|
|
|
|
18
18
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
|
19
19
|
spec.require_paths = ["lib"]
|
|
20
20
|
|
|
21
|
-
spec.
|
|
22
|
-
|
|
23
|
-
spec.add_development_dependency "
|
|
24
|
-
spec.add_development_dependency "
|
|
21
|
+
spec.required_ruby_version = ">= 2.0"
|
|
22
|
+
|
|
23
|
+
spec.add_development_dependency "bundler", "~> 2.2.27"
|
|
24
|
+
spec.add_development_dependency "simplecov", "~> 0.21.2"
|
|
25
|
+
spec.add_development_dependency "rake", "~> 13.0.6"
|
|
26
|
+
spec.add_development_dependency "rspec", "~> 3.10.0"
|
|
25
27
|
spec.add_development_dependency "rspec-its", "~> 1.3.0"
|
|
26
|
-
spec.add_development_dependency "json", "~> 2.
|
|
27
|
-
spec.add_development_dependency "fuubar", "~> 2.5.
|
|
28
|
+
spec.add_development_dependency "json", "~> 2.5.1"
|
|
29
|
+
spec.add_development_dependency "fuubar", "~> 2.5.1"
|
|
28
30
|
|
|
29
|
-
spec.add_dependency "
|
|
31
|
+
spec.add_dependency "faraday", "~> 1.7.2"
|
|
30
32
|
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: triviacrack
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.5.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- David Kus
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2021-09-17 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: bundler
|
|
@@ -16,56 +16,56 @@ dependencies:
|
|
|
16
16
|
requirements:
|
|
17
17
|
- - "~>"
|
|
18
18
|
- !ruby/object:Gem::Version
|
|
19
|
-
version: 2.
|
|
19
|
+
version: 2.2.27
|
|
20
20
|
type: :development
|
|
21
21
|
prerelease: false
|
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
|
23
23
|
requirements:
|
|
24
24
|
- - "~>"
|
|
25
25
|
- !ruby/object:Gem::Version
|
|
26
|
-
version: 2.
|
|
26
|
+
version: 2.2.27
|
|
27
27
|
- !ruby/object:Gem::Dependency
|
|
28
28
|
name: simplecov
|
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
|
30
30
|
requirements:
|
|
31
31
|
- - "~>"
|
|
32
32
|
- !ruby/object:Gem::Version
|
|
33
|
-
version: 0.
|
|
33
|
+
version: 0.21.2
|
|
34
34
|
type: :development
|
|
35
35
|
prerelease: false
|
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
|
37
37
|
requirements:
|
|
38
38
|
- - "~>"
|
|
39
39
|
- !ruby/object:Gem::Version
|
|
40
|
-
version: 0.
|
|
40
|
+
version: 0.21.2
|
|
41
41
|
- !ruby/object:Gem::Dependency
|
|
42
42
|
name: rake
|
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
|
44
44
|
requirements:
|
|
45
45
|
- - "~>"
|
|
46
46
|
- !ruby/object:Gem::Version
|
|
47
|
-
version: 13.0.
|
|
47
|
+
version: 13.0.6
|
|
48
48
|
type: :development
|
|
49
49
|
prerelease: false
|
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
|
51
51
|
requirements:
|
|
52
52
|
- - "~>"
|
|
53
53
|
- !ruby/object:Gem::Version
|
|
54
|
-
version: 13.0.
|
|
54
|
+
version: 13.0.6
|
|
55
55
|
- !ruby/object:Gem::Dependency
|
|
56
56
|
name: rspec
|
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
|
58
58
|
requirements:
|
|
59
59
|
- - "~>"
|
|
60
60
|
- !ruby/object:Gem::Version
|
|
61
|
-
version: 3.
|
|
61
|
+
version: 3.10.0
|
|
62
62
|
type: :development
|
|
63
63
|
prerelease: false
|
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
|
65
65
|
requirements:
|
|
66
66
|
- - "~>"
|
|
67
67
|
- !ruby/object:Gem::Version
|
|
68
|
-
version: 3.
|
|
68
|
+
version: 3.10.0
|
|
69
69
|
- !ruby/object:Gem::Dependency
|
|
70
70
|
name: rspec-its
|
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -86,42 +86,42 @@ dependencies:
|
|
|
86
86
|
requirements:
|
|
87
87
|
- - "~>"
|
|
88
88
|
- !ruby/object:Gem::Version
|
|
89
|
-
version: 2.
|
|
89
|
+
version: 2.5.1
|
|
90
90
|
type: :development
|
|
91
91
|
prerelease: false
|
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
|
93
93
|
requirements:
|
|
94
94
|
- - "~>"
|
|
95
95
|
- !ruby/object:Gem::Version
|
|
96
|
-
version: 2.
|
|
96
|
+
version: 2.5.1
|
|
97
97
|
- !ruby/object:Gem::Dependency
|
|
98
98
|
name: fuubar
|
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
|
100
100
|
requirements:
|
|
101
101
|
- - "~>"
|
|
102
102
|
- !ruby/object:Gem::Version
|
|
103
|
-
version: 2.5.
|
|
103
|
+
version: 2.5.1
|
|
104
104
|
type: :development
|
|
105
105
|
prerelease: false
|
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
|
107
107
|
requirements:
|
|
108
108
|
- - "~>"
|
|
109
109
|
- !ruby/object:Gem::Version
|
|
110
|
-
version: 2.5.
|
|
110
|
+
version: 2.5.1
|
|
111
111
|
- !ruby/object:Gem::Dependency
|
|
112
|
-
name:
|
|
112
|
+
name: faraday
|
|
113
113
|
requirement: !ruby/object:Gem::Requirement
|
|
114
114
|
requirements:
|
|
115
115
|
- - "~>"
|
|
116
116
|
- !ruby/object:Gem::Version
|
|
117
|
-
version: 1.
|
|
117
|
+
version: 1.7.2
|
|
118
118
|
type: :runtime
|
|
119
119
|
prerelease: false
|
|
120
120
|
version_requirements: !ruby/object:Gem::Requirement
|
|
121
121
|
requirements:
|
|
122
122
|
- - "~>"
|
|
123
123
|
- !ruby/object:Gem::Version
|
|
124
|
-
version: 1.
|
|
124
|
+
version: 1.7.2
|
|
125
125
|
description: A Ruby interface to the Trivia Crack API.
|
|
126
126
|
email:
|
|
127
127
|
- david@kus.dk
|
|
@@ -130,9 +130,12 @@ extensions: []
|
|
|
130
130
|
extra_rdoc_files: []
|
|
131
131
|
files:
|
|
132
132
|
- ".github/workflows/ci.yml"
|
|
133
|
+
- ".github/workflows/publish.yml"
|
|
133
134
|
- ".gitignore"
|
|
134
135
|
- ".rspec"
|
|
136
|
+
- ".ruby-version"
|
|
135
137
|
- Gemfile
|
|
138
|
+
- Gemfile.lock
|
|
136
139
|
- LICENSE.txt
|
|
137
140
|
- README.md
|
|
138
141
|
- Rakefile
|
|
@@ -170,6 +173,7 @@ files:
|
|
|
170
173
|
- spec/data/answer.json
|
|
171
174
|
- spec/data/dashboard.json
|
|
172
175
|
- spec/data/game.json
|
|
176
|
+
- spec/data/game_duel.json
|
|
173
177
|
- spec/data/login.json
|
|
174
178
|
- spec/data/my_profile.json
|
|
175
179
|
- spec/data/new_game.json
|
|
@@ -202,14 +206,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
202
206
|
requirements:
|
|
203
207
|
- - ">="
|
|
204
208
|
- !ruby/object:Gem::Version
|
|
205
|
-
version: '0'
|
|
209
|
+
version: '2.0'
|
|
206
210
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
207
211
|
requirements:
|
|
208
212
|
- - ">="
|
|
209
213
|
- !ruby/object:Gem::Version
|
|
210
214
|
version: '0'
|
|
211
215
|
requirements: []
|
|
212
|
-
rubygems_version: 3.
|
|
216
|
+
rubygems_version: 3.2.22
|
|
213
217
|
signing_key:
|
|
214
218
|
specification_version: 4
|
|
215
219
|
summary: A Ruby interface to the Trivia Crack API.
|
|
@@ -222,6 +226,7 @@ test_files:
|
|
|
222
226
|
- spec/data/answer.json
|
|
223
227
|
- spec/data/dashboard.json
|
|
224
228
|
- spec/data/game.json
|
|
229
|
+
- spec/data/game_duel.json
|
|
225
230
|
- spec/data/login.json
|
|
226
231
|
- spec/data/my_profile.json
|
|
227
232
|
- spec/data/new_game.json
|