Sha256: a1c4433d21ecda8ce23a649cca0ebb7c50c536dc584765fa45d29ad9d49fad1c

Contents?: true

Size: 1.24 KB

Versions: 11

Compression:

Stored size: 1.24 KB

Contents

require 'spec_helper'

RSpec.describe 'PlayerHandler', type: :request do
  context 'authenticate' do
    it 'create_new_user' do
      setup = {'initial_player' => {'wallet' => {'gold' => 10}}}
      config = {'initial_player' => {'name' => 'Guest'}}

      set_setup(setup)
      set_config(config)

      params = {}
      request("rubypitaya.playerHandler.authenticate", params)

      player = Player.last

      expect(response[:code]).to eq('RP-200')
      expect(response[:data][:name]).to eq('Guest')
      expect(response[:data][:gold]).to eq(10)

      expect(User.count).to eq(1)
      expect(Player.count).to eq(1)
      expect(player.name).to eq('Guest')
      expect(player.gold).to eq(10)
    end
  end

  context 'getInfo' do
    it 'success' do
      player = Player.create(name: 'Someone', gold: 12, user: User.new)

      authenticate(player.user_id)

      request("rubypitaya.playerHandler.getInfo")

      expect(response[:code]).to eq('RP-200')
      expect(response[:data]).to eq(player.to_hash)
    end

    it 'error_not_authenticated' do
      request("rubypitaya.playerHandler.getInfo")

      expect(response[:code]).to eq(RubyPitaya::StatusCodes::CODE_NOT_AUTHENTICATED)
      expect(response[:msg]).to eq('Not authenticated')
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
rubypitaya-2.20.0 ./lib/rubypitaya/app-template/spec/player_handler_spec.rb
rubypitaya-2.19.1 ./lib/rubypitaya/app-template/spec/player_handler_spec.rb
rubypitaya-2.19.0 ./lib/rubypitaya/app-template/spec/player_handler_spec.rb
rubypitaya-2.18.0 ./lib/rubypitaya/app-template/spec/player_handler_spec.rb
rubypitaya-2.17.0 ./lib/rubypitaya/app-template/spec/player_handler_spec.rb
rubypitaya-2.16.0 ./lib/rubypitaya/app-template/spec/player_handler_spec.rb
rubypitaya-2.15.0 ./lib/rubypitaya/app-template/spec/player_handler_spec.rb
rubypitaya-2.14.1 ./lib/rubypitaya/app-template/spec/player_handler_spec.rb
rubypitaya-2.14.0 ./lib/rubypitaya/app-template/spec/player_handler_spec.rb
rubypitaya-2.13.1 ./lib/rubypitaya/app-template/spec/player_handler_spec.rb
rubypitaya-2.13.0 ./lib/rubypitaya/app-template/spec/player_handler_spec.rb