Sha256: 5a99c019e0a1834dc6e2c8ef2d9ab8e051e4b404f68c66a162f68fef0595b7ac

Contents?: true

Size: 1.67 KB

Versions: 3

Compression:

Stored size: 1.67 KB

Contents

# -*- coding: utf-8 -*-
require 'spec_helper'

describe Libgss::ActionRequest do

  let(:network) do
    network = Libgss::Network.new("http://localhost:3000")
    network.player_id = "1000001"
    network.login
    network
  end

  let(:request) do
    network.new_action_request
  end


  describe "ruby_stored_script#execute" do
    before do
      request_fixture_load("01_basic")
      # HP満タンなので、減らす
      req1 = network.new_action_request
      req1.get_by_game_data
      req1.send_request # コールバックなしでもOK

      req1.outputs.length.should == 1
      game_data = req1.outputs.first["result"]
      new_content_attrs = {"hp" => 10} # 5ポイント減らす
      game_data["content"].update(new_content_attrs)
      #
      req2 = network.new_action_request
      req2.update("GameData", game_data)
      req2.send_request
      req2.outputs.first["result"].should == "OK"
    end


    it "valid" do
      callback_called = false
      request.execute("ItemRubyStoredScript", "use_item", {"item_cd" => "20001"})
      request.send_request do |outputs|
        callback_called = true
        outputs.length.should == 1
        outputs.first["result"].should == "recovery hp 5points"
      end
      callback_called.should == true
    end

    it "invalid args" do
      pending "どう振る舞うべきか検討"
      callback_called = false
      request.execute("ItemRubyStoredScript", "use_item", {}) # 引数の指定なし
      request.send_request do |outputs|
        callback_called = true
        outputs.length.should == 1
        outputs.first["result"].should == "recovery hp 5points"
      end
      callback_called.should == true
    end
  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
libgss-0.2.0 spec/libgss/actions/ruby_stored_script_spec.rb
libgss-0.0.2 spec/libgss/actions/ruby_stored_script_spec.rb
libgss-0.0.1 spec/libgss/actions/ruby_stored_script_spec.rb