Fixed most merge conflicts- possible coupling issues
commit
6f6e67054b
|
@ -13,7 +13,9 @@ class ControllerCommandProc
|
|||
'servo_move']
|
||||
|
||||
def check_whitelist(function)
|
||||
raise "UNAUTHORIZED" unless WHITELIST.include?(function.downcase)
|
||||
unless WHITELIST.include?(function.downcase)
|
||||
raise "UNAUTHORIZED: #{function}"
|
||||
end
|
||||
end
|
||||
|
||||
def process_command( cmd )
|
||||
|
@ -37,11 +39,6 @@ class ControllerCommandProc
|
|||
if $hardware_sim == 0
|
||||
send(function, command_line)
|
||||
else
|
||||
#$status.info_movement =
|
||||
@info_movement = "#{command_line.action.downcase} xyz=#{command_line.coord_x} #{command_line.coord_y} #{command_line.coord_z} amt=#{command_line.amount} spd=#{command_line.speed} pin=#{command_line.pin_nr}"
|
||||
puts "simulating: #{@info_movement}"
|
||||
#@bot_dbaccess.write_to_log(1,@info_movement)
|
||||
#@bot_dbaccess.write_to_log(1,"simulating hardware: #{function}")
|
||||
sleep 0.1
|
||||
end
|
||||
end
|
||||
|
|
|
@ -16,7 +16,7 @@ class DbAccessLogs
|
|||
def initialize(db)
|
||||
@dbaccess = db
|
||||
@log_to_screen = true
|
||||
@max_nr_log_lines = 10000
|
||||
@max_nr_log_lines = 1000
|
||||
end
|
||||
|
||||
## logs
|
||||
|
|
|
@ -7,13 +7,15 @@
|
|||
|
||||
require 'serialport'
|
||||
|
||||
require_relative 'ramps_serial_port_sim'
|
||||
require_relative 'ramps_arduino_values_received.rb'
|
||||
require_relative 'ramps_arduino_write_status.rb'
|
||||
|
||||
class HardwareInterfaceArduino
|
||||
|
||||
attr_accessor :ramps_param, :ramps_main
|
||||
attr_accessor :test_serial_read, :test_serial_write
|
||||
#attr_accessor :test_serial_read, :test_serial_write
|
||||
attr_accessor :serial_port
|
||||
attr_accessor :external_info
|
||||
|
||||
# initialize the interface
|
||||
|
@ -25,8 +27,6 @@ class HardwareInterfaceArduino
|
|||
@status_debug_msg = $status_debug_msg
|
||||
|
||||
@test_mode = test_mode
|
||||
@test_serial_read = ""
|
||||
@test_serial_write = ""
|
||||
|
||||
# connect to arduino
|
||||
connect_board()
|
||||
|
@ -53,6 +53,7 @@ class HardwareInterfaceArduino
|
|||
|
||||
comm_port = '/dev/ttyACM0'
|
||||
@serial_port = SerialPort.new(comm_port, parameters) if @test_mode == false
|
||||
@serial_port = SerialPortSim.new(comm_port, parameters) if @test_mode == true
|
||||
|
||||
end
|
||||
|
||||
|
@ -62,7 +63,10 @@ class HardwareInterfaceArduino
|
|||
begin
|
||||
|
||||
write_status = create_write_status(text, log, onscreen)
|
||||
|
||||
#puts @serial_port.test_serial_read
|
||||
prepare_serial_port(write_status)
|
||||
#puts @serial_port.test_serial_read
|
||||
|
||||
# wait until the arduino responds
|
||||
while(write_status.is_busy())
|
||||
|
@ -74,7 +78,9 @@ class HardwareInterfaceArduino
|
|||
|
||||
log_result_of_execution(write_status)
|
||||
|
||||
rescue Exception => e
|
||||
rescue => e
|
||||
#puts 'exception received'
|
||||
#puts e
|
||||
handle_execution_exception(e)
|
||||
end
|
||||
end
|
||||
|
@ -89,25 +95,21 @@ class HardwareInterfaceArduino
|
|||
end
|
||||
|
||||
def handle_execution_exception(e)
|
||||
if @test_mode == false
|
||||
puts("ST: serial error\n#{e.message}\n#{e.backtrace.inspect}")
|
||||
end
|
||||
puts("ST: serial error\n#{e.message}\n#{e.backtrace.inspect}")
|
||||
@bot_dbaccess.write_to_log(4,"ST: serial error\n#{e.message}\n#{e.backtrace.inspect}")
|
||||
if @test_mode == false
|
||||
@serial_port.rts = 1
|
||||
connect_board
|
||||
sleep 5
|
||||
end
|
||||
@serial_port.rts = 1
|
||||
connect_board
|
||||
sleep 5 if @test_mode == false
|
||||
end
|
||||
|
||||
def log_result_of_execution(write_status)
|
||||
|
||||
# log things if needed
|
||||
if write_status.done == 1
|
||||
puts 'ST: done' if write_status.onscreen and @test_mode == false
|
||||
puts 'ST: done' if write_status.onscreen
|
||||
@bot_dbaccess.write_to_log(4, 'ST: done') if write_status.log
|
||||
else
|
||||
puts 'ST: timeout' if @test_mode == false
|
||||
puts 'ST: timeout'
|
||||
@bot_dbaccess.write_to_log(4, 'ST: timeout')
|
||||
|
||||
sleep 5 if @test_mode == false
|
||||
|
@ -117,13 +119,10 @@ class HardwareInterfaceArduino
|
|||
# receive all characters coming from the serial port
|
||||
#
|
||||
def process_feedback(write_status)
|
||||
i = @serial_port.read(1)
|
||||
|
||||
if @test_mode == false
|
||||
i = @serial_port.read(1)
|
||||
else
|
||||
i = @test_serial_read[0]
|
||||
@test_serial_read = @test_serial_read[1..-1]
|
||||
end
|
||||
#print "-#{i}"
|
||||
#print "#{i}"
|
||||
|
||||
if i != nil
|
||||
i.each_char do |c|
|
||||
|
@ -132,7 +131,8 @@ class HardwareInterfaceArduino
|
|||
|
||||
end
|
||||
else
|
||||
sleep 0.001
|
||||
sleep 0.001 if @test_mode == false
|
||||
#write_status.done = 1 if @test_mode == true
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -190,7 +190,7 @@ class HardwareInterfaceArduino
|
|||
def prepare_serial_port(write_status)
|
||||
puts "WR: #{write_status.text}" if write_status.onscreen
|
||||
@bot_dbaccess.write_to_log(4, "WR: #{write_status.text}") if write_status.log
|
||||
@serial_port.read_timeout = 2 if @test_mode == false
|
||||
@serial_port.read_timeout = 2
|
||||
clean_serial_buffer() if @test_mode == false
|
||||
serial_port_write( "#{write_status.text}\n" )
|
||||
end
|
||||
|
@ -198,21 +198,13 @@ class HardwareInterfaceArduino
|
|||
# empty the input buffer so no old data is processed
|
||||
#
|
||||
def clean_serial_buffer
|
||||
if @test_mode == false
|
||||
while (@serial_port.read(1) != nil)
|
||||
end
|
||||
else
|
||||
@test_serial_read = ''
|
||||
while (@serial_port.read(1) != nil)
|
||||
end
|
||||
end
|
||||
|
||||
# write something to the serial port
|
||||
def serial_port_write(text)
|
||||
if @test_mode == false
|
||||
@serial_port.write( text )
|
||||
else
|
||||
@test_serial_write = text
|
||||
end
|
||||
@serial_port.write( text )
|
||||
end
|
||||
|
||||
# if there is an emergency stop, immediately write it to the arduino
|
||||
|
@ -358,7 +350,7 @@ class HardwareInterfaceArduino
|
|||
#
|
||||
def process_value_process_R99(code,text)
|
||||
if code == 'R99'
|
||||
puts ">#{text}<" if @test_mode == false
|
||||
puts ">#{text}<"
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -191,6 +191,7 @@ class HardwareInterfaceParam
|
|||
def update_param_version_ar
|
||||
# read the parameter version in the database and in the device
|
||||
read_parameter_from_device(0)
|
||||
|
||||
params.each do |p|
|
||||
if p['id'] == 0
|
||||
@param_version_ar = p['value_ar']
|
||||
|
|
|
@ -0,0 +1,33 @@
|
|||
## SERIAL PORT SIMULATION
|
||||
## **********************
|
||||
|
||||
# Used for unit tests
|
||||
|
||||
|
||||
class SerialPortSim
|
||||
|
||||
attr_accessor :rts
|
||||
attr_accessor :read_timeout
|
||||
attr_accessor :test_serial_read, :test_serial_write
|
||||
|
||||
def initialize(comm_port, parameters)
|
||||
@test_serial_read = ""
|
||||
@test_serial_write = ""
|
||||
end
|
||||
|
||||
def write(text)
|
||||
@test_serial_write = text
|
||||
end
|
||||
|
||||
def read(characters)
|
||||
i = nil
|
||||
@test_serial_read = nil if @test_serial_read == ""
|
||||
|
||||
if @test_serial_read != nil
|
||||
i = @test_serial_read[0]
|
||||
@test_serial_read = @test_serial_read[1..-1]
|
||||
end
|
||||
i
|
||||
end
|
||||
|
||||
end
|
|
@ -59,12 +59,12 @@ class MessageHandler
|
|||
message_obj = MessageHandlerMessage.new
|
||||
|
||||
split_message(message, message_obj)
|
||||
|
||||
log_message_obj_info(message_obj)
|
||||
send_message_obj_to_individual_handlers(message_obj)
|
||||
check_if_message_handled(message_obj)
|
||||
|
||||
rescue Exception => e
|
||||
puts e.message, e.backtrace.first
|
||||
rescue => e
|
||||
err_snd = true
|
||||
err_msg = e.message
|
||||
err_trc = e.backtrace.inspect
|
||||
|
@ -73,8 +73,7 @@ class MessageHandler
|
|||
# in case of an error, send error message as a reply
|
||||
begin
|
||||
handle_message_error(err_snd, sender, time_stamp, err_msg, err_trc)
|
||||
rescue Exception => e
|
||||
puts e.message, e.backtrace.first
|
||||
rescue => e
|
||||
puts "Error while sending error message: #{e.message}"
|
||||
end
|
||||
end
|
||||
|
|
|
@ -42,7 +42,7 @@ class MessageHandler
|
|||
sender = ""
|
||||
time_stamp = nil
|
||||
|
||||
puts "received at #{Time.now.strftime("%Y-%m-%d %H:%M:%S")}: #{message}" if $messages_print == 1
|
||||
puts "received at #{Time.now.strftime("%Y-%m-%d %H:%M:%S")}: #{message}" if $mesh_msg_print == 1
|
||||
|
||||
err_msg = ""
|
||||
err_trc = ""
|
||||
|
@ -58,6 +58,7 @@ class MessageHandler
|
|||
message_obj = MessageHandlerMessage.new
|
||||
|
||||
split_message(message, message_obj)
|
||||
|
||||
log_message_obj_info(message_obj)
|
||||
send_message_obj_to_individual_handlers(message_obj)
|
||||
check_if_message_handled(message_obj)
|
||||
|
@ -152,7 +153,7 @@ class MessageHandler
|
|||
def check_if_message_handled(message_obj)
|
||||
if message_obj.handled == false
|
||||
@dbaccess.write_to_log(2,'message could not be handled')
|
||||
send_error(sender, '', 'message could not be handled')
|
||||
send_error(message_obj.sender, '', 'message could not be handled')
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -2,6 +2,7 @@ require 'json'
|
|||
|
||||
require_relative 'credentials'
|
||||
require_relative 'web_socket'
|
||||
|
||||
require_relative 'messagehandler.rb'
|
||||
|
||||
#require '/home/pi/ruby-socket.io-client-simple/lib/socket.io-client-simple.rb'
|
||||
|
|
|
@ -19,7 +19,7 @@ class MessagingTest
|
|||
|
||||
def send_message(devices, message_hash )
|
||||
@message = message_hash
|
||||
@devices = devices
|
||||
@device = devices
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -20,7 +20,6 @@ class MessagingTest
|
|||
def send_message(devices, message_hash )
|
||||
@message = message_hash
|
||||
@devices = devices
|
||||
@socket.emit("message",{:devices => devices, :message => message_hash})
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -38,13 +38,15 @@ describe ControllerCommandProc do
|
|||
command_line.coord_y = y
|
||||
command_line.coord_z = z
|
||||
|
||||
@ramps.ramps_arduino.serial_port.test_serial_read = "R01\nR02\n"
|
||||
|
||||
@controller.move_absolute(command_line)
|
||||
|
||||
part_x = "X#{x * @ramps.ramps_param.axis_x_steps_per_unit}"
|
||||
part_y = "Y#{y * @ramps.ramps_param.axis_y_steps_per_unit}"
|
||||
part_z = "Z#{z * @ramps.ramps_param.axis_z_steps_per_unit}"
|
||||
|
||||
expect(@ramps.ramps_arduino.test_serial_write).to eq("G00 #{part_x} #{part_y} #{part_z}\n")
|
||||
expect(@ramps.ramps_arduino.serial_port.test_serial_write).to eq("G00 #{part_x} #{part_y} #{part_z}\n")
|
||||
end
|
||||
|
||||
# def move_relative(command_line)
|
||||
|
@ -68,45 +70,51 @@ describe ControllerCommandProc do
|
|||
command_line.coord_y = y
|
||||
command_line.coord_z = z
|
||||
|
||||
@ramps.ramps_arduino.serial_port.test_serial_read = "R01\nR02\n"
|
||||
|
||||
@controller.move_relative(command_line)
|
||||
|
||||
part_x = "X#{x * @ramps.ramps_param.axis_x_steps_per_unit + current_x}"
|
||||
part_y = "Y#{y * @ramps.ramps_param.axis_y_steps_per_unit + current_y}"
|
||||
part_z = "Z#{z * @ramps.ramps_param.axis_z_steps_per_unit + current_z}"
|
||||
|
||||
expect(@ramps.ramps_arduino.test_serial_write).to eq("G00 #{part_x} #{part_y} #{part_z}\n")
|
||||
expect(@ramps.ramps_arduino.serial_port.test_serial_write).to eq("G00 #{part_x} #{part_y} #{part_z}\n")
|
||||
end
|
||||
|
||||
# def home_x(command_line)
|
||||
|
||||
it "home x" do
|
||||
|
||||
@ramps.ramps_arduino.serial_port.test_serial_read = "R01\nR02\n"
|
||||
|
||||
command_line = CommandLine.new
|
||||
@controller.home_x(command_line)
|
||||
|
||||
expect(@ramps.ramps_arduino.test_serial_write).to eq("F11\n")
|
||||
|
||||
expect(@ramps.ramps_arduino.serial_port.test_serial_write).to eq("F11\n")
|
||||
end
|
||||
|
||||
# def home_y(command_line)
|
||||
|
||||
it "home y" do
|
||||
|
||||
@ramps.ramps_arduino.serial_port.test_serial_read = "R01\nR02\n"
|
||||
|
||||
command_line = CommandLine.new
|
||||
@controller.home_y(command_line)
|
||||
|
||||
expect(@ramps.ramps_arduino.test_serial_write).to eq("F12\n")
|
||||
|
||||
expect(@ramps.ramps_arduino.serial_port.test_serial_write).to eq("F12\n")
|
||||
end
|
||||
|
||||
# def home_z(command_line)
|
||||
|
||||
it "home z" do
|
||||
|
||||
@ramps.ramps_arduino.serial_port.test_serial_read = "R01\nR02\n"
|
||||
|
||||
command_line = CommandLine.new
|
||||
@controller.home_z(command_line)
|
||||
|
||||
expect(@ramps.ramps_arduino.test_serial_write).to eq("F13\n")
|
||||
expect(@ramps.ramps_arduino.serial_port.test_serial_write).to eq("F13\n")
|
||||
|
||||
end
|
||||
|
||||
|
@ -114,10 +122,12 @@ describe ControllerCommandProc do
|
|||
|
||||
it "calibrate x" do
|
||||
|
||||
@ramps.ramps_arduino.serial_port.test_serial_read = "R01\nR02\n"
|
||||
|
||||
command_line = CommandLine.new
|
||||
@controller.calibration_x(command_line)
|
||||
|
||||
expect(@ramps.ramps_arduino.test_serial_write).to eq("F14\n")
|
||||
expect(@ramps.ramps_arduino.serial_port.test_serial_write).to eq("F14\n")
|
||||
|
||||
end
|
||||
|
||||
|
@ -125,10 +135,12 @@ describe ControllerCommandProc do
|
|||
|
||||
it "calibrate y" do
|
||||
|
||||
@ramps.ramps_arduino.serial_port.test_serial_read = "R01\nR02\n"
|
||||
|
||||
command_line = CommandLine.new
|
||||
@controller.calibration_y(command_line)
|
||||
|
||||
expect(@ramps.ramps_arduino.test_serial_write).to eq("F15\n")
|
||||
expect(@ramps.ramps_arduino.serial_port.test_serial_write).to eq("F15\n")
|
||||
|
||||
end
|
||||
|
||||
|
@ -136,10 +148,12 @@ describe ControllerCommandProc do
|
|||
|
||||
it "calibrate z" do
|
||||
|
||||
@ramps.ramps_arduino.serial_port.test_serial_read = "R01\nR02\n"
|
||||
|
||||
command_line = CommandLine.new
|
||||
@controller.calibration_z(command_line)
|
||||
|
||||
expect(@ramps.ramps_arduino.test_serial_write).to eq("F16\n")
|
||||
expect(@ramps.ramps_arduino.serial_port.test_serial_write).to eq("F16\n")
|
||||
|
||||
end
|
||||
|
||||
|
@ -149,11 +163,13 @@ describe ControllerCommandProc do
|
|||
|
||||
amount = rand(9999999).to_i
|
||||
|
||||
@ramps.ramps_arduino.serial_port.test_serial_read = "R01\nR02\n"
|
||||
|
||||
command_line = CommandLine.new
|
||||
command_line.amount = amount
|
||||
@controller.dose_water(command_line)
|
||||
|
||||
expect(@ramps.ramps_arduino.test_serial_write).to eq("F01 Q#{amount}\n")
|
||||
expect(@ramps.ramps_arduino.serial_port.test_serial_write).to eq("F01 Q#{amount}\n")
|
||||
|
||||
end
|
||||
|
||||
|
@ -170,9 +186,11 @@ describe ControllerCommandProc do
|
|||
command_line.pin_value_1 = value
|
||||
command_line.pin_mode = mode
|
||||
|
||||
@ramps.ramps_arduino.serial_port.test_serial_read = "R01\nR02\n"
|
||||
|
||||
@controller.pin_write(command_line)
|
||||
|
||||
expect(@ramps.ramps_arduino.test_serial_write).to eq("F41 P#{pin} V#{value} M#{mode}\n")
|
||||
expect(@ramps.ramps_arduino.serial_port.test_serial_write).to eq("F41 P#{pin} V#{value} M#{mode}\n")
|
||||
end
|
||||
|
||||
# def pin_read(command_line)
|
||||
|
@ -190,9 +208,11 @@ describe ControllerCommandProc do
|
|||
command_line.pin_mode = mode
|
||||
command_line.external_info = ext_info
|
||||
|
||||
@ramps.ramps_arduino.serial_port.test_serial_read = "R01\nR02\n"
|
||||
|
||||
@controller.pin_read(command_line)
|
||||
|
||||
expect(@ramps.ramps_arduino.test_serial_write).to eq("F42 P#{pin} M#{mode}\n")
|
||||
expect(@ramps.ramps_arduino.serial_port.test_serial_write).to eq("F42 P#{pin} M#{mode}\n")
|
||||
end
|
||||
|
||||
# def pin_mode(command_line)
|
||||
|
@ -206,9 +226,11 @@ describe ControllerCommandProc do
|
|||
command_line.pin_nr = pin
|
||||
command_line.pin_mode = mode
|
||||
|
||||
@ramps.ramps_arduino.serial_port.test_serial_read = "R01\nR02\n"
|
||||
|
||||
@controller.pin_mode(command_line)
|
||||
|
||||
expect(@ramps.ramps_arduino.test_serial_write).to eq("F43 P#{pin} M#{mode}\n")
|
||||
expect(@ramps.ramps_arduino.serial_port.test_serial_write).to eq("F43 P#{pin} M#{mode}\n")
|
||||
end
|
||||
|
||||
|
||||
|
@ -229,9 +251,11 @@ describe ControllerCommandProc do
|
|||
command_line.pin_value_2 = value_2
|
||||
command_line.pin_time = time
|
||||
|
||||
@ramps.ramps_arduino.serial_port.test_serial_read = "R01\nR02\n"
|
||||
|
||||
@controller.pin_pulse(command_line)
|
||||
|
||||
expect(@ramps.ramps_arduino.test_serial_write).to eq("F44 P#{pin} V#{value_1} W#{value_2} T#{time} M#{mode}\n")
|
||||
expect(@ramps.ramps_arduino.serial_port.test_serial_write).to eq("F44 P#{pin} V#{value_1} W#{value_2} T#{time} M#{mode}\n")
|
||||
end
|
||||
|
||||
# def servo_move(command_line)
|
||||
|
@ -241,12 +265,14 @@ describe ControllerCommandProc do
|
|||
pin = rand(9999999).to_i
|
||||
value = rand(9999999).to_i
|
||||
|
||||
@ramps.ramps_arduino.serial_port.test_serial_read = "R01\nR02\n"
|
||||
|
||||
command_line = CommandLine.new
|
||||
command_line.pin_nr = pin
|
||||
command_line.pin_value_1 = value
|
||||
@controller.servo_move(command_line)
|
||||
|
||||
expect(@ramps.ramps_arduino.test_serial_write).to eq("F61 P#{pin} V#{value}\n")
|
||||
expect(@ramps.ramps_arduino.serial_port.test_serial_write).to eq("F61 P#{pin} V#{value}\n")
|
||||
end
|
||||
|
||||
# def send_command(command_line)
|
||||
|
@ -256,19 +282,21 @@ describe ControllerCommandProc do
|
|||
pin = rand(9999999).to_i
|
||||
value = rand(9999999).to_i
|
||||
|
||||
@ramps.ramps_arduino.serial_port.test_serial_read = "R01\nR02\n"
|
||||
|
||||
command_line = CommandLine.new
|
||||
command_line.action = 'SERVO MOVE'
|
||||
command_line.pin_nr = pin
|
||||
command_line.pin_value_1 = value
|
||||
@controller.send_command(command_line)
|
||||
|
||||
expect(@ramps.ramps_arduino.test_serial_write).to eq("F61 P#{pin} V#{value}\n")
|
||||
expect(@ramps.ramps_arduino.serial_port.test_serial_write).to eq("F61 P#{pin} V#{value}\n")
|
||||
|
||||
$hardware_sim = 1
|
||||
|
||||
@ramps.ramps_arduino.test_serial_write = ""
|
||||
@ramps.ramps_arduino.serial_port.test_serial_write = ""
|
||||
@controller.send_command(command_line)
|
||||
expect(@ramps.ramps_arduino.test_serial_write).to eq("")
|
||||
expect(@ramps.ramps_arduino.serial_port.test_serial_write).to eq("")
|
||||
|
||||
$hardware_sim = 0
|
||||
end
|
||||
|
@ -288,9 +316,11 @@ describe ControllerCommandProc do
|
|||
cmd = Command.new
|
||||
cmd.command_lines << command_line
|
||||
|
||||
@ramps.ramps_arduino.serial_port.test_serial_read = "R01\nR02\n"
|
||||
|
||||
@controller.process_command( cmd )
|
||||
|
||||
expect(@ramps.ramps_arduino.test_serial_write).to eq("F61 P#{pin} V#{value}\n")
|
||||
expect(@ramps.ramps_arduino.serial_port.test_serial_write).to eq("F61 P#{pin} V#{value}\n")
|
||||
end
|
||||
|
||||
# def process_command( cmd )
|
||||
|
|
|
@ -30,10 +30,23 @@ describe HardwareInterfaceArduino do
|
|||
|
||||
command = "TEST"
|
||||
|
||||
@ramps.test_serial_read = "R01\nR02\n"
|
||||
@ramps.serial_port.test_serial_read = "R01\nR02\n"
|
||||
@ramps.execute_command(command, false, false)
|
||||
|
||||
expect(@ramps.test_serial_write).to eq("#{command}\n")
|
||||
expect(@ramps.serial_port.test_serial_write).to eq("#{command}\n")
|
||||
|
||||
end
|
||||
|
||||
it "execute_command with causing an error" do
|
||||
|
||||
$status = nil
|
||||
|
||||
@ramps.serial_port.rts = 0
|
||||
@ramps.execute_command(nil,nil,nil)
|
||||
|
||||
$status = Status.new
|
||||
|
||||
expect { @ramps }.to_not raise_error
|
||||
|
||||
end
|
||||
|
||||
|
@ -48,7 +61,6 @@ describe HardwareInterfaceArduino do
|
|||
expect(write_status.text ).to eq(text )
|
||||
expect(write_status.log ).to eq(log )
|
||||
expect(write_status.onscreen ).to eq(onscreen )
|
||||
|
||||
end
|
||||
|
||||
it "handle execution exception" do
|
||||
|
@ -76,7 +88,7 @@ describe HardwareInterfaceArduino do
|
|||
log = rand(9999999).to_s
|
||||
onscreen = false
|
||||
|
||||
@ramps.test_serial_read = "R02\n"
|
||||
@ramps.serial_port.test_serial_read = "R02\n"
|
||||
|
||||
write_status = @ramps.create_write_status(text, log, onscreen)
|
||||
|
||||
|
@ -200,30 +212,30 @@ describe HardwareInterfaceArduino do
|
|||
end
|
||||
|
||||
it "clean serial buffer" do
|
||||
@ramps.test_serial_read = rand(9999999).to_s
|
||||
@ramps.serial_port.test_serial_read = rand(9999999).to_s
|
||||
@ramps.clean_serial_buffer
|
||||
expect(@ramps.test_serial_read).to eq("")
|
||||
expect(@ramps.serial_port.test_serial_read).to eq(nil)
|
||||
|
||||
end
|
||||
|
||||
it "serial port write" do
|
||||
text = rand(9999999).to_s
|
||||
@ramps.serial_port_write(text)
|
||||
expect(@ramps.test_serial_write).to eq(text)
|
||||
expect(@ramps.serial_port.test_serial_write).to eq(text)
|
||||
end
|
||||
|
||||
it "emergency stop off" do
|
||||
@ramps.test_serial_write = ""
|
||||
@ramps.serial_port.test_serial_write = ""
|
||||
$status.emergency_stop = false
|
||||
@ramps.check_emergency_stop
|
||||
expect(@ramps.test_serial_write).to eq("")
|
||||
expect(@ramps.serial_port.test_serial_write).to eq("")
|
||||
end
|
||||
|
||||
it "emergency stop on" do
|
||||
@ramps.test_serial_write = ""
|
||||
@ramps.serial_port.test_serial_write = ""
|
||||
$status.emergency_stop = true
|
||||
@ramps.check_emergency_stop
|
||||
expect(@ramps.test_serial_write).to eq("E\n")
|
||||
expect(@ramps.serial_port.test_serial_write).to eq("E\n")
|
||||
end
|
||||
|
||||
it "log incoming text" do
|
||||
|
|
|
@ -238,10 +238,9 @@ describe HardwareInterfaceArduino do
|
|||
value = rand(9999999).to_i
|
||||
|
||||
@ramps.clean_serial_buffer()
|
||||
@ramps.test_serial_write = ""
|
||||
@ramps.test_serial_read = "R21 P#{id} V#{value}\n"
|
||||
@ramps.serial_port.test_serial_write = ""
|
||||
@ramps.serial_port.test_serial_read = "R01\nR21 P#{id} V#{value}\nR02\n"
|
||||
@ramps_param.read_parameter_from_device(id)
|
||||
|
||||
param = @ramps_param.get_param(id, :by_id)
|
||||
|
||||
expect(param['id']).to eq(id)
|
||||
|
@ -259,12 +258,12 @@ describe HardwareInterfaceArduino do
|
|||
@ramps_param.save_param_value(id, :by_id, :from_db, value)
|
||||
|
||||
@ramps.clean_serial_buffer()
|
||||
@ramps.test_serial_write = ""
|
||||
@ramps.test_serial_read = "R01\nR02\n"
|
||||
@ramps.serial_port.test_serial_write = ""
|
||||
@ramps.serial_port.test_serial_read = "R01\nR02\n"
|
||||
|
||||
@ramps_param.write_parameter_to_device(id, value)
|
||||
|
||||
expect(@ramps.test_serial_write).to eq("F22 P#{id} V#{value}\n")
|
||||
expect(@ramps.serial_port.test_serial_write).to eq("F22 P#{id} V#{value}\n")
|
||||
|
||||
end
|
||||
|
||||
|
@ -276,8 +275,9 @@ describe HardwareInterfaceArduino do
|
|||
value = rand(9999999).to_i
|
||||
|
||||
@ramps.clean_serial_buffer()
|
||||
@ramps.test_serial_write = ""
|
||||
@ramps.test_serial_read = "R21 P#{id} V#{value}\n"
|
||||
@ramps.serial_port.test_serial_write = ""
|
||||
@ramps.serial_port.test_serial_read = "R01\nR21 P#{id} V#{value}\nR02\n"
|
||||
|
||||
@ramps_param.update_param_version_ar()
|
||||
|
||||
expect(@ramps_param.param_version_ar).to eq(value)
|
||||
|
@ -287,8 +287,12 @@ describe HardwareInterfaceArduino do
|
|||
|
||||
it "parameters different false" do
|
||||
|
||||
@ramps.serial_port.test_serial_write = ""
|
||||
@ramps.serial_port.test_serial_read = ""
|
||||
|
||||
@ramps_param.params.each do |p|
|
||||
p['value_ar'] = p['value_db']
|
||||
@ramps.serial_port.test_serial_read = @ramps.serial_port.test_serial_read + "R02\n"
|
||||
end
|
||||
|
||||
different = @ramps_param.parameters_different()
|
||||
|
@ -301,8 +305,12 @@ describe HardwareInterfaceArduino do
|
|||
id = 11
|
||||
value = rand(9999999).to_i
|
||||
|
||||
@ramps.serial_port.test_serial_write = ""
|
||||
@ramps.serial_port.test_serial_read = ""
|
||||
|
||||
@ramps_param.params.each do |p|
|
||||
p['value_ar'] = p['value_db']
|
||||
@ramps.serial_port.test_serial_read = @ramps.serial_port.test_serial_read + "R02\n"
|
||||
end
|
||||
|
||||
@ramps_param.save_param_value(id, :by_id, :from_db, value)
|
||||
|
@ -316,7 +324,6 @@ describe HardwareInterfaceArduino do
|
|||
|
||||
it "check and write one parameter, test with similar" do
|
||||
|
||||
|
||||
name = 'TESTING'
|
||||
id = 1
|
||||
value = rand(9999999).to_i
|
||||
|
@ -325,8 +332,9 @@ describe HardwareInterfaceArduino do
|
|||
DbAccess.current.write_parameter(name,value)
|
||||
|
||||
param = @ramps_param.get_param(id, :by_id)
|
||||
@ramps.test_serial_write = ""
|
||||
@ramps.test_serial_read = "R21 P#{id} V#{value}\n"
|
||||
|
||||
@ramps.serial_port.test_serial_write = ""
|
||||
@ramps.serial_port.test_serial_read = "R01\nR21 P#{id} V#{value}\nR02\nR02\n"
|
||||
|
||||
differences_found = @ramps_param.check_and_write_parameter(param)
|
||||
|
||||
|
@ -335,7 +343,6 @@ describe HardwareInterfaceArduino do
|
|||
|
||||
it "check and write one parameter, test with different" do
|
||||
|
||||
|
||||
name = 'TESTING'
|
||||
id = 1
|
||||
value = rand(9999999).to_i
|
||||
|
@ -344,15 +351,16 @@ describe HardwareInterfaceArduino do
|
|||
DbAccess.current.write_parameter(name,value)
|
||||
|
||||
param = @ramps_param.get_param(id, :by_id)
|
||||
@ramps.test_serial_write = ""
|
||||
@ramps.test_serial_read = "R21 P#{id} V#{value2}\n"
|
||||
@ramps.serial_port.test_serial_write = ""
|
||||
@ramps.serial_port.test_serial_read = "R01\nR21 P#{id} V#{value2}\nR02\nR02\n"
|
||||
|
||||
differences_found = @ramps_param.check_and_write_parameter(param)
|
||||
|
||||
expect(differences_found).to eq(true)
|
||||
expect(@ramps.test_serial_write).to eq("F22 P#{id} V#{value}\n")
|
||||
expect(@ramps.serial_port.test_serial_write).to eq("F22 P#{id} V#{value}\n")
|
||||
end
|
||||
|
||||
|
||||
# def compare_and_write_parameters
|
||||
|
||||
it "compare and write paramters, different" do
|
||||
|
@ -366,6 +374,9 @@ describe HardwareInterfaceArduino do
|
|||
value3 = rand(9999999).to_i
|
||||
value4 = rand(9999999).to_i
|
||||
|
||||
@ramps.serial_port.test_serial_write = ""
|
||||
@ramps.serial_port.test_serial_read = ""
|
||||
|
||||
DbAccess.current.write_parameter(name,value0)
|
||||
|
||||
@ramps_param.param_version_db = value3
|
||||
|
@ -383,12 +394,21 @@ describe HardwareInterfaceArduino do
|
|||
end
|
||||
|
||||
#@ramps_param.save_param_value(id, :by_id, :from_db, value)
|
||||
@ramps.test_serial_write = ""
|
||||
@ramps.test_serial_read = ""
|
||||
@ramps.serial_port.test_serial_write = ""
|
||||
@ramps.serial_port.test_serial_read = ""
|
||||
|
||||
feedback = ""
|
||||
@ramps_param.params.each do |p|
|
||||
if p['id'] != 0
|
||||
feedback = feedback + "R01\nR02\n"
|
||||
end
|
||||
end
|
||||
feedback = feedback + "R01\nR02\n"
|
||||
@ramps.serial_port.test_serial_read = feedback
|
||||
|
||||
@ramps_param.compare_and_write_parameters()
|
||||
|
||||
expect(@ramps.test_serial_write).to eq("F22 P#{id} V#{value0}\n")
|
||||
expect(@ramps.serial_port.test_serial_write).to eq("F22 P#{id} V#{value0}\n")
|
||||
expect(@ramps_param.params_in_sync).to eq(false)
|
||||
end
|
||||
|
||||
|
@ -399,15 +419,23 @@ describe HardwareInterfaceArduino do
|
|||
|
||||
value = rand(9999999).to_i
|
||||
|
||||
@ramps.serial_port.test_serial_write = ""
|
||||
@ramps.serial_port.test_serial_read = ""
|
||||
|
||||
@ramps_param.param_version_db = value
|
||||
@ramps_param.param_version_ar = value
|
||||
|
||||
@ramps.test_serial_write = ""
|
||||
@ramps.test_serial_read = ""
|
||||
feedback = ""
|
||||
@ramps_param.params.each do |p|
|
||||
if p['id'] != 0
|
||||
feedback = feedback + "R01\nR02\n"
|
||||
end
|
||||
end
|
||||
@ramps.serial_port.test_serial_read = feedback
|
||||
|
||||
@ramps_param.compare_and_write_parameters()
|
||||
|
||||
expect(@ramps.test_serial_write).to eq("")
|
||||
expect(@ramps.serial_port.test_serial_write).to eq("")
|
||||
expect(@ramps_param.params_in_sync).to eq(true)
|
||||
end
|
||||
|
||||
|
@ -418,6 +446,9 @@ describe HardwareInterfaceArduino do
|
|||
|
||||
value = rand(9999999).to_i
|
||||
|
||||
@ramps.serial_port.test_serial_write = ""
|
||||
@ramps.serial_port.test_serial_read = ""
|
||||
|
||||
@ramps_param.params.each do |p|
|
||||
p['value_ar'] = p['value_db']
|
||||
end
|
||||
|
@ -427,12 +458,19 @@ describe HardwareInterfaceArduino do
|
|||
|
||||
DbAccess.current.write_parameter('PARAM_VERSION',@ramps_param.param_version_db)
|
||||
|
||||
@ramps.test_serial_write = ""
|
||||
@ramps.test_serial_read = ""
|
||||
feedback = ""
|
||||
@ramps_param.params.each do |p|
|
||||
if p['id'] != 0
|
||||
feedback = feedback + "R01\nR02\n"
|
||||
end
|
||||
end
|
||||
feedback = feedback + "R01\nR02\n"
|
||||
@ramps.serial_port.test_serial_read = feedback
|
||||
@ramps.serial_port.test_serial_write = ""
|
||||
|
||||
@ramps_param.compare_and_write_parameters()
|
||||
|
||||
expect(@ramps.test_serial_write).to eq("F22 P0 V#{value}\n")
|
||||
expect(@ramps.serial_port.test_serial_write).to eq("F22 P0 V#{value}\n")
|
||||
expect(@ramps_param.params_in_sync).to eq(true)
|
||||
end
|
||||
|
||||
|
@ -448,8 +486,19 @@ describe HardwareInterfaceArduino do
|
|||
|
||||
DbAccess.current.write_parameter('PARAM_VERSION',db_version)
|
||||
|
||||
@ramps.test_serial_write = ""
|
||||
@ramps.test_serial_read = "R21 P0 V#{db_version}\n"
|
||||
feedback = ""
|
||||
feedback = feedback + "R01\nR21 P0 V#{db_version}\nR02\n"
|
||||
@ramps_param.params.each do |p|
|
||||
if p['id'] != 0
|
||||
feedback = feedback + "R01\nR02\n"
|
||||
end
|
||||
end
|
||||
#feedback = feedback + "R01\nR02\n"
|
||||
|
||||
@ramps.serial_port.test_serial_read = feedback
|
||||
@ramps.serial_port.test_serial_write = ""
|
||||
|
||||
#@ramps.serial_port.test_serial_read =
|
||||
|
||||
@ramps_param.check_parameters()
|
||||
|
||||
|
@ -469,11 +518,23 @@ describe HardwareInterfaceArduino do
|
|||
value1 = rand(9999999).to_i
|
||||
value2 = rand(9999999).to_i
|
||||
|
||||
@ramps.serial_port.test_serial_write = ""
|
||||
@ramps.serial_port.test_serial_read = ""
|
||||
|
||||
DbAccess.current.write_parameter(name,value0)
|
||||
DbAccess.current.write_parameter('PARAM_VERSION',db_version)
|
||||
|
||||
@ramps.test_serial_write = ""
|
||||
@ramps.test_serial_read = "R21 P0 V#{ar_version}\n"
|
||||
|
||||
feedback = ""
|
||||
feedback = feedback + "R01\nR21 P0 V#{ar_version}\nR02\n"
|
||||
@ramps_param.params.each do |p|
|
||||
if p['id'] != 0
|
||||
feedback = feedback + "R01\nR02\n"
|
||||
end
|
||||
end
|
||||
feedback = feedback + "R01\nR02\n"
|
||||
@ramps.serial_port.test_serial_write = ""
|
||||
@ramps.serial_port.test_serial_read = feedback
|
||||
|
||||
# make sure all parameters in device and database are equal
|
||||
@ramps_param.params.each do |p|
|
||||
|
@ -491,7 +552,7 @@ describe HardwareInterfaceArduino do
|
|||
@ramps_param.check_parameters()
|
||||
|
||||
expect(@ramps_param.params_in_sync).to eq(false)
|
||||
expect(@ramps.test_serial_write).to eq("F22 P#{id} V#{value0}\n")
|
||||
expect(@ramps.serial_port.test_serial_write).to eq("F22 P#{id} V#{value0}\n")
|
||||
|
||||
end
|
||||
|
||||
|
|
|
@ -23,10 +23,10 @@ describe HardwareInterface do
|
|||
pin = rand(9999999).to_i
|
||||
value = rand(9999999).to_i
|
||||
|
||||
@ramps.ramps_arduino.test_serial_read = "R01\nR02\n"
|
||||
@ramps.ramps_arduino.serial_port.test_serial_read = "R01\nR02\n"
|
||||
@ramps.servo_std_move(pin, value)
|
||||
|
||||
expect(@ramps.ramps_arduino.test_serial_write).to eq("F61 P#{pin} V#{value}\n")
|
||||
expect(@ramps.ramps_arduino.serial_port.test_serial_write).to eq("F61 P#{pin} V#{value}\n")
|
||||
end
|
||||
|
||||
# def pin_std_set_value(pin, value, mode)
|
||||
|
@ -37,10 +37,10 @@ describe HardwareInterface do
|
|||
value = rand(9999999).to_i
|
||||
mode = rand(9999999).to_i
|
||||
|
||||
@ramps.ramps_arduino.test_serial_read = "R01\nR02\n"
|
||||
@ramps.ramps_arduino.serial_port.test_serial_read = "R01\nR02\n"
|
||||
@ramps.pin_std_set_value(pin, value, mode)
|
||||
|
||||
expect(@ramps.ramps_arduino.test_serial_write).to eq("F41 P#{pin} V#{value} M#{mode}\n")
|
||||
expect(@ramps.ramps_arduino.serial_port.test_serial_write).to eq("F41 P#{pin} V#{value} M#{mode}\n")
|
||||
end
|
||||
|
||||
# def pin_std_read_value(pin, mode, external_info)
|
||||
|
@ -52,7 +52,7 @@ describe HardwareInterface do
|
|||
value = rand(9999999).to_i
|
||||
ext_info = rand(9999999).to_s
|
||||
|
||||
@ramps.ramps_arduino.test_serial_read = "R01\nR41 P#{pin} V#{value}\nR02\n"
|
||||
@ramps.ramps_arduino.serial_port.test_serial_read = "R01\nR41 P#{pin} V#{value}\nR02\n"
|
||||
@ramps.pin_std_read_value(pin, mode, ext_info)
|
||||
|
||||
pin_value = 0
|
||||
|
@ -65,7 +65,7 @@ describe HardwareInterface do
|
|||
end
|
||||
|
||||
expect(pin_value.to_i).to eq(value.to_i)
|
||||
expect(@ramps.ramps_arduino.test_serial_write).to eq("F42 P#{pin} M#{mode}\n")
|
||||
expect(@ramps.ramps_arduino.serial_port.test_serial_write).to eq("F42 P#{pin} M#{mode}\n")
|
||||
end
|
||||
|
||||
# def pin_std_set_mode(pin, mode)
|
||||
|
@ -75,10 +75,10 @@ describe HardwareInterface do
|
|||
pin = rand(9999999).to_i
|
||||
mode = rand(9999999).to_i
|
||||
|
||||
@ramps.ramps_arduino.test_serial_read = "R01\nR02\n"
|
||||
@ramps.ramps_arduino.serial_port.test_serial_read = "R01\nR02\n"
|
||||
@ramps.pin_std_set_mode(pin, mode)
|
||||
|
||||
expect(@ramps.ramps_arduino.test_serial_write).to eq("F43 P#{pin} M#{mode}\n")
|
||||
expect(@ramps.ramps_arduino.serial_port.test_serial_write).to eq("F43 P#{pin} M#{mode}\n")
|
||||
|
||||
end
|
||||
|
||||
|
@ -92,10 +92,10 @@ describe HardwareInterface do
|
|||
time = rand(9999999).to_i
|
||||
mode = rand(9999999).to_i
|
||||
|
||||
@ramps.ramps_arduino.test_serial_read = "R01\nR02\n"
|
||||
@ramps.ramps_arduino.serial_port.test_serial_read = "R01\nR02\n"
|
||||
@ramps.pin_std_pulse(pin, value1, value2, time, mode)
|
||||
|
||||
expect(@ramps.ramps_arduino.test_serial_write).to eq("F44 P#{pin} V#{value1} W#{value2} T#{time} M#{mode}\n")
|
||||
expect(@ramps.ramps_arduino.serial_port.test_serial_write).to eq("F44 P#{pin} V#{value1} W#{value2} T#{time} M#{mode}\n")
|
||||
|
||||
end
|
||||
|
||||
|
@ -105,10 +105,10 @@ describe HardwareInterface do
|
|||
|
||||
amount = rand(9999999).to_i
|
||||
|
||||
@ramps.ramps_arduino.test_serial_read = "R01\nR02\n"
|
||||
@ramps.ramps_arduino.serial_port.test_serial_read = "R01\nR02\n"
|
||||
@ramps.dose_water(amount)
|
||||
|
||||
expect(@ramps.ramps_arduino.test_serial_write).to eq("F01 Q#{amount}\n")
|
||||
expect(@ramps.ramps_arduino.serial_port.test_serial_write).to eq("F01 Q#{amount}\n")
|
||||
|
||||
end
|
||||
|
||||
|
@ -123,10 +123,10 @@ describe HardwareInterface do
|
|||
za = (rand(2) >= 1) ? 1 : 0
|
||||
zb = (rand(2) >= 1) ? 1 : 0
|
||||
|
||||
@ramps.ramps_arduino.test_serial_read = "R01\nR81 XA#{xa} XB#{xb} YA#{ya} YB#{yb} ZA#{za} ZB#{zb}\nR02\n"
|
||||
@ramps.ramps_arduino.serial_port.test_serial_read = "R01\nR81 XA#{xa} XB#{xb} YA#{ya} YB#{yb} ZA#{za} ZB#{zb}\nR02\n"
|
||||
@ramps.read_end_stops()
|
||||
|
||||
expect(@ramps.ramps_arduino.test_serial_write).to eq("F81\n")
|
||||
expect(@ramps.ramps_arduino.serial_port.test_serial_write).to eq("F81\n")
|
||||
expect($status.info_end_stop_x_a).to eq(xa == 1)
|
||||
expect($status.info_end_stop_x_b).to eq(xb == 1)
|
||||
expect($status.info_end_stop_y_a).to eq(ya == 1)
|
||||
|
@ -144,10 +144,10 @@ describe HardwareInterface do
|
|||
z = rand(9999999).to_i
|
||||
|
||||
|
||||
@ramps.ramps_arduino.test_serial_read = "R01\nR82 X#{x} Y#{y} Z#{z}\nR02\n"
|
||||
@ramps.ramps_arduino.serial_port.test_serial_read = "R01\nR82 X#{x} Y#{y} Z#{z}\nR02\n"
|
||||
@ramps.read_postition()
|
||||
|
||||
expect(@ramps.ramps_arduino.test_serial_write).to eq("F82\n")
|
||||
expect(@ramps.ramps_arduino.serial_port.test_serial_write).to eq("F82\n")
|
||||
expect($status.info_current_x_steps).to eq(x)
|
||||
expect($status.info_current_y_steps).to eq(y)
|
||||
expect($status.info_current_z_steps).to eq(z)
|
||||
|
@ -159,10 +159,10 @@ describe HardwareInterface do
|
|||
|
||||
version = rand(9999999).to_s
|
||||
|
||||
@ramps.ramps_arduino.test_serial_read = "R01\nR83 #{version}\nR02\n"
|
||||
@ramps.ramps_arduino.serial_port.test_serial_read = "R01\nR83 #{version}\nR02\n"
|
||||
@ramps.read_device_version()
|
||||
|
||||
expect(@ramps.ramps_arduino.test_serial_write).to eq("F83\n")
|
||||
expect(@ramps.ramps_arduino.serial_port.test_serial_write).to eq("F83\n")
|
||||
expect($status.device_version).to eq(version)
|
||||
end
|
||||
|
||||
|
@ -170,10 +170,10 @@ describe HardwareInterface do
|
|||
|
||||
it "home all" do
|
||||
|
||||
@ramps.ramps_arduino.test_serial_read = "R01\nR02\n"
|
||||
@ramps.ramps_arduino.serial_port.test_serial_read = "R01\nR02\n"
|
||||
@ramps.move_home_all()
|
||||
|
||||
expect(@ramps.ramps_arduino.test_serial_write).to eq("G28\n")
|
||||
expect(@ramps.ramps_arduino.serial_port.test_serial_write).to eq("G28\n")
|
||||
|
||||
end
|
||||
|
||||
|
@ -181,10 +181,10 @@ describe HardwareInterface do
|
|||
|
||||
it "home x" do
|
||||
|
||||
@ramps.ramps_arduino.test_serial_read = "R01\nR02\n"
|
||||
@ramps.ramps_arduino.serial_port.test_serial_read = "R01\nR02\n"
|
||||
@ramps.move_home_x()
|
||||
|
||||
expect(@ramps.ramps_arduino.test_serial_write).to eq("F11\n")
|
||||
expect(@ramps.ramps_arduino.serial_port.test_serial_write).to eq("F11\n")
|
||||
|
||||
end
|
||||
|
||||
|
@ -192,10 +192,10 @@ describe HardwareInterface do
|
|||
|
||||
it "home y" do
|
||||
|
||||
@ramps.ramps_arduino.test_serial_read = "R01\nR02\n"
|
||||
@ramps.ramps_arduino.serial_port.test_serial_read = "R01\nR02\n"
|
||||
@ramps.move_home_y()
|
||||
|
||||
expect(@ramps.ramps_arduino.test_serial_write).to eq("F12\n")
|
||||
expect(@ramps.ramps_arduino.serial_port.test_serial_write).to eq("F12\n")
|
||||
|
||||
end
|
||||
|
||||
|
@ -203,10 +203,10 @@ describe HardwareInterface do
|
|||
|
||||
it "home z" do
|
||||
|
||||
@ramps.ramps_arduino.test_serial_read = "R01\nR02\n"
|
||||
@ramps.ramps_arduino.serial_port.test_serial_read = "R01\nR02\n"
|
||||
@ramps.move_home_z()
|
||||
|
||||
expect(@ramps.ramps_arduino.test_serial_write).to eq("F13\n")
|
||||
expect(@ramps.ramps_arduino.serial_port.test_serial_write).to eq("F13\n")
|
||||
|
||||
end
|
||||
|
||||
|
@ -214,10 +214,10 @@ describe HardwareInterface do
|
|||
|
||||
it "calibrate x" do
|
||||
|
||||
@ramps.ramps_arduino.test_serial_read = "R01\nR02\n"
|
||||
@ramps.ramps_arduino.serial_port.test_serial_read = "R01\nR02\n"
|
||||
@ramps.calibrate_x()
|
||||
|
||||
expect(@ramps.ramps_arduino.test_serial_write).to eq("F14\n")
|
||||
expect(@ramps.ramps_arduino.serial_port.test_serial_write).to eq("F14\n")
|
||||
|
||||
end
|
||||
|
||||
|
@ -225,10 +225,10 @@ describe HardwareInterface do
|
|||
|
||||
it "calibrate y" do
|
||||
|
||||
@ramps.ramps_arduino.test_serial_read = "R01\nR02\n"
|
||||
@ramps.ramps_arduino.serial_port.test_serial_read = "R01\nR02\n"
|
||||
@ramps.calibrate_y()
|
||||
|
||||
expect(@ramps.ramps_arduino.test_serial_write).to eq("F15\n")
|
||||
expect(@ramps.ramps_arduino.serial_port.test_serial_write).to eq("F15\n")
|
||||
|
||||
end
|
||||
|
||||
|
@ -236,10 +236,10 @@ describe HardwareInterface do
|
|||
|
||||
it "calibrate z" do
|
||||
|
||||
@ramps.ramps_arduino.test_serial_read = "R01\nR02\n"
|
||||
@ramps.ramps_arduino.serial_port.test_serial_read = "R01\nR02\n"
|
||||
@ramps.calibrate_z()
|
||||
|
||||
expect(@ramps.ramps_arduino.test_serial_write).to eq("F16\n")
|
||||
expect(@ramps.ramps_arduino.serial_port.test_serial_write).to eq("F16\n")
|
||||
|
||||
end
|
||||
|
||||
|
@ -251,14 +251,14 @@ describe HardwareInterface do
|
|||
y = rand(9999999).to_i
|
||||
z = rand(9999999).to_i
|
||||
|
||||
@ramps.ramps_arduino.test_serial_read = "R01\nR02\n"
|
||||
@ramps.ramps_arduino.serial_port.test_serial_read = "R01\nR02\n"
|
||||
@ramps.move_absolute( x, y, z)
|
||||
|
||||
part_x = "X#{x * @ramps.ramps_param.axis_x_steps_per_unit}"
|
||||
part_y = "Y#{y * @ramps.ramps_param.axis_y_steps_per_unit}"
|
||||
part_z = "Z#{z * @ramps.ramps_param.axis_z_steps_per_unit}"
|
||||
|
||||
expect(@ramps.ramps_arduino.test_serial_write).to eq("G00 #{part_x} #{part_y} #{part_z}\n")
|
||||
expect(@ramps.ramps_arduino.serial_port.test_serial_write).to eq("G00 #{part_x} #{part_y} #{part_z}\n")
|
||||
end
|
||||
|
||||
|
||||
|
@ -278,14 +278,14 @@ describe HardwareInterface do
|
|||
$status.info_current_y_steps = current_y
|
||||
$status.info_current_z_steps = current_z
|
||||
|
||||
@ramps.ramps_arduino.test_serial_read = "R01\nR02\n"
|
||||
@ramps.ramps_arduino.serial_port.test_serial_read = "R01\nR02\n"
|
||||
@ramps.move_relative( x, y, z)
|
||||
|
||||
part_x = "X#{x * @ramps.ramps_param.axis_x_steps_per_unit + current_x}"
|
||||
part_y = "Y#{y * @ramps.ramps_param.axis_y_steps_per_unit + current_y}"
|
||||
part_z = "Z#{z * @ramps.ramps_param.axis_z_steps_per_unit + current_z}"
|
||||
|
||||
expect(@ramps.ramps_arduino.test_serial_write).to eq("G00 #{part_x} #{part_y} #{part_z}\n")
|
||||
expect(@ramps.ramps_arduino.serial_port.test_serial_write).to eq("G00 #{part_x} #{part_y} #{part_z}\n")
|
||||
end
|
||||
|
||||
# def move_steps(steps_x, steps_y, steps_z)
|
||||
|
@ -296,14 +296,14 @@ describe HardwareInterface do
|
|||
y = rand(9999999).to_i
|
||||
z = rand(9999999).to_i
|
||||
|
||||
@ramps.ramps_arduino.test_serial_read = "R01\nR02\n"
|
||||
@ramps.ramps_arduino.serial_port.test_serial_read = "R01\nR02\n"
|
||||
@ramps.move_steps( x, y, z)
|
||||
|
||||
part_x = "X#{x}"
|
||||
part_y = "Y#{y}"
|
||||
part_z = "Z#{z}"
|
||||
|
||||
expect(@ramps.ramps_arduino.test_serial_write).to eq("G01 #{part_x} #{part_y} #{part_z}\n")
|
||||
expect(@ramps.ramps_arduino.serial_port.test_serial_write).to eq("G01 #{part_x} #{part_y} #{part_z}\n")
|
||||
end
|
||||
|
||||
# def move_to_coord(steps_x, steps_y, steps_z)
|
||||
|
@ -314,14 +314,14 @@ describe HardwareInterface do
|
|||
y = rand(9999999).to_i
|
||||
z = rand(9999999).to_i
|
||||
|
||||
@ramps.ramps_arduino.test_serial_read = "R01\nR02\n"
|
||||
@ramps.ramps_arduino.serial_port.test_serial_read = "R01\nR02\n"
|
||||
@ramps.move_to_coord( x, y, z)
|
||||
|
||||
part_x = "X#{x}"
|
||||
part_y = "Y#{y}"
|
||||
part_z = "Z#{z}"
|
||||
|
||||
expect(@ramps.ramps_arduino.test_serial_write).to eq("G00 #{part_x} #{part_y} #{part_z}\n")
|
||||
expect(@ramps.ramps_arduino.serial_port.test_serial_write).to eq("G00 #{part_x} #{part_y} #{part_z}\n")
|
||||
end
|
||||
|
||||
# def check_parameters
|
||||
|
@ -332,11 +332,11 @@ describe HardwareInterface do
|
|||
|
||||
DbAccess.current.write_parameter('PARAM_VERSION',db_version)
|
||||
|
||||
@ramps.ramps_arduino.test_serial_write = ""
|
||||
@ramps.ramps_arduino.test_serial_read = "R21 P0 V#{db_version}\n"
|
||||
@ramps.ramps_arduino.serial_port.test_serial_write = ""
|
||||
@ramps.ramps_arduino.serial_port.test_serial_read = "R21 P0 V#{db_version}\n"
|
||||
@ramps.check_parameters()
|
||||
|
||||
expect(@ramps.ramps_arduino.test_serial_write).to eq("F21 P0\n")
|
||||
expect(@ramps.ramps_arduino.serial_port.test_serial_write).to eq("F21 P0\n")
|
||||
end
|
||||
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
require 'spec_helper'
|
||||
require './lib/messaging/messaging.rb'
|
||||
#require './lib/messaging/messaging.rb'
|
||||
require './lib/messaging/messagehandler_base.rb'
|
||||
require './lib/messaging/messagehandler_message.rb'
|
||||
|
||||
describe MessageHandlerBase do
|
||||
|
|
|
@ -1,16 +1,12 @@
|
|||
require 'spec_helper'
|
||||
require './lib/messaging/messagehandler_emergencystop.rb'
|
||||
require './lib/status.rb'
|
||||
require './lib/messaging/messaging.rb'
|
||||
require './lib/messaging/messagehandler.rb'
|
||||
require './lib/messaging/messaging_test.rb'
|
||||
require './lib/messaging/messagehandler_emergencystop.rb'
|
||||
|
||||
describe MessageHandlerEmergencyStop do
|
||||
|
||||
before do
|
||||
#$db_write_sync = Mutex.new
|
||||
#DbAccess.current = DbAccess.new('development')
|
||||
#@msg = MessageHandler.new
|
||||
|
||||
$db_write_sync = Mutex.new
|
||||
DbAccess.current = DbAccess.new('development')
|
||||
DbAccess.current = DbAccess.current
|
||||
|
@ -18,8 +14,8 @@ describe MessageHandlerEmergencyStop do
|
|||
|
||||
$status = Status.new
|
||||
|
||||
Messaging.current = MessagingTest.new
|
||||
Messaging.current.reset
|
||||
@messaging = MessagingTest.new
|
||||
@messaging.reset
|
||||
|
||||
@handler = MessageHandlerEmergencyStop.new
|
||||
@main_handler = MessageHandler.new
|
||||
|
@ -40,7 +36,7 @@ describe MessageHandlerEmergencyStop do
|
|||
@handler.emergency_stop(message)
|
||||
|
||||
expect($status.emergency_stop).to eq(true)
|
||||
expect(Messaging.current.message[:message_type]).to eq('confirmation')
|
||||
expect(@messaging.message[:message_type]).to eq('confirmation')
|
||||
end
|
||||
|
||||
it "message handler emergency stop reset" do
|
||||
|
@ -51,7 +47,7 @@ describe MessageHandlerEmergencyStop do
|
|||
@handler.emergency_stop_reset(message)
|
||||
|
||||
expect($status.emergency_stop).to eq(false)
|
||||
expect(Messaging.current.message[:message_type]).to eq('confirmation')
|
||||
expect(@messaging.message[:message_type]).to eq('confirmation')
|
||||
end
|
||||
|
||||
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
require 'spec_helper'
|
||||
require './lib/status.rb'
|
||||
require './lib/messaging/messaging.rb'
|
||||
#require './lib/messaging/messaging.rb'
|
||||
require './lib/messaging/messagehandler.rb'
|
||||
require './lib/messaging/messaging_test.rb'
|
||||
require './lib/messaging/messagehandler_logs.rb'
|
||||
|
||||
|
@ -14,8 +15,8 @@ describe MessageHandlerLog do
|
|||
|
||||
$status = Status.new
|
||||
|
||||
Messaging.current = MessagingTest.new
|
||||
Messaging.current.reset
|
||||
@messaging = MessagingTest.new
|
||||
@messaging.reset
|
||||
|
||||
@handler = MessageHandlerLog.new
|
||||
@main_handler = MessageHandler.new
|
||||
|
@ -47,7 +48,7 @@ describe MessageHandlerLog do
|
|||
|
||||
@handler.read_logs(message)
|
||||
|
||||
return_list = Messaging.current.message
|
||||
return_list = @messaging.message
|
||||
|
||||
# check if the logged lines are present in the message
|
||||
|
||||
|
@ -68,7 +69,7 @@ describe MessageHandlerLog do
|
|||
|
||||
expect(found_in_list_1).to eq(true)
|
||||
expect(found_in_list_2).to eq(true)
|
||||
expect(Messaging.current.message[:message_type]).to eq('read_logs_response')
|
||||
expect(@messaging.message[:message_type]).to eq('read_logs_response')
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
require 'spec_helper'
|
||||
require './lib/status.rb'
|
||||
require './lib/messaging/messaging.rb'
|
||||
#require './lib/messaging/messaging.rb'
|
||||
require './lib/messaging/messagehandler.rb'
|
||||
require './lib/messaging/messaging_test.rb'
|
||||
require './lib/messaging/messagehandler_measurements.rb'
|
||||
|
||||
|
@ -14,8 +15,8 @@ describe MessageHandlerMeasurement do
|
|||
|
||||
$status = Status.new
|
||||
|
||||
Messaging.current = MessagingTest.new
|
||||
Messaging.current.reset
|
||||
@messaging = MessagingTest.new
|
||||
@messaging.reset
|
||||
|
||||
@handler = MessageHandlerMeasurement.new
|
||||
@main_handler = MessageHandler.new
|
||||
|
@ -44,14 +45,14 @@ describe MessageHandlerMeasurement do
|
|||
|
||||
# check if the created item is into the list to send
|
||||
found_in_list = false
|
||||
Messaging.current.message[:measurements].each do |item|
|
||||
@messaging.message[:measurements].each do |item|
|
||||
if item['value'] == measurement_value and item['ext_info'] == measurement_text
|
||||
found_in_list = true
|
||||
end
|
||||
end
|
||||
|
||||
expect(found_in_list).to eq(true)
|
||||
expect(Messaging.current.message[:message_type]).to eq('read_measurements_response')
|
||||
expect(@messaging.message[:message_type]).to eq('read_measurements_response')
|
||||
end
|
||||
|
||||
it "delete measurement" do
|
||||
|
@ -113,7 +114,7 @@ describe MessageHandlerMeasurement do
|
|||
expect(found_in_list_2).to eq(true)
|
||||
expect(found_in_list_1_after).to eq(false)
|
||||
expect(found_in_list_2_after).to eq(false)
|
||||
expect(Messaging.current.message[:message_type]).to eq('confirmation')
|
||||
expect(@messaging.message[:message_type]).to eq('confirmation')
|
||||
|
||||
end
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
require 'spec_helper'
|
||||
require './lib/status.rb'
|
||||
require './lib/messaging/messaging.rb'
|
||||
require './lib/messaging/messagehandler.rb'
|
||||
require './lib/messaging/messaging_test.rb'
|
||||
require './lib/messaging/messagehandler_parameters.rb'
|
||||
|
||||
|
@ -14,8 +14,8 @@ describe MessageHandlerParameter do
|
|||
|
||||
$status = Status.new
|
||||
|
||||
Messaging.current = MessagingTest.new
|
||||
Messaging.current.reset
|
||||
@messaging = MessagingTest.new
|
||||
@messaging.reset
|
||||
|
||||
@handler = MessageHandlerParameter.new
|
||||
@main_handler = MessageHandler.new
|
||||
|
@ -47,7 +47,7 @@ describe MessageHandlerParameter do
|
|||
|
||||
@handler.read_parameters(message)
|
||||
|
||||
return_list = Messaging.current.message
|
||||
return_list = @messaging.message
|
||||
|
||||
# check if the parameters are present in the message
|
||||
|
||||
|
@ -67,7 +67,7 @@ describe MessageHandlerParameter do
|
|||
|
||||
expect(found_in_list_1).to eq(true)
|
||||
expect(found_in_list_2).to eq(true)
|
||||
expect(Messaging.current.message[:message_type]).to eq('read_parameters_response')
|
||||
expect(@messaging.message[:message_type]).to eq('read_parameters_response')
|
||||
end
|
||||
|
||||
it "write parameters" do
|
||||
|
@ -105,7 +105,7 @@ describe MessageHandlerParameter do
|
|||
|
||||
expect(value_read_1).to eq(parameter_value_1)
|
||||
expect(value_read_2).to eq(parameter_value_2)
|
||||
expect(Messaging.current.message[:message_type]).to eq('confirmation')
|
||||
expect(@messaging.message[:message_type]).to eq('confirmation')
|
||||
|
||||
end
|
||||
|
||||
|
@ -119,7 +119,7 @@ describe MessageHandlerParameter do
|
|||
|
||||
@handler.write_parameters(message)
|
||||
|
||||
expect(Messaging.current.message[:message_type]).to eq('error')
|
||||
expect(@messaging.message[:message_type]).to eq('error')
|
||||
|
||||
end
|
||||
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
require 'spec_helper'
|
||||
require './lib/status.rb'
|
||||
require './lib/messaging/messaging.rb'
|
||||
#require './lib/messaging/messaging.rb'
|
||||
#require './lib/messagehandler_base'
|
||||
require './lib/messaging/messagehandler.rb'
|
||||
require './lib/messaging/messagehandler_schedule.rb'
|
||||
require './lib/messaging/messaging_test.rb'
|
||||
|
||||
#require './lib/messagehandler_schedule'
|
||||
|
@ -17,8 +20,8 @@ describe MessageHandlerSchedule do
|
|||
|
||||
$status = Status.new
|
||||
|
||||
Messaging.current = MessagingTest.new
|
||||
Messaging.current.reset
|
||||
@messaging = MessagingTest.new
|
||||
@messaging.reset
|
||||
|
||||
@handler = MessageHandlerSchedule.new
|
||||
@main_handler = MessageHandler.new
|
||||
|
@ -254,7 +257,7 @@ describe MessageHandlerSchedule do
|
|||
|
||||
# do the checks
|
||||
|
||||
expect(Messaging.current.message[:message_type]).to eq('error')
|
||||
expect(@messaging.message[:message_type]).to eq('error')
|
||||
|
||||
end
|
||||
|
||||
|
|
|
@ -1,29 +1,109 @@
|
|||
require 'spec_helper'
|
||||
require './lib/messaging/messaging.rb'
|
||||
require './lib/messaging/messaging_test.rb'
|
||||
require './lib/messaging/messagehandler.rb'
|
||||
require './lib/messaging/messagehandler_base.rb'
|
||||
require './lib/messaging/messagehandler_message.rb'
|
||||
|
||||
|
||||
describe MessageHandler do
|
||||
|
||||
|
||||
before do
|
||||
$db_write_sync = Mutex.new
|
||||
DbAccess.current = DbAccess.new('development')
|
||||
@msg = MessageHandler.new
|
||||
$dbaccess = DbAccess.current
|
||||
$dbaccess.disable_log_to_screen()
|
||||
|
||||
#$status = Status.new
|
||||
|
||||
$messaging = MessagingTest.new
|
||||
$messaging.reset
|
||||
|
||||
$mesh_msg_print = 1
|
||||
|
||||
@handler = MessageHandler.new
|
||||
end
|
||||
|
||||
## messaging
|
||||
it "handle message with test message" do
|
||||
|
||||
it "test" do
|
||||
expect(1).to eq(1)
|
||||
fromUuid = rand(9999999).to_s
|
||||
message_type = 'test'
|
||||
time_stamp = Time.now.to_f.to_s
|
||||
|
||||
message =
|
||||
{
|
||||
'fromUuid' => fromUuid,
|
||||
'payload' =>
|
||||
{
|
||||
'message_type' => message_type,
|
||||
'time_stamp' => time_stamp
|
||||
}
|
||||
}
|
||||
|
||||
@handler.handle_message(message)
|
||||
|
||||
expect($messaging.message[:message_type]).to eq('error')
|
||||
end
|
||||
|
||||
# it "create new command" do
|
||||
# crop_id = rand(9999999).to_i
|
||||
# scheduled_time = Time.now
|
||||
#
|
||||
# @db.create_new_command(scheduled_time, crop_id)
|
||||
#
|
||||
# cmd = Command.where("scheduled_time = ?",scheduled_time).first
|
||||
#
|
||||
# expect(cmd.crop_id).to eq(crop_id)
|
||||
# end
|
||||
it "handle message - test error handling" do
|
||||
|
||||
fromUuid = nil
|
||||
message_type = 'test'
|
||||
time_stamp = Time.now.to_f.to_s
|
||||
|
||||
message =
|
||||
{
|
||||
'fromUuid' => fromUuid,
|
||||
'payload' => nil
|
||||
}
|
||||
|
||||
@handler.handle_message(message)
|
||||
|
||||
expect($messaging.message[:message_type]).to eq('error')
|
||||
expect($messaging.device).to eq(fromUuid)
|
||||
end
|
||||
|
||||
it "return error" do
|
||||
ret = @handler.error
|
||||
expect(ret).to eq({:error => ''})
|
||||
end
|
||||
|
||||
it "send confirmation" do
|
||||
destination = rand(9999999).to_s
|
||||
time_stamp = nil
|
||||
|
||||
@handler.send_confirmation(destination, time_stamp)
|
||||
|
||||
expect($messaging.message[:message_type]).to eq('confirmation')
|
||||
expect($messaging.device).to eq(destination)
|
||||
|
||||
end
|
||||
|
||||
it "send error" do
|
||||
destination = rand(9999999).to_s
|
||||
error = rand(9999999).to_s
|
||||
time_stamp = nil
|
||||
|
||||
@handler.send_error(destination, time_stamp, error)
|
||||
|
||||
expect($messaging.message[:message_type]).to eq('error')
|
||||
expect($messaging.device).to eq(destination)
|
||||
|
||||
end
|
||||
|
||||
it "handle message error" do
|
||||
|
||||
err_snd = true
|
||||
err_msg = rand(9999999).to_s
|
||||
err_trc = rand(9999999).to_s
|
||||
sender = rand(9999999).to_s
|
||||
time_stamp = nil
|
||||
|
||||
@handler.handle_message_error(err_snd, sender, time_stamp, err_msg, err_trc)
|
||||
|
||||
expect($messaging.message[:message_type]).to eq('error')
|
||||
expect($messaging.message[:error]).to eq(" #{err_msg} @ #{err_trc}")
|
||||
expect($messaging.device).to eq(sender)
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -1,12 +1,10 @@
|
|||
require 'spec_helper'
|
||||
require './lib/status.rb'
|
||||
require './lib/messaging/messaging.rb'
|
||||
require './lib/messaging/messagehandler.rb'
|
||||
require './lib/messaging/messagehandler_base.rb'
|
||||
require './lib/messaging/messagehandler_status.rb'
|
||||
require './lib/messaging/messaging_test.rb'
|
||||
|
||||
#require './lib/messagehandler_schedule'
|
||||
#require './lib/messagehandler_schedule_cmd_line'
|
||||
#require './lib/messaging/messagehandler_logs.rb'
|
||||
|
||||
class HwStatusSim
|
||||
def read_hw_status
|
||||
end
|
||||
|
@ -24,8 +22,8 @@ describe MessageHandlerStatus do
|
|||
|
||||
$bot_control = HwStatusSim.new
|
||||
|
||||
Messaging.current = MessagingTest.new
|
||||
Messaging.current.reset
|
||||
@messaging = MessagingTest.new
|
||||
@messaging.reset
|
||||
|
||||
@handler = MessageHandlerStatus.new
|
||||
@main_handler = MessageHandler.new
|
||||
|
@ -99,7 +97,7 @@ describe MessageHandlerStatus do
|
|||
|
||||
# retrieve response message
|
||||
|
||||
return_msg = Messaging.current.message
|
||||
return_msg = @messaging.message
|
||||
|
||||
# do the checks
|
||||
|
||||
|
|
|
@ -3,87 +3,12 @@ SimpleCov.start do
|
|||
add_filter "/spec/"
|
||||
end
|
||||
|
||||
# Given that it is always loaded, you are encouraged to keep this file as
|
||||
# light-weight as possible. Requiring heavyweight dependencies from this file
|
||||
# will add to the boot time of your test suite on EVERY test run, even for an
|
||||
# individual file that may not need all of that loaded. Instead, consider making
|
||||
# a separate helper file that requires the additional dependencies and performs
|
||||
# the additional setup, and require it from the spec files that actually need it.
|
||||
#
|
||||
# The `.rspec` file also contains a few flags that are not defaults but that
|
||||
# users commonly want.
|
||||
#
|
||||
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
|
||||
RSpec.configure do |config|
|
||||
# rspec-expectations config goes here. You can use an alternate
|
||||
# assertion/expectation library such as wrong or the stdlib/minitest
|
||||
# assertions if you prefer.
|
||||
config.expect_with :rspec do |expectations|
|
||||
# This option will default to `true` in RSpec 4. It makes the `description`
|
||||
# and `failure_message` of custom matchers include text for helper methods
|
||||
# defined using `chain`, e.g.:
|
||||
# be_bigger_than(2).and_smaller_than(4).description
|
||||
# # => "be bigger than 2 and smaller than 4"
|
||||
# ...rather than:
|
||||
# # => "be bigger than 2"
|
||||
expectations.include_chain_clauses_in_custom_matcher_descriptions = true
|
||||
end
|
||||
|
||||
# rspec-mocks config goes here. You can use an alternate test double
|
||||
# library (such as bogus or mocha) by changing the `mock_with` option here.
|
||||
config.mock_with :rspec do |mocks|
|
||||
# Prevents you from mocking or stubbing a method that does not exist on
|
||||
# a real object. This is generally recommended, and will default to
|
||||
# `true` in RSpec 4.
|
||||
mocks.verify_partial_doubles = true
|
||||
end
|
||||
|
||||
# The settings below are suggested to provide a good initial experience
|
||||
# with RSpec, but feel free to customize to your heart's content.
|
||||
=begin
|
||||
# These two settings work together to allow you to limit a spec run
|
||||
# to individual examples or groups you care about by tagging them with
|
||||
# `:focus` metadata. When nothing is tagged with `:focus`, all examples
|
||||
# get run.
|
||||
config.filter_run :focus
|
||||
config.run_all_when_everything_filtered = true
|
||||
|
||||
# Limits the available syntax to the non-monkey patched syntax that is recommended.
|
||||
# For more details, see:
|
||||
# - http://myronmars.to/n/dev-blog/2012/06/rspecs-new-expectation-syntax
|
||||
# - http://teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
|
||||
# - http://myronmars.to/n/dev-blog/2014/05/notable-changes-in-rspec-3#new__config_option_to_disable_rspeccore_monkey_patching
|
||||
config.disable_monkey_patching!
|
||||
|
||||
# This setting enables warnings. It's recommended, but in some cases may
|
||||
# be too noisy due to issues in dependencies.
|
||||
config.warnings = true
|
||||
|
||||
# Many RSpec users commonly either run the entire suite or an individual
|
||||
# file, and it's useful to allow more verbose output when running an
|
||||
# individual spec file.
|
||||
if config.files_to_run.one?
|
||||
# Use the documentation formatter for detailed output,
|
||||
# unless a formatter has already been configured
|
||||
# (e.g. via a command-line flag).
|
||||
config.default_formatter = 'doc'
|
||||
end
|
||||
|
||||
# Print the 10 slowest examples and example groups at the
|
||||
# end of the spec run, to help surface which specs are running
|
||||
# particularly slow.
|
||||
config.profile_examples = 10
|
||||
|
||||
# Run specs in random order to surface order dependencies. If you find an
|
||||
# order dependency and want to debug it, you can fix the order by providing
|
||||
# the seed, which is printed after each run.
|
||||
# --seed 1234
|
||||
config.order = :random
|
||||
|
||||
# Seed global randomization in this process using the `--seed` CLI option.
|
||||
# Setting this allows you to use `--seed` to deterministically reproduce
|
||||
# test failures related to randomization by passing the same `--seed` value
|
||||
# as the one that triggered the failure.
|
||||
Kernel.srand config.seed
|
||||
=end
|
||||
end
|
||||
|
|
|
@ -0,0 +1,29 @@
|
|||
require 'spec_helper'
|
||||
require './lib/messaging/messaging.rb'
|
||||
|
||||
describe MessageHandler do
|
||||
|
||||
before do
|
||||
$db_write_sync = Mutex.new
|
||||
$dbaccess = DbAccess.new('development')
|
||||
@msg = MessageHandler.new
|
||||
end
|
||||
|
||||
## messaging
|
||||
|
||||
it "test" do
|
||||
expect(1).to eq(1)
|
||||
end
|
||||
|
||||
# it "create new command" do
|
||||
# crop_id = rand(9999999).to_i
|
||||
# scheduled_time = Time.now
|
||||
#
|
||||
# @db.create_new_command(scheduled_time, crop_id)
|
||||
#
|
||||
# cmd = Command.where("scheduled_time = ?",scheduled_time).first
|
||||
#
|
||||
# expect(cmd.crop_id).to eq(crop_id)
|
||||
# end
|
||||
|
||||
end
|
Loading…
Reference in New Issue