spec/parsers/game_parser_spec.rb in triviacrack-0.6.0 vs spec/parsers/game_parser_spec.rb in triviacrack-0.7.0
- old
+ new
@@ -1,20 +1,20 @@
-require "spec_helper"
+# frozen_string_literal: true
-describe TriviaCrack::Parsers::GameParser do
+require 'spec_helper'
- describe ".parse" do
-
+describe TriviaCrack::Parsers::GameParser do
+ describe '.parse' do
subject { TriviaCrack::Parsers::GameParser.parse raw_data }
- let(:game_data) { SpecData.get_json "game.json" }
- let(:dashboard_data) { SpecData.get_json "dashboard.json" }
- let(:answer_data) { SpecData.get_json "answer.json" }
- let(:new_game_data) { SpecData.get_json "new_game.json" }
+ let(:game_data) { SpecData.get_json 'game.json' }
+ let(:dashboard_data) { SpecData.get_json 'dashboard.json' }
+ let(:answer_data) { SpecData.get_json 'answer.json' }
+ let(:new_game_data) { SpecData.get_json 'new_game.json' }
context 'when given data from the games API' do
- let(:raw_data) { SpecData.get_json "game.json" }
+ let(:raw_data) { SpecData.get_json 'game.json' }
it { is_expected.to be_a TriviaCrack::Game }
its(:id) { is_expected.to be 1111 }
its(:opponent) { is_expected.to be_a TriviaCrack::User }
its('opponent.id') { is_expected.to be 111 }
@@ -29,17 +29,17 @@
its(:is_random) { is_expected.to be true }
its(:unread_messages) { is_expected.to be 0 }
its(:status_version) { is_expected.to be 23 }
its(:available_crowns) { is_expected.to contain_exactly(:entertainment, :arts, :sports) }
its('questions.first') { is_expected.to be_a TriviaCrack::Question }
- its('questions.first.id') { is_expected.to be 16653413 }
+ its('questions.first.id') { is_expected.to be 16_653_413 }
its(:my_statistics) { is_expected.to be_a TriviaCrack::GameStatistics }
its(:opponent_statistics) { is_expected.to be_a TriviaCrack::GameStatistics }
end
context 'when given data from the dashboard API' do
- let(:raw_data) { SpecData.get_json("dashboard.json")["list"][3] }
+ let(:raw_data) { SpecData.get_json('dashboard.json')['list'][3] }
it { is_expected.to be_a TriviaCrack::Game }
its(:id) { is_expected.to be 1115 }
its(:opponent) { is_expected.to be_a TriviaCrack::User }
its('opponent.id') { is_expected.to be 114 }
@@ -54,17 +54,17 @@
its(:is_random) { is_expected.to be true }
its(:unread_messages) { is_expected.to be 0 }
its(:status_version) { is_expected.to be 24 }
its(:available_crowns) { is_expected.to contain_exactly(:entertainment, :arts, :sports) }
its('questions.first') { is_expected.to be_a TriviaCrack::Question }
- its('questions.first.id') { is_expected.to be 15593975 }
+ its('questions.first.id') { is_expected.to be 15_593_975 }
its(:my_statistics) { is_expected.to be_a TriviaCrack::GameStatistics }
its(:opponent_statistics) { is_expected.to be_a TriviaCrack::GameStatistics }
end
context 'when given data from the answers API' do
- let(:raw_data) { SpecData.get_json "answer.json" }
+ let(:raw_data) { SpecData.get_json 'answer.json' }
it { is_expected.to be_a TriviaCrack::Game }
its(:id) { is_expected.to be 1111 }
its(:opponent) { is_expected.to be_a TriviaCrack::User }
its('opponent.id') { is_expected.to be 111 }
@@ -79,17 +79,17 @@
its(:is_random) { is_expected.to be true }
its(:unread_messages) { is_expected.to be 0 }
its(:status_version) { is_expected.to be 24 }
its(:available_crowns) { is_expected.to contain_exactly(:entertainment, :arts, :sports) }
its('questions.first') { is_expected.to be_a TriviaCrack::Question }
- its('questions.first.id') { is_expected.to be 15593975 }
+ its('questions.first.id') { is_expected.to be 15_593_975 }
its(:my_statistics) { is_expected.to be_a TriviaCrack::GameStatistics }
its(:opponent_statistics) { is_expected.to be_a TriviaCrack::GameStatistics }
end
context 'when given data from the new game API' do
- let(:raw_data) { SpecData.get_json "new_game.json" }
+ let(:raw_data) { SpecData.get_json 'new_game.json' }
it { is_expected.to be_a TriviaCrack::Game }
its(:id) { is_expected.to be 2222 }
its(:opponent) { is_expected.to be_a TriviaCrack::User }
its('opponent.id') { is_expected.to be 0 }
@@ -102,19 +102,21 @@
its(:my_turn) { is_expected.to be true }
its(:round_number) { is_expected.to be 1 }
its(:is_random) { is_expected.to be true }
its(:unread_messages) { is_expected.to be 0 }
its(:status_version) { is_expected.to be 0 }
- its(:available_crowns) { is_expected.to contain_exactly(:arts, :entertainment, :geography, :history, :science, :sports) }
+ its(:available_crowns) do
+ is_expected.to contain_exactly(:arts, :entertainment, :geography, :history, :science, :sports)
+ end
its('questions.first') { is_expected.to be_a TriviaCrack::Question }
- its('questions.first.id') { is_expected.to be 12785 }
+ its('questions.first.id') { is_expected.to be 12_785 }
its(:my_statistics) { is_expected.to be_a TriviaCrack::GameStatistics }
its(:opponent_statistics) { is_expected.to be_a TriviaCrack::GameStatistics }
end
context 'when given data from the games API and the game is a duel' do
- let(:raw_data) { SpecData.get_json "game_duel.json" }
+ let(:raw_data) { SpecData.get_json 'game_duel.json' }
it { is_expected.to be_a TriviaCrack::Game }
its(:id) { is_expected.to be 1119 }
its(:opponent) { is_expected.to be_a TriviaCrack::User }
its('opponent.id') { is_expected.to be 321 }
@@ -130,10 +132,10 @@
its(:unread_messages) { is_expected.to be 0 }
its(:status_version) { is_expected.to be 13 }
its(:available_crowns) { is_expected.to contain_exactly(:entertainment, :science, :history, :sports) }
its('questions.size') { is_expected.to eq(7) }
its('questions.first') { is_expected.to be_a TriviaCrack::Question }
- its('questions.first.id') { is_expected.to be 17881223 }
+ its('questions.first.id') { is_expected.to be 17_881_223 }
its(:my_statistics) { is_expected.to be_a TriviaCrack::GameStatistics }
its(:opponent_statistics) { is_expected.to be_a TriviaCrack::GameStatistics }
end
end
end