minecraft 0.2.1 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2,6 +2,25 @@ require "helper"
2
2
  require "minecraft"
3
3
 
4
4
  class ExtensionsTest < Test
5
+ # Coloured line testing.
6
+ sandbox_test "should colour server side lines properly" do
7
+ @ext = Minecraft::Extensions.new(StringIO.new, {})
8
+ result = "\033[0;37m2011-08-21 13:45:13\033[0m [INFO] Starting minecraft server version Beta 1.7.3"
9
+ assert_equal result, @ext.colour("2011-08-21 13:45:13 [INFO] Starting minecraft server version Beta 1.7.3")
10
+
11
+ result = "\033[0;37m2011-08-21 13:45:28\033[0m [INFO] <\033[1;34mbasicxman\033[0m> \033[1;33m!list\033[0m"
12
+ assert_equal result, @ext.colour("2011-08-21 13:45:28 [INFO] <basicxman> !list")
13
+
14
+ result = "\033[0;37m2011-08-21 13:45:35\033[0m [INFO] <\033[1;34mbasicxman\033[0m> \033[1;33m!hop basicxman\033[0m"
15
+ assert_equal result, @ext.colour("2011-08-21 13:45:35 [INFO] <basicxman> !hop basicxman")
16
+
17
+ result = "\033[0;37m2011-08-21 14:03:10\033[0m [INFO] \033[1;30mbasicxman lost connection: disconnect.quitting\033[0m"
18
+ assert_equal result, @ext.colour("2011-08-21 14:03:10 [INFO] basicxman lost connection: disconnect.quitting")
19
+
20
+ result = "\033[0;37m2011-08-21 13:53:09\033[0m [INFO] \033[1;36mCONSOLE:\033[0m Forcing save.."
21
+ assert_equal result, @ext.colour("2011-08-21 13:53:09 [INFO] CONSOLE: Forcing save..")
22
+ end
23
+
5
24
  # call_comamnd testing.
6
25
  sandbox_test "should call a command for a regular user" do
7
26
  @ext = Minecraft::Extensions.new(StringIO.new, {})
@@ -61,4 +80,33 @@ class ExtensionsTest < Test
61
80
  @ext.call_command("basicxman", "morning")
62
81
  refute_match "not a", @ext.server.string
63
82
  end
83
+
84
+ sandbox_test "should remove excess arguments" do
85
+ @ext = Minecraft::Extensions.new(StringIO.new, {})
86
+ @ext.call_command("basicxman", "help", "foo", "bar")
87
+ refute_empty @ext.server.string
88
+
89
+ @ext.call_command("basicxman", "day", "foo")
90
+ refute_empty @ext.server.string
91
+ end
92
+
93
+ # Command valiation testing.
94
+ sandbox_test "should print an arguments error if not enough arguments are given" do
95
+ ts, $stderr = $stderr, StringIO.new
96
+ @ext = Minecraft::Extensions.new(StringIO.new, {})
97
+ @ext.ops = ["basicxman"]
98
+ @ext.call_command("basicxman", "give")
99
+ assert_match "at least one argument", @ext.server.string
100
+ @ext.server.string = ""
101
+
102
+ @ext.call_command("basicxman", "kit")
103
+ assert_match "Expected", @ext.server.string
104
+ assert_match "group", @ext.server.string
105
+ @ext.server.string = ""
106
+
107
+ @ext.call_command("basicxman", "hop")
108
+ assert_match "Expected", @ext.server.string
109
+ assert_match "target user", @ext.server.string
110
+ $stderr = ts
111
+ end
64
112
  end
@@ -10,15 +10,18 @@ require "turn"
10
10
 
11
11
  module Minecraft
12
12
  class Extensions
13
- attr_accessor :commands, :users, :ops, :hops, :counter, :server, :kickvotes, :last_kick_vote, :uptime, :timers, :shortcuts, :userlog, :userpoints, :vote_threshold
13
+ attr_accessor :commands, :users, :ops, :hops, :counter, :server, :kickvotes, :last_kick_vote, :uptime, :timers, :shortcuts, :userlog, :userpoints, :vote_threshold, :userdnd, :welcome_message, :memos, :todo_items
14
14
  end
15
15
  end
16
16
 
17
17
  class Test < MiniTest::Unit::TestCase
18
+ # Standard test.
18
19
  def self.test(name, &block)
19
20
  define_method("test_#{name.gsub(/\W/, '_')}", block)
20
21
  end
21
22
 
23
+ # Sandbox test which creates a sandboxed environment for a mocked Minecraft
24
+ # server to run in.
22
25
  def self.sandbox_test(name, &block)
23
26
  p = Proc.new do
24
27
  FileUtils.mkdir("mc") unless File.exists? "mc"
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: minecraft
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.2.1
5
+ version: 0.3.0
6
6
  platform: ruby
7
7
  authors:
8
8
  - Andrew Horsman
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2011-08-21 00:00:00 -04:00
13
+ date: 2011-08-29 00:00:00 -04:00
14
14
  default_executable:
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency