Sha256: a750edf07d54c4bfa2bedd7369c3f5d11cb0653bb0370126dd02fb3efc9bd65e

Contents?: true

Size: 1.37 KB

Versions: 1

Compression:

Stored size: 1.37 KB

Contents

require "spec_helper"

module Fonte
  module Parsers
    describe PropertyParser do
      let(:parser) { described_class.new }

      subject { parser.parse(properties) }

      context "with one property" do
        let(:properties) { '(key "value")' }
        it { should be }
        its(:value) { should == { "key" => "value" } }
      end

      context "with multiple properties" do
        let(:properties) { '(key1 "value1") (key2 "value2")' }
        it { should be }
        its(:value) { should == { "key1" => "value1", "key2" => "value2" } }
      end

      context "with properties without values" do
        let(:properties) { '(headshot)' }
        it { should be }
        its(:value) { should == { "headshot" => true } }
      end

      context "player property" do
        let(:properties) { '(player "Reu<2><STEAM_1:1:24968171><Red>")' }
        it { should be }

        describe "player" do
          subject { parser.parse(properties).value["player"] }
          it_should_behave_like "a real player"
        end
      end

      context "number property" do
        let(:properties) { '(area "10")' }
        its(:value) { should == { "area" => 10 } }
      end

      context "coordinate property" do
        let(:properties) { '(attacker_position "-1624 1258 617")' }
        its(:value) { should == { "attacker_position" => [-1624, 1258, 617] } }
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
fonte-0.2.0 spec/parsers/property_parser_spec.rb