test/packet_test.rb in ardtweeno-0.5.0 vs test/packet_test.rb in ardtweeno-0.6.0
- old
+ new
@@ -1,12 +1,29 @@
-###################################################################################################
+=begin
+####################################################################################################
# @author David Kirwan https://github.com/davidkirwan/ardtweeno
-# @description Ardtweeno::Packet test fixtures
+# @description Ardtweeno Gateway
#
-# @date 2013-08-18
+# @date 2014-08-12
####################################################################################################
+This file is part of Ardtweeno.
+
+Ardtweeno is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, either version 3 of the License, or
+any later version.
+
+Ardtweeno is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with Foobar. If not, see <http://www.gnu.org/licenses/>.
+=end
+
require 'test/unit'
require 'rack/test'
require 'ardtweeno'
require 'logger'
require 'json'
@@ -27,10 +44,11 @@
# Create a DateTime instance
today = DateTime.now
@theDate = today.year.to_s() + "-" + "%02d" % today.month.to_s() + "-" + "%02d" % today.day.to_s()
@newHour = ("%02d" % today.hour).to_s
@newMinute = ("%02d" % today.min).to_s
+ @newSecond = ("%02d" % today.sec).to_s
# Instantiate the packetArray
@packetArray = Array.new
# Create 20 packets and add to the packetList
@@ -53,19 +71,18 @@
# Test the Ardtweeno::Packet#to_s method
def test_to_s
@packetArray.each do |i|
assert_equal(
- "Packet No: #{i.seqNo} Key: 0123456789abcdef Node: defaultNode Date: #{@theDate} #{@newHour}:#{@newMinute} Data: [23.5, 997.8, 30]",
+ "Packet No: #{i.seqNo} Key: 0123456789abcdef Node: defaultNode Date: #{@theDate} #{@newHour}:#{@newMinute}:#{@newSecond} Data: [23.5, 997.8, 30]",
i.to_s
)
end
end
# Test the Ardtweeno::Packet#to_json method
def test_to_json
- str = "{\"date\":\"#{@theDate}\",\"hour\":\"#{@newHour}\",\"minute\":\"#{@newMinute
- }\",\"node\":\"defaultNode\",\"key\":\"0123456789abcdef\",\"seqNo\":0,\"data\":[23.5,997.8,30]}"
+ str = "{\"date\":\"#{@theDate}\",\"hour\":\"#{@newHour}\",\"minute\":\"#{@newMinute}\",\"second\":\"#{@newSecond}\",\"node\":\"defaultNode\",\"key\":\"0123456789abcdef\",\"seqNo\":0,\"data\":[23.5,997.8,30]}"
assert_equal(str, @packetArray.first.to_json)
# Create JSON objects and compare
json1 = JSON.parse(str)
\ No newline at end of file