Sha256: 05696f356fbd3e8b35961e77d2ebe5313118ae8784a801e2e7f3b6b04e9d5870

Contents?: true

Size: 1.21 KB

Versions: 36

Compression:

Stored size: 1.21 KB

Contents

require 'spec_helper'

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

      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[:message]).to eq('Not authenticated')
    end
  end
end

Version data entries

36 entries across 32 versions & 1 rubygems

Version Path
rubypitaya-3.19.6 ./lib/rubypitaya/app-template/spec/player_handler_spec.rb
rubypitaya-3.19.5 ./lib/rubypitaya/app-template/spec/player_handler_spec.rb
rubypitaya-3.19.4 ./lib/rubypitaya/app-template/spec/player_handler_spec.rb
rubypitaya-3.19.3 ./lib/rubypitaya/app-template/spec/player_handler_spec.rb
rubypitaya-3.19.2 ./lib/rubypitaya/app-template/spec/player_handler_spec.rb
rubypitaya-3.19.1 ./lib/rubypitaya/app-template/spec/player_handler_spec.rb
rubypitaya-3.19.0 ./lib/rubypitaya/app-template/spec/player_handler_spec.rb
rubypitaya-3.18.0 ./lib/rubypitaya/app-template/spec/player_handler_spec.rb
rubypitaya-3.17.2 ./lib/rubypitaya/app-template/spec/player_handler_spec.rb
rubypitaya-3.17.1 ./lib/rubypitaya/app-template/spec/player_handler_spec.rb
rubypitaya-3.17.0 ./lib/rubypitaya/app-template/spec/player_handler_spec.rb
rubypitaya-3.16.0 ./lib/rubypitaya/app-template/spec/player_handler_spec.rb
rubypitaya-3.15.3 ./lib/rubypitaya/app-template/spec/player_handler_spec.rb
rubypitaya-3.15.2 ./lib/rubypitaya/app-template/spec/player_handler_spec.rb
rubypitaya-3.15.1 ./lib/rubypitaya/app-template/spec/player_handler_spec.rb
rubypitaya-3.15.0 ./lib/rubypitaya/app-template/spec/player_handler_spec.rb
rubypitaya-3.14.0 ./lib/rubypitaya/app-template/spec/player_handler_spec.rb
rubypitaya-3.13.1 ./lib/rubypitaya/app-template/spec/player_handler_spec.rb
rubypitaya-3.13.0 ./lib/rubypitaya/app-template/spec/player_handler_spec.rb
rubypitaya-3.12.5 ./lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rubypitaya-3.12.1/lib/rubypitaya/app-template/spec/player_handler_spec.rb