Sha256: 86a6f32dfeb9457cb8c427f140d2654a2fcd460dc4664510644b4f5802fbf3e0

Contents?: true

Size: 1.71 KB

Versions: 22

Compression:

Stored size: 1.71 KB

Contents

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

describe Libgss::ActionRequest do

  let(:network){ new_network }

  let(:request) do
    network.login
    network.new_action_request
  end


  describe "log#create" do
    it "valid" do
      callback_called = false
      # player_id, created_atはサーバで設定されます。
      request.create("ItemIncomingLog", {"level" => 1, "item_cd" => 10001, "incoming_route_cd" => 1, "amount" => 2})
      request.send_request do |outputs|
        callback_called = true
        outputs.length.should == 1
        outputs.first["result"].should == "OK"
      end
      callback_called.should == true
    end

    shared_examples_for "log#create invalid" do |error_code, attrs|
      it "with additional field" do
        callback_called = false
        request.create("ItemIncomingLog", attrs)
        request.send_request do |outputs|
          callback_called = true
          outputs.length.should == 1
          error = outputs.first["error"]
          error.should_not be_nil
          error["message"].should =~ /^#{error_code}\:/
          error["input"].should == {
            "id" => 1,
            "name" => "ItemIncomingLog",
            "attrs" => attrs,
            "action"=>"create"
          }
          outputs.first["id"].should == 1
          outputs.first["result"].should == nil
        end
        callback_called.should == true
      end
    end

    it_should_behave_like "log#create invalid", 1004, {"level" => 1, "item_cd" => 10001, "incoming_route_cd" => 1, "amount" => 2, "extra_field" => 100}
    it_should_behave_like "log#create invalid", 1005, {"level" => 1, "item_cd" => 10001, "incoming_route_cd" => 1} # 必須のフィールドamountがないのでエラー
  end

end

Version data entries

22 entries across 22 versions & 1 rubygems

Version Path
libgss-0.11.0 spec/libgss/actions/log_spec.rb
libgss-0.10.0 spec/libgss/actions/log_spec.rb
libgss-0.9.0 spec/libgss/actions/log_spec.rb
libgss-0.8.4 spec/libgss/actions/log_spec.rb
libgss-0.8.3 spec/libgss/actions/log_spec.rb
libgss-0.8.2 spec/libgss/actions/log_spec.rb
libgss-0.8.1 spec/libgss/actions/log_spec.rb
libgss-0.8.0 spec/libgss/actions/log_spec.rb
libgss-0.7.6 spec/libgss/actions/log_spec.rb
libgss-0.7.5 spec/libgss/actions/log_spec.rb
libgss-0.7.4 spec/libgss/actions/log_spec.rb
libgss-0.7.3 spec/libgss/actions/log_spec.rb
libgss-0.7.2 spec/libgss/actions/log_spec.rb
libgss-0.7.1 spec/libgss/actions/log_spec.rb
libgss-0.7.0 spec/libgss/actions/log_spec.rb
libgss-0.6.2 spec/libgss/actions/log_spec.rb
libgss-0.6.1 spec/libgss/actions/log_spec.rb
libgss-0.6.0 spec/libgss/actions/log_spec.rb
libgss-0.5.0 spec/libgss/actions/log_spec.rb
libgss-0.4.1 spec/libgss/actions/log_spec.rb