spec/parsers/action_parser_spec.rb in fonte-0.1.0 vs spec/parsers/action_parser_spec.rb in fonte-0.2.0

- old
+ new

@@ -58,10 +58,16 @@ context "without the 'Server' entry" do let(:action) { '"key" = "value"' } its(:value) { should == "cvar set" } its(:"to_hash") { should == { "key" => "value"} } end + + context "when it starts with server_cvar" do + let(:action) { 'server_cvar: "key" "value"' } + its(:value) { should == "cvar set" } + its(:"to_hash") { should == { "key" => "value"} } + end end describe "sever name" do let(:action) { 'Server name is "Manapot Server"' } its(:value) { should == "server name" } @@ -173,10 +179,22 @@ context "with properties" do let(:action) { '"Reu<2><STEAM_1:1:24968171><Blue>" killed "guimello<13><STEAM_1:1:34492580><Red>" with "minigun" (attacker_position "3354 -2485 -187") (victim_position "3410 -2518 -149")' } it_should_behave_like "a action with properties", "attacker_position", "victim_position" end + + context "l4d2 format" do + let(:action) { '(DEATH)"Reu<2><STEAM_1:1:24968171><Survivor><Gambler><ALIVE><80+0><setpos_exact 4793.19 -3962.89 165.33; setang 18.14 -34.47 0.00><Area 70>" killed "infected<552><><Infected><infected><DEAD><0><setpos_exact 4831.17 -3989.32 104.81; setang 0.00 288.65 0.00><Area 792>" with "melee"' } + its(:value) { should == "kill" } + its(:"attacker.value") { should == "Reu<2><STEAM_1:1:24968171><Survivor>" } + its(:"victim.value") { should == "infected<552><><Infected>" } + + context "with properties" do + let(:action) { '(DEATH)"Reu<2><STEAM_1:1:24968171><Survivor><Gambler><ALIVE><80+0><setpos_exact 4793.19 -3962.89 165.33; setang 18.14 -34.47 0.00><Area 70>" killed "infected<552><><Infected><infected><DEAD><0><setpos_exact 4831.17 -3989.32 104.81; setang 0.00 288.65 0.00><Area 792>" with "melee" (headshot)' } + it_should_behave_like "a action with properties", "headshot" + end + end end describe "injure" do let(:action) { '"Reu<2><STEAM_1:1:24968171><Blue>" attacked "guimello<13><STEAM_1:1:34492580><Red>" with "minigun"' } its(:value) { should == "injure" } @@ -247,10 +265,15 @@ context "with properties" do let(:action) { 'World triggered "Mini_Round_Selected" (round "Round_A")' } it_should_behave_like "a action with properties", "round" end + + context "with reason" do + let(:action) { 'World triggered "Game_Over" reason "Reached Time Limit"' } + its(:value) { should == "Game_Over" } + end end describe "chat" do let(:action) { '"Reu<2><STEAM_1:1:24968171><Blue>" say "hai"' } its(:value) { should == "chat" } @@ -314,9 +337,27 @@ describe "weapon pickup" do let(:action) { '"Reu<2><STEAM_1:1:24968171><Blue>" acquired weapon "Shotgun"' } its(:value) { should == "weapon pickup" } its(:"player.value") { should == "Reu<2><STEAM_1:1:24968171><Blue>" } its(:"weapon.value") { should == "Shotgun" } + end + + describe "rcon command" do + let(:action) { 'Rcon: "rcon challenge "password" command" from "192.168.10.1:17015"' } + it_should_behave_like "a rcon command", :password => "password", :origin => "//192.168.10.1:17015" + end + + describe "steamauth" do + let(:action) { 'STEAMAUTH: Client reu received failure code 6' } + its(:value) { should == "authentication failure" } + its(:"client.value") { should == "reu" } + its(:"code.value") { should == 6 } + end + + describe "spawn" do + let(:action) { '"Pulo_ms<8><STEAM_1:1:41920953><Survivor><Producer><ALIVE><100+0><setpos_exact 3617.36 -1739.69 294.53; setang 0.00 179.84 0.00><Area 205>" spawned' } + its(:value) { should == "spawn" } + its(:"player.value") { should == "Pulo_ms<8><STEAM_1:1:41920953><Survivor>" } end end end end