cosmos 3.2.1 → 3.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.
- checksums.yaml +4 -4
- data/Manifest.txt +195 -0
- data/README.md +3 -3
- data/data/crc.txt +52 -52
- data/lib/cosmos.rb +1 -1
- data/lib/cosmos/core_ext/time.rb +11 -9
- data/lib/cosmos/gui/choosers/telemetry_chooser.rb +0 -2
- data/lib/cosmos/gui/dialogs/about_dialog.rb +2 -2
- data/lib/cosmos/gui/dialogs/exception_dialog.rb +2 -2
- data/lib/cosmos/gui/dialogs/progress_dialog.rb +11 -5
- data/lib/cosmos/gui/dialogs/splash.rb +32 -10
- data/lib/cosmos/gui/dialogs/tlm_details_dialog.rb +1 -1
- data/lib/cosmos/gui/line_graph/line_graph_drawing.rb +2 -2
- data/lib/cosmos/gui/qt.rb +22 -22
- data/lib/cosmos/io/json_drb.rb +4 -4
- data/lib/cosmos/io/json_rpc.rb +21 -21
- data/lib/cosmos/packet_logs/packet_log_writer.rb +18 -20
- data/lib/cosmos/packets/commands.rb +8 -6
- data/lib/cosmos/packets/limits.rb +3 -2
- data/lib/cosmos/packets/packet.rb +14 -11
- data/lib/cosmos/packets/parsers/limits_parser.rb +1 -1
- data/lib/cosmos/packets/parsers/macro_parser.rb +4 -4
- data/lib/cosmos/packets/parsers/state_parser.rb +1 -1
- data/lib/cosmos/packets/structure.rb +2 -2
- data/lib/cosmos/packets/telemetry.rb +5 -4
- data/lib/cosmos/script/script.rb +6 -6
- data/lib/cosmos/streams/tcpip_socket_stream.rb +2 -1
- data/lib/cosmos/streams/template_stream_protocol.rb +1 -1
- data/lib/cosmos/tools/cmd_sender/cmd_sender.rb +1 -1
- data/lib/cosmos/tools/cmd_tlm_server/cmd_tlm_server_gui.rb +5 -8
- data/lib/cosmos/tools/cmd_tlm_server/gui/interfaces_tab.rb +4 -3
- data/lib/cosmos/tools/cmd_tlm_server/gui/packets_tab.rb +9 -3
- data/lib/cosmos/tools/cmd_tlm_server/gui/status_tab.rb +15 -11
- data/lib/cosmos/tools/data_viewer/data_viewer.rb +1 -1
- data/lib/cosmos/tools/data_viewer/data_viewer_component.rb +2 -2
- data/lib/cosmos/tools/handbook_creator/handbook_creator.rb +2 -2
- data/lib/cosmos/tools/handbook_creator/handbook_creator_config.rb +0 -2
- data/lib/cosmos/tools/limits_monitor/limits_monitor.rb +1 -1
- data/lib/cosmos/tools/replay/replay.rb +2 -2
- data/lib/cosmos/tools/script_runner/script_audit.rb +1 -1
- data/lib/cosmos/tools/script_runner/script_runner.rb +1 -1
- data/lib/cosmos/tools/script_runner/script_runner_frame.rb +3 -7
- data/lib/cosmos/tools/table_manager/table_config.rb +1 -1
- data/lib/cosmos/tools/test_runner/results_writer.rb +1 -1
- data/lib/cosmos/tools/test_runner/test_runner.rb +2 -2
- data/lib/cosmos/tools/tlm_extractor/tlm_extractor.rb +2 -1
- data/lib/cosmos/tools/tlm_extractor/tlm_extractor_processor.rb +1 -1
- data/lib/cosmos/tools/tlm_grapher/data_object_adders/xy_data_object_adder.rb +1 -0
- data/lib/cosmos/tools/tlm_grapher/data_object_editors/housekeeping_data_object_editor.rb +1 -0
- data/lib/cosmos/tools/tlm_grapher/data_object_editors/xy_data_object_editor.rb +1 -0
- data/lib/cosmos/tools/tlm_grapher/tabbed_plots/overview_tabbed_plots.rb +3 -3
- data/lib/cosmos/tools/tlm_viewer/tlm_viewer.rb +1 -3
- data/lib/cosmos/top_level.rb +2 -6
- data/lib/cosmos/utilities/ruby_lex_utils.rb +1 -1
- data/lib/cosmos/version.rb +5 -5
- data/lib/cosmos/win32/win32_main.rb +11 -7
- data/spec/ccsds/ccsds_packet_spec.rb +28 -28
- data/spec/ccsds/ccsds_parser_spec.rb +27 -27
- data/spec/config/config_parser_spec.rb +88 -88
- data/spec/conversions/conversion_spec.rb +3 -3
- data/spec/conversions/generic_conversion_spec.rb +9 -9
- data/spec/conversions/new_packet_log_conversion_spec.rb +4 -4
- data/spec/conversions/polynomial_conversion_spec.rb +7 -7
- data/spec/conversions/processor_conversion_spec.rb +9 -9
- data/spec/conversions/received_count_conversion_spec.rb +7 -7
- data/spec/conversions/received_time_formatted_conversion_spec.rb +9 -9
- data/spec/conversions/received_time_seconds_conversion_spec.rb +9 -9
- data/spec/conversions/segmented_polynomial_conversion_spec.rb +11 -11
- data/spec/conversions/unix_time_formatted_conversion_spec.rb +13 -13
- data/spec/conversions/unix_time_seconds_conversion_spec.rb +13 -13
- data/spec/core_ext/array_spec.rb +76 -76
- data/spec/core_ext/class_spec.rb +3 -3
- data/spec/core_ext/cosmos_io_spec.rb +16 -16
- data/spec/core_ext/exception_spec.rb +19 -19
- data/spec/core_ext/file_spec.rb +16 -16
- data/spec/core_ext/hash_spec.rb +3 -3
- data/spec/core_ext/io_spec.rb +2 -2
- data/spec/core_ext/kernel_spec.rb +2 -2
- data/spec/core_ext/math_spec.rb +43 -43
- data/spec/core_ext/matrix_spec.rb +22 -22
- data/spec/core_ext/objectspace_spec.rb +6 -6
- data/spec/core_ext/range_spec.rb +2 -2
- data/spec/core_ext/socket_spec.rb +4 -4
- data/spec/core_ext/string_spec.rb +67 -67
- data/spec/core_ext/stringio_spec.rb +2 -2
- data/spec/core_ext/time_spec.rb +82 -82
- data/spec/gui/line_graph/line_clip_spec.rb +34 -34
- data/spec/interfaces/interface_spec.rb +46 -46
- data/spec/interfaces/linc_interface_spec.rb +26 -26
- data/spec/interfaces/serial_interface_spec.rb +16 -16
- data/spec/interfaces/simulated_target_interface_spec.rb +21 -21
- data/spec/interfaces/stream_interface_spec.rb +22 -22
- data/spec/interfaces/tcpip_client_interface_spec.rb +14 -14
- data/spec/interfaces/tcpip_server_interface_spec.rb +41 -41
- data/spec/interfaces/udp_interface_spec.rb +46 -46
- data/spec/io/buffered_file_spec.rb +50 -50
- data/spec/io/io_multiplexer_spec.rb +9 -9
- data/spec/io/json_drb_object_spec.rb +7 -7
- data/spec/io/json_drb_spec.rb +55 -55
- data/spec/io/json_rpc_spec.rb +68 -68
- data/spec/io/raw_logger_pair_spec.rb +28 -28
- data/spec/io/raw_logger_spec.rb +22 -22
- data/spec/io/serial_driver_spec.rb +3 -3
- data/spec/io/stderr_spec.rb +2 -2
- data/spec/io/stdout_spec.rb +2 -2
- data/spec/io/tcpip_server_spec.rb +62 -62
- data/spec/io/udp_sockets_spec.rb +19 -19
- data/spec/io/win32_serial_driver_spec.rb +10 -10
- data/spec/packet_logs/meta_packet_log_writer_spec.rb +32 -32
- data/spec/packet_logs/packet_log_reader_spec.rb +138 -138
- data/spec/packet_logs/packet_log_writer_pair_spec.rb +3 -3
- data/spec/packet_logs/packet_log_writer_spec.rb +26 -26
- data/spec/packets/binary_accessor_spec.rb +672 -672
- data/spec/packets/commands_spec.rb +123 -123
- data/spec/packets/limits_response_spec.rb +1 -1
- data/spec/packets/limits_spec.rb +69 -69
- data/spec/packets/packet_config_spec.rb +93 -93
- data/spec/packets/packet_item_limits_spec.rb +46 -46
- data/spec/packets/packet_item_spec.rb +108 -108
- data/spec/packets/packet_spec.rb +364 -348
- data/spec/packets/parsers/format_string_parser_spec.rb +13 -13
- data/spec/packets/parsers/limits_parser_spec.rb +8 -8
- data/spec/packets/parsers/limits_response_parser_spec.rb +9 -9
- data/spec/packets/parsers/macro_parser_spec.rb +34 -6
- data/spec/packets/parsers/packet_parser_spec.rb +6 -6
- data/spec/packets/parsers/processor_parser_spec.rb +7 -7
- data/spec/packets/parsers/state_parser_spec.rb +23 -23
- data/spec/packets/structure_item_spec.rb +62 -62
- data/spec/packets/structure_spec.rb +183 -183
- data/spec/packets/telemetry_spec.rb +174 -174
- data/spec/processors/new_packet_log_processor_spec.rb +4 -4
- data/spec/processors/processor_spec.rb +9 -9
- data/spec/processors/statistics_processor_spec.rb +21 -21
- data/spec/processors/watermark_processor_spec.rb +12 -12
- data/spec/script/script_spec.rb +158 -158
- data/spec/spec_helper.rb +44 -13
- data/spec/streams/burst_stream_protocol_spec.rb +8 -8
- data/spec/streams/fixed_stream_protocol_spec.rb +26 -26
- data/spec/streams/length_stream_protocol_spec.rb +27 -27
- data/spec/streams/preidentified_stream_protocol_spec.rb +25 -25
- data/spec/streams/serial_stream_spec.rb +19 -19
- data/spec/streams/stream_protocol_spec.rb +52 -52
- data/spec/streams/stream_spec.rb +1 -1
- data/spec/streams/tcpip_client_stream_spec.rb +7 -7
- data/spec/streams/tcpip_socket_stream_spec.rb +84 -49
- data/spec/streams/template_stream_protocol_spec.rb +17 -17
- data/spec/streams/terminated_stream_protocol_spec.rb +19 -19
- data/spec/system/system_spec.rb +95 -95
- data/spec/system/target_spec.rb +32 -32
- data/spec/tools/cmd_tlm_server/api_spec.rb +386 -386
- data/spec/tools/cmd_tlm_server/background_task_spec.rb +3 -3
- data/spec/tools/cmd_tlm_server/background_tasks_spec.rb +8 -8
- data/spec/tools/cmd_tlm_server/cmd_tlm_server_config_spec.rb +57 -57
- data/spec/tools/cmd_tlm_server/cmd_tlm_server_spec.rb +85 -85
- data/spec/tools/cmd_tlm_server/commanding_spec.rb +11 -11
- data/spec/tools/cmd_tlm_server/connections_spec.rb +23 -23
- data/spec/tools/cmd_tlm_server/interface_thread_spec.rb +57 -57
- data/spec/tools/cmd_tlm_server/interfaces_spec.rb +32 -32
- data/spec/tools/cmd_tlm_server/packet_logging_spec.rb +17 -17
- data/spec/tools/cmd_tlm_server/router_thread_spec.rb +15 -15
- data/spec/tools/cmd_tlm_server/routers_spec.rb +36 -36
- data/spec/top_level/top_level_spec.rb +60 -60
- data/spec/utilities/crc_spec.rb +6 -6
- data/spec/utilities/csv_spec.rb +13 -13
- data/spec/utilities/logger_spec.rb +20 -20
- data/spec/utilities/message_log_spec.rb +13 -13
- data/spec/utilities/quaternion_spec.rb +30 -30
- data/spec/utilities/ruby_lex_utils_spec.rb +14 -14
- data/test/benchmarks/binary_accessor_benchmark.rb +14 -0
- data/test/benchmarks/gsub_benchmark.rb +114 -0
- data/test/performance/PACKETS.bat +1 -0
- data/test/performance/Rakefile +77 -0
- data/test/performance/THREADS.bat +1 -0
- data/test/performance/config/data/attitude.bin +0 -0
- data/test/performance/config/data/crc.txt +206 -0
- data/test/performance/config/data/diamond.STL +58 -0
- data/test/performance/config/data/groundoff.gif +0 -0
- data/test/performance/config/data/groundon.gif +0 -0
- data/test/performance/config/data/hselectoff.gif +0 -0
- data/test/performance/config/data/hselecton.gif +0 -0
- data/test/performance/config/data/hswitchoff.gif +0 -0
- data/test/performance/config/data/hswitchon.gif +0 -0
- data/test/performance/config/data/meta_init.txt +4 -0
- data/test/performance/config/data/position.bin +0 -0
- data/test/performance/config/data/poweroff.gif +0 -0
- data/test/performance/config/data/poweron.gif +0 -0
- data/test/performance/config/data/satellite.gif +0 -0
- data/test/performance/config/data/tada.wav +0 -0
- data/test/performance/config/data/vswitchoff.gif +0 -0
- data/test/performance/config/data/vswitchon.gif +0 -0
- data/test/performance/config/system/system_packets.txt +39 -0
- data/test/performance/config/system/system_threads.txt +59 -0
- data/test/performance/config/targets/COSMOS/cmd_tlm/cosmos_server_cmds.txt +41 -0
- data/test/performance/config/targets/COSMOS/cmd_tlm/cosmos_server_tlm.txt +15 -0
- data/test/performance/config/targets/COSMOS/cmd_tlm_server.txt +6 -0
- data/test/performance/config/targets/COSMOS/screens/limits_change.txt +20 -0
- data/test/performance/config/targets/COSMOS/screens/version.txt +19 -0
- data/test/performance/config/targets/COSMOS/target.txt +11 -0
- data/test/performance/config/targets/EXAMPLE/cmd_tlm/example_cmds.txt +17 -0
- data/test/performance/config/targets/EXAMPLE/cmd_tlm/example_tlm.txt +18 -0
- data/test/performance/config/targets/EXAMPLE/cmd_tlm_server.txt +6 -0
- data/test/performance/config/targets/EXAMPLE/lib/example_interface.rb +22 -0
- data/test/performance/config/targets/EXAMPLE/target.txt +7 -0
- data/test/performance/config/targets/SYSTEM/screens/status.txt +12 -0
- data/test/performance/config/tools/cmd_tlm_server/cmd_tlm_server_packets.txt +34 -0
- data/test/performance/config/tools/cmd_tlm_server/cmd_tlm_server_threads.txt +68 -0
- data/test/performance/config/tools/data_viewer/data_viewer.txt +11 -0
- data/test/performance/config/tools/handbook_creator/default_toc.xsl +59 -0
- data/test/performance/config/tools/handbook_creator/handbook_creator.txt +66 -0
- data/test/performance/config/tools/handbook_creator/templates/command_packets.html.erb +86 -0
- data/test/performance/config/tools/handbook_creator/templates/command_toc.html.erb +38 -0
- data/test/performance/config/tools/handbook_creator/templates/footer.html.erb +9 -0
- data/test/performance/config/tools/handbook_creator/templates/header.html.erb +25 -0
- data/test/performance/config/tools/handbook_creator/templates/limits_groups.html.erb +13 -0
- data/test/performance/config/tools/handbook_creator/templates/nav.html.erb +27 -0
- data/test/performance/config/tools/handbook_creator/templates/overview.html.erb +1 -0
- data/test/performance/config/tools/handbook_creator/templates/pdf_cover.html.erb +23 -0
- data/test/performance/config/tools/handbook_creator/templates/pdf_footer.html.erb +33 -0
- data/test/performance/config/tools/handbook_creator/templates/pdf_header.html.erb +41 -0
- data/test/performance/config/tools/handbook_creator/templates/telemetry_packets.html.erb +80 -0
- data/test/performance/config/tools/handbook_creator/templates/telemetry_toc.html.erb +38 -0
- data/test/performance/config/tools/handbook_creator/templates/title.html.erb +1 -0
- data/test/performance/config/tools/launcher/launcher_packets.txt +29 -0
- data/test/performance/config/tools/launcher/launcher_threads.txt +70 -0
- data/test/performance/config/tools/limits_monitor/README.txt +1 -0
- data/test/performance/config/tools/opengl_builder/README.txt +1 -0
- data/test/performance/config/tools/script_runner/script_runner.txt +3 -0
- data/test/performance/config/tools/table_manager/ConfigTables_def.txt +8 -0
- data/test/performance/config/tools/table_manager/ExampleTableDefinition.txt +24 -0
- data/test/performance/config/tools/table_manager/MCConfigurationTable_fsw1_def.txt +25 -0
- data/test/performance/config/tools/table_manager/MCConfigurationTable_fsw2_def.txt +25 -0
- data/test/performance/config/tools/table_manager/PPSSelectionTable_def.txt +8 -0
- data/test/performance/config/tools/table_manager/TLMMonitoringTable_def.txt +248 -0
- data/test/performance/config/tools/test_runner/test_runner.txt +17 -0
- data/test/performance/config/tools/tlm_extractor/tlm_extractor.txt +13 -0
- data/test/performance/config/tools/tlm_extractor/tlm_extractor2.txt +2 -0
- data/test/performance/config/tools/tlm_extractor/tlm_extractor3.txt +2 -0
- data/test/performance/config/tools/tlm_extractor/tlm_extractor4.txt +2 -0
- data/test/performance/config/tools/tlm_grapher/README.txt +1 -0
- data/test/performance/config/tools/tlm_viewer/tlm_viewer.txt +41 -0
- data/test/performance/lib/example_background_task.rb +57 -0
- data/test/performance/lib/example_target.rb +120 -0
- data/test/performance/lib/scpi_target.rb +74 -0
- data/test/performance/lib/user_version.rb +3 -0
- data/test/performance/outputs/handbooks/README.txt +1 -0
- data/test/performance/outputs/logs/README.txt +1 -0
- data/test/performance/outputs/saved_config/README.txt +1 -0
- data/test/performance/outputs/tables/README.txt +1 -0
- data/test/performance/outputs/tmp/README.txt +1 -0
- data/test/performance/procedures/checks.rb +11 -0
- data/test/performance/procedures/clear_util.rb +7 -0
- data/test/performance/procedures/collect.rb +18 -0
- data/test/performance/procedures/collect_util.rb +14 -0
- data/test/performance/procedures/cosmos_api_test.rb +293 -0
- data/test/performance/procedures/disconnect.rb +29 -0
- data/test/performance/procedures/example_test.rb +182 -0
- data/test/performance/procedures/plot_test.rb +8 -0
- data/test/performance/procedures/procedure.rb +3 -0
- data/test/performance/procedures/run_example_test.rb +3 -0
- data/test/performance/procedures/test.rb +51 -0
- data/test/performance/tools/CmdExtractor +14 -0
- data/test/performance/tools/CmdExtractor.bat +59 -0
- data/test/performance/tools/CmdSender +14 -0
- data/test/performance/tools/CmdSender.bat +59 -0
- data/test/performance/tools/CmdTlmServer +16 -0
- data/test/performance/tools/CmdTlmServer.bat +59 -0
- data/test/performance/tools/CmdTlmServerMemProf +20 -0
- data/test/performance/tools/CmdTlmServerMemProf.bat +59 -0
- data/test/performance/tools/DataViewer +14 -0
- data/test/performance/tools/DataViewer.bat +59 -0
- data/test/performance/tools/ExampleTarget +14 -0
- data/test/performance/tools/ExampleTarget.bat +59 -0
- data/test/performance/tools/HandbookCreator +14 -0
- data/test/performance/tools/HandbookCreator.bat +61 -0
- data/test/performance/tools/Launcher +14 -0
- data/test/performance/tools/Launcher.bat +59 -0
- data/test/performance/tools/LimitsMonitor +14 -0
- data/test/performance/tools/LimitsMonitor.bat +59 -0
- data/test/performance/tools/OpenGLBuilder +14 -0
- data/test/performance/tools/OpenGLBuilder.bat +59 -0
- data/test/performance/tools/PacketViewer +14 -0
- data/test/performance/tools/PacketViewer.bat +59 -0
- data/test/performance/tools/Replay +14 -0
- data/test/performance/tools/Replay.bat +59 -0
- data/test/performance/tools/ScpiTarget +14 -0
- data/test/performance/tools/ScpiTarget.bat +59 -0
- data/test/performance/tools/ScriptRunner +14 -0
- data/test/performance/tools/ScriptRunner.bat +59 -0
- data/test/performance/tools/TableManager +14 -0
- data/test/performance/tools/TableManager.bat +59 -0
- data/test/performance/tools/TestRunner +14 -0
- data/test/performance/tools/TestRunner.bat +59 -0
- data/test/performance/tools/TlmExtractor +14 -0
- data/test/performance/tools/TlmExtractor.bat +59 -0
- data/test/performance/tools/TlmGrapher +14 -0
- data/test/performance/tools/TlmGrapher.bat +59 -0
- data/test/performance/tools/TlmViewer +14 -0
- data/test/performance/tools/TlmViewer.bat +59 -0
- data/test/performance/tools/mac/CmdExtractor.app/Contents/Info.plist +38 -0
- data/test/performance/tools/mac/CmdExtractor.app/Contents/MacOS/CmdExtractor.rb +15 -0
- data/test/performance/tools/mac/CmdExtractor.app/Contents/MacOS/main.sh +6 -0
- data/test/performance/tools/mac/CmdExtractor.app/Contents/Resources/appIcon.icns +0 -0
- data/test/performance/tools/mac/CmdSender.app/Contents/Info.plist +38 -0
- data/test/performance/tools/mac/CmdSender.app/Contents/MacOS/CmdSender.rb +15 -0
- data/test/performance/tools/mac/CmdSender.app/Contents/MacOS/main.sh +6 -0
- data/test/performance/tools/mac/CmdSender.app/Contents/Resources/appIcon.icns +0 -0
- data/test/performance/tools/mac/CmdTlmServer.app/Contents/Info.plist +38 -0
- data/test/performance/tools/mac/CmdTlmServer.app/Contents/MacOS/CmdTlmServer.rb +15 -0
- data/test/performance/tools/mac/CmdTlmServer.app/Contents/MacOS/main.sh +6 -0
- data/test/performance/tools/mac/CmdTlmServer.app/Contents/Resources/appIcon.icns +0 -0
- data/test/performance/tools/mac/DataViewer.app/Contents/Info.plist +38 -0
- data/test/performance/tools/mac/DataViewer.app/Contents/MacOS/DataViewer.rb +15 -0
- data/test/performance/tools/mac/DataViewer.app/Contents/MacOS/main.sh +6 -0
- data/test/performance/tools/mac/DataViewer.app/Contents/Resources/appIcon.icns +0 -0
- data/test/performance/tools/mac/HandbookCreator.app/Contents/Info.plist +38 -0
- data/test/performance/tools/mac/HandbookCreator.app/Contents/MacOS/HandbookCreator.rb +15 -0
- data/test/performance/tools/mac/HandbookCreator.app/Contents/MacOS/main.sh +6 -0
- data/test/performance/tools/mac/HandbookCreator.app/Contents/Resources/appIcon.icns +0 -0
- data/test/performance/tools/mac/Launcher.app/Contents/Info.plist +38 -0
- data/test/performance/tools/mac/Launcher.app/Contents/MacOS/Launcher.rb +15 -0
- data/test/performance/tools/mac/Launcher.app/Contents/MacOS/main.sh +6 -0
- data/test/performance/tools/mac/Launcher.app/Contents/Resources/appIcon.icns +0 -0
- data/test/performance/tools/mac/LimitsMonitor.app/Contents/Info.plist +38 -0
- data/test/performance/tools/mac/LimitsMonitor.app/Contents/MacOS/LimitsMonitor.rb +15 -0
- data/test/performance/tools/mac/LimitsMonitor.app/Contents/MacOS/main.sh +6 -0
- data/test/performance/tools/mac/LimitsMonitor.app/Contents/Resources/appIcon.icns +0 -0
- data/test/performance/tools/mac/OpenGLBuilder.app/Contents/Info.plist +38 -0
- data/test/performance/tools/mac/OpenGLBuilder.app/Contents/MacOS/OpenGLBuilder.rb +15 -0
- data/test/performance/tools/mac/OpenGLBuilder.app/Contents/MacOS/main.sh +6 -0
- data/test/performance/tools/mac/OpenGLBuilder.app/Contents/Resources/appIcon.icns +0 -0
- data/test/performance/tools/mac/PacketViewer.app/Contents/Info.plist +38 -0
- data/test/performance/tools/mac/PacketViewer.app/Contents/MacOS/PacketViewer.rb +15 -0
- data/test/performance/tools/mac/PacketViewer.app/Contents/MacOS/main.sh +6 -0
- data/test/performance/tools/mac/PacketViewer.app/Contents/Resources/appIcon.icns +0 -0
- data/test/performance/tools/mac/Replay.app/Contents/Info.plist +38 -0
- data/test/performance/tools/mac/Replay.app/Contents/MacOS/Replay.rb +15 -0
- data/test/performance/tools/mac/Replay.app/Contents/MacOS/main.sh +6 -0
- data/test/performance/tools/mac/Replay.app/Contents/Resources/appIcon.icns +0 -0
- data/test/performance/tools/mac/ScriptRunner.app/Contents/Info.plist +38 -0
- data/test/performance/tools/mac/ScriptRunner.app/Contents/MacOS/ScriptRunner.rb +15 -0
- data/test/performance/tools/mac/ScriptRunner.app/Contents/MacOS/main.sh +6 -0
- data/test/performance/tools/mac/ScriptRunner.app/Contents/Resources/appIcon.icns +0 -0
- data/test/performance/tools/mac/TableManager.app/Contents/Info.plist +38 -0
- data/test/performance/tools/mac/TableManager.app/Contents/MacOS/TableManager.rb +15 -0
- data/test/performance/tools/mac/TableManager.app/Contents/MacOS/main.sh +6 -0
- data/test/performance/tools/mac/TableManager.app/Contents/Resources/appIcon.icns +0 -0
- data/test/performance/tools/mac/TestRunner.app/Contents/Info.plist +38 -0
- data/test/performance/tools/mac/TestRunner.app/Contents/MacOS/TestRunner.rb +15 -0
- data/test/performance/tools/mac/TestRunner.app/Contents/MacOS/main.sh +6 -0
- data/test/performance/tools/mac/TestRunner.app/Contents/Resources/appIcon.icns +0 -0
- data/test/performance/tools/mac/TlmExtractor.app/Contents/Info.plist +38 -0
- data/test/performance/tools/mac/TlmExtractor.app/Contents/MacOS/TlmExtractor.rb +15 -0
- data/test/performance/tools/mac/TlmExtractor.app/Contents/MacOS/main.sh +6 -0
- data/test/performance/tools/mac/TlmExtractor.app/Contents/Resources/appIcon.icns +0 -0
- data/test/performance/tools/mac/TlmGrapher.app/Contents/Info.plist +38 -0
- data/test/performance/tools/mac/TlmGrapher.app/Contents/MacOS/TlmGrapher.rb +15 -0
- data/test/performance/tools/mac/TlmGrapher.app/Contents/MacOS/main.sh +6 -0
- data/test/performance/tools/mac/TlmGrapher.app/Contents/Resources/appIcon.icns +0 -0
- data/test/performance/tools/mac/TlmViewer.app/Contents/Info.plist +38 -0
- data/test/performance/tools/mac/TlmViewer.app/Contents/MacOS/TlmViewer.rb +15 -0
- data/test/performance/tools/mac/TlmViewer.app/Contents/MacOS/main.sh +6 -0
- data/test/performance/tools/mac/TlmViewer.app/Contents/Resources/appIcon.icns +0 -0
- data/test/performance/userpath.txt +1 -0
- metadata +197 -2
@@ -19,13 +19,13 @@ module Cosmos
|
|
19
19
|
end
|
20
20
|
|
21
21
|
describe "add_stream" do
|
22
|
-
it "
|
22
|
+
it "adds a single stream" do
|
23
23
|
@io.add_stream(STDOUT)
|
24
24
|
expect($stdout).to receive(:puts).with("TEST")
|
25
25
|
@io.puts "TEST"
|
26
26
|
end
|
27
27
|
|
28
|
-
it "
|
28
|
+
it "adds multiple streams" do
|
29
29
|
@io.add_stream(STDOUT)
|
30
30
|
@io.add_stream(STDERR)
|
31
31
|
expect($stdout).to receive(:puts).with("TEST")
|
@@ -35,7 +35,7 @@ module Cosmos
|
|
35
35
|
end
|
36
36
|
|
37
37
|
describe "remove_stream" do
|
38
|
-
it "
|
38
|
+
it "removes the stream from output" do
|
39
39
|
@io.add_stream(STDOUT)
|
40
40
|
@io.add_stream(STDERR)
|
41
41
|
@io.remove_stream(STDOUT)
|
@@ -46,7 +46,7 @@ module Cosmos
|
|
46
46
|
end
|
47
47
|
|
48
48
|
describe "print, printf, putc, puts, flush" do
|
49
|
-
it "
|
49
|
+
it "defers to the stream" do
|
50
50
|
@io.add_stream(STDOUT)
|
51
51
|
expect($stdout).to receive(:print).with("TEST")
|
52
52
|
@io.print "TEST"
|
@@ -62,19 +62,19 @@ module Cosmos
|
|
62
62
|
end
|
63
63
|
|
64
64
|
describe "write write_nonblock" do
|
65
|
-
it "
|
65
|
+
it "defers to the stream" do
|
66
66
|
@io.add_stream(STDOUT)
|
67
67
|
expect($stdout).to receive(:write).with("TEST")
|
68
68
|
len = @io.write "TEST"
|
69
|
-
len.
|
69
|
+
expect(len).to eql 4
|
70
70
|
expect($stdout).to receive(:write_nonblock).with("TEST")
|
71
71
|
len = @io.write_nonblock "TEST"
|
72
|
-
len.
|
72
|
+
expect(len).to eql 4
|
73
73
|
end
|
74
74
|
end
|
75
75
|
|
76
76
|
describe "remove_default_io" do
|
77
|
-
it "
|
77
|
+
it "removes STDOUT and STDERR from the streams" do
|
78
78
|
f = File.open("unittest.txt",'w')
|
79
79
|
@io.add_stream(STDOUT)
|
80
80
|
@io.add_stream(STDERR)
|
@@ -84,7 +84,7 @@ module Cosmos
|
|
84
84
|
f.close
|
85
85
|
expect($stdout).not_to receive(:puts).with("TEST")
|
86
86
|
expect($stderr).not_to receive(:puts).with("TEST")
|
87
|
-
File.read("unittest.txt").
|
87
|
+
expect(File.read("unittest.txt")).to eql "TEST\n"
|
88
88
|
File.delete("unittest.txt")
|
89
89
|
end
|
90
90
|
end
|
@@ -15,13 +15,13 @@ module Cosmos
|
|
15
15
|
|
16
16
|
describe JsonDRbObject do
|
17
17
|
describe "initialize" do
|
18
|
-
it "
|
18
|
+
it "rescues bad hosts" do
|
19
19
|
expect { JsonDRbObject.new("blah", 7777) }.to raise_error("Invalid hostname: blah")
|
20
20
|
end
|
21
21
|
end
|
22
22
|
|
23
23
|
describe "method_missing" do
|
24
|
-
it "
|
24
|
+
it "calls the method on the remote object" do
|
25
25
|
class JsonDRbObjectServer
|
26
26
|
def my_method(param)
|
27
27
|
param * 2
|
@@ -31,13 +31,13 @@ module Cosmos
|
|
31
31
|
json = JsonDRb.new
|
32
32
|
json.start_service('127.0.0.1', 7777, JsonDRbObjectServer.new)
|
33
33
|
obj = JsonDRbObject.new("localhost", 7777)
|
34
|
-
obj.my_method(10).
|
34
|
+
expect(obj.my_method(10)).to eql 20
|
35
35
|
obj.disconnect
|
36
36
|
json.stop_service
|
37
37
|
sleep(0.1)
|
38
38
|
end
|
39
39
|
|
40
|
-
it "
|
40
|
+
it "raises an exception if the remote connection can't be made" do
|
41
41
|
json = JsonDRb.new
|
42
42
|
json.start_service('127.0.0.1', 7777, self)
|
43
43
|
allow_any_instance_of(Socket).to receive(:connect_nonblock) { raise "Error" }
|
@@ -48,7 +48,7 @@ module Cosmos
|
|
48
48
|
sleep(0.1)
|
49
49
|
end
|
50
50
|
|
51
|
-
it "
|
51
|
+
it "retries the request and then raise an exception" do
|
52
52
|
class JsonDRbObjectServer
|
53
53
|
def my_method(param)
|
54
54
|
param * 2
|
@@ -65,7 +65,7 @@ module Cosmos
|
|
65
65
|
sleep(0.1)
|
66
66
|
end
|
67
67
|
|
68
|
-
it "
|
68
|
+
it "raises an exception if the remote method returns an error" do
|
69
69
|
json = JsonDRb.new
|
70
70
|
json.start_service('127.0.0.1', 7777, self)
|
71
71
|
obj = JsonDRbObject.new("localhost", 7777)
|
@@ -76,7 +76,7 @@ module Cosmos
|
|
76
76
|
sleep(0.1)
|
77
77
|
end
|
78
78
|
|
79
|
-
it "
|
79
|
+
it "handles the remote not returning a response" do
|
80
80
|
class JsonDRbObjectServer
|
81
81
|
def my_method(param)
|
82
82
|
param * 2
|
data/spec/io/json_drb_spec.rb
CHANGED
@@ -20,60 +20,60 @@ module Cosmos
|
|
20
20
|
end
|
21
21
|
|
22
22
|
describe "initialize" do
|
23
|
-
it "
|
24
|
-
@json.request_count.
|
25
|
-
@json.num_clients.
|
23
|
+
it "sets request_count and num_clients to 0" do
|
24
|
+
expect(@json.request_count).to eql 0
|
25
|
+
expect(@json.num_clients).to eql 0
|
26
26
|
end
|
27
27
|
end
|
28
28
|
|
29
29
|
describe "acl" do
|
30
|
-
it "
|
30
|
+
it "sets the access control list" do
|
31
31
|
acl = ACL.new(['allow','127.0.0.1'], ACL::ALLOW_DENY)
|
32
32
|
@json.acl = acl
|
33
|
-
@json.acl.
|
33
|
+
expect(@json.acl).to eql acl
|
34
34
|
end
|
35
35
|
end
|
36
36
|
|
37
37
|
describe "method_whitelist" do
|
38
|
-
it "
|
38
|
+
it "sets the method whitelist" do
|
39
39
|
@json.method_whitelist = ['cmd']
|
40
|
-
@json.method_whitelist.
|
40
|
+
expect(@json.method_whitelist).to eql ['cmd']
|
41
41
|
end
|
42
42
|
end
|
43
43
|
|
44
44
|
describe "add_request_time, average_request_time" do
|
45
|
-
it "
|
45
|
+
it "adds time to the list and return the average" do
|
46
46
|
@json.add_request_time(1.0)
|
47
47
|
@json.add_request_time(2.0)
|
48
48
|
@json.add_request_time(3.0)
|
49
|
-
@json.average_request_time.
|
49
|
+
expect(@json.average_request_time).to eql 2.0
|
50
50
|
end
|
51
51
|
end
|
52
52
|
|
53
53
|
describe "start_service" do
|
54
|
-
it "
|
55
|
-
@json.thread.
|
54
|
+
it "does nothing when passed no parameters" do
|
55
|
+
expect(@json.thread).to be_nil
|
56
56
|
@json.start_service()
|
57
|
-
@json.thread.
|
57
|
+
expect(@json.thread).to be_nil
|
58
58
|
end
|
59
59
|
|
60
|
-
it "
|
61
|
-
@json.thread.
|
60
|
+
it "raises an error when passed incomplete parameters" do
|
61
|
+
expect(@json.thread).to be_nil
|
62
62
|
expect { @json.start_service('127.0.0.1') }.to raise_error
|
63
63
|
expect { @json.start_service('127.0.0.1', 7777) }.to raise_error
|
64
|
-
@json.thread.
|
64
|
+
expect(@json.thread).to be_nil
|
65
65
|
end
|
66
66
|
|
67
|
-
it "
|
67
|
+
it "raises an error when passed a bad host" do
|
68
68
|
capture_io do |stdout|
|
69
|
-
@json.thread.
|
69
|
+
expect(@json.thread).to be_nil
|
70
70
|
system_exit_count = $system_exit_count
|
71
71
|
@json.start_service('blah', 7777, self)
|
72
72
|
thread = @json.thread
|
73
|
-
$system_exit_count.
|
73
|
+
expect($system_exit_count).to eql(system_exit_count + 1)
|
74
74
|
sleep 0.1
|
75
75
|
|
76
|
-
stdout.string.
|
76
|
+
expect(stdout.string).to match /listen thread/
|
77
77
|
@json.stop_service
|
78
78
|
sleep(0.1)
|
79
79
|
end
|
@@ -83,16 +83,16 @@ module Cosmos
|
|
83
83
|
end
|
84
84
|
end
|
85
85
|
|
86
|
-
it "
|
87
|
-
@json.thread.
|
86
|
+
it "creates a single listen thread" do
|
87
|
+
expect(@json.thread).to be_nil
|
88
88
|
@json.start_service('127.0.0.1', 7777, self)
|
89
|
-
@json.thread.alive
|
89
|
+
expect(@json.thread.alive?).to be_truthy
|
90
90
|
expect { @json.start_service('127.0.0.1', 7777, self) }.to raise_error(/Error binding to port/)
|
91
91
|
@json.stop_service
|
92
92
|
sleep(0.1)
|
93
93
|
end
|
94
94
|
|
95
|
-
it "
|
95
|
+
it "rescues listen thread exceptions" do
|
96
96
|
capture_io do |stdout|
|
97
97
|
allow_any_instance_of(TCPServer).to receive(:accept_nonblock) { raise "BLAH" }
|
98
98
|
@json.start_service('127.0.0.1', 7777, self)
|
@@ -101,7 +101,7 @@ module Cosmos
|
|
101
101
|
@json.stop_service
|
102
102
|
sleep(0.1)
|
103
103
|
|
104
|
-
stdout.string.
|
104
|
+
expect(stdout.string).to match /JsonDRb listen thread unexpectedly died/
|
105
105
|
end
|
106
106
|
|
107
107
|
Dir[File.join(Cosmos::USERPATH,"*_exception.txt")].each do |file|
|
@@ -109,12 +109,12 @@ module Cosmos
|
|
109
109
|
end
|
110
110
|
end
|
111
111
|
|
112
|
-
it "
|
112
|
+
it "ignores connections via the ACL" do
|
113
113
|
@json.acl = ACL.new(['deny','127.0.0.1'], ACL::ALLOW_DENY)
|
114
114
|
@json.start_service('127.0.0.1', 7777, self)
|
115
115
|
socket = TCPSocket.open('127.0.0.1',7777)
|
116
116
|
sleep 0.1
|
117
|
-
socket.eof
|
117
|
+
expect(socket.eof?).to be_truthy
|
118
118
|
socket.close
|
119
119
|
@json.stop_service
|
120
120
|
sleep(0.1)
|
@@ -122,7 +122,7 @@ module Cosmos
|
|
122
122
|
end
|
123
123
|
|
124
124
|
describe "receive_message" do
|
125
|
-
it "
|
125
|
+
it "returns nil if 4 bytes of data aren't available" do
|
126
126
|
@json.start_service('127.0.0.1', 7777, self)
|
127
127
|
socket = TCPSocket.open('127.0.0.1',7777)
|
128
128
|
# Stub recv_nonblock so it returns nothing
|
@@ -130,14 +130,14 @@ module Cosmos
|
|
130
130
|
sleep 0.1
|
131
131
|
JsonDRb.send_data(socket, "\x00")
|
132
132
|
response_data = JsonDRb.receive_message(socket, '')
|
133
|
-
response_data.
|
133
|
+
expect(response_data).to be_nil
|
134
134
|
socket.close
|
135
135
|
sleep 0.1
|
136
136
|
@json.stop_service
|
137
137
|
sleep(0.1)
|
138
138
|
end
|
139
139
|
|
140
|
-
it "
|
140
|
+
it "processes success requests" do
|
141
141
|
class MyServer1
|
142
142
|
def my_method(param)
|
143
143
|
end
|
@@ -150,14 +150,14 @@ module Cosmos
|
|
150
150
|
JsonDRb.send_data(socket, request)
|
151
151
|
response_data = JsonDRb.receive_message(socket, '')
|
152
152
|
response = JsonRpcResponse.from_json(response_data)
|
153
|
-
response.
|
153
|
+
expect(response).to be_a(JsonRpcSuccessResponse)
|
154
154
|
socket.close
|
155
155
|
sleep 0.1
|
156
156
|
@json.stop_service
|
157
157
|
sleep(0.1)
|
158
158
|
end
|
159
159
|
|
160
|
-
it "
|
160
|
+
it "processes bad methods" do
|
161
161
|
class MyServer2
|
162
162
|
end
|
163
163
|
|
@@ -168,16 +168,16 @@ module Cosmos
|
|
168
168
|
JsonDRb.send_data(socket, request)
|
169
169
|
response_data = JsonDRb.receive_message(socket, '')
|
170
170
|
response = JsonRpcResponse.from_json(response_data)
|
171
|
-
response.
|
172
|
-
response.error.code.
|
173
|
-
response.error.message.
|
171
|
+
expect(response).to be_a(JsonRpcErrorResponse)
|
172
|
+
expect(response.error.code).to eql -32601
|
173
|
+
expect(response.error.message).to eql "Method not found"
|
174
174
|
socket.close
|
175
175
|
sleep 0.1
|
176
176
|
@json.stop_service
|
177
177
|
sleep(0.1)
|
178
178
|
end
|
179
179
|
|
180
|
-
it "
|
180
|
+
it "processes bad parameters" do
|
181
181
|
class MyServer3
|
182
182
|
def my_method(param1, param2)
|
183
183
|
end
|
@@ -190,16 +190,16 @@ module Cosmos
|
|
190
190
|
JsonDRb.send_data(socket, request)
|
191
191
|
response_data = JsonDRb.receive_message(socket, '')
|
192
192
|
response = JsonRpcResponse.from_json(response_data)
|
193
|
-
response.
|
194
|
-
response.error.code.
|
195
|
-
response.error.message.
|
193
|
+
expect(response).to be_a(JsonRpcErrorResponse)
|
194
|
+
expect(response.error.code).to eql -32602
|
195
|
+
expect(response.error.message).to eql "Invalid params"
|
196
196
|
socket.close
|
197
197
|
sleep 0.1
|
198
198
|
@json.stop_service
|
199
199
|
sleep(0.1)
|
200
200
|
end
|
201
201
|
|
202
|
-
it "
|
202
|
+
it "handles method exceptions" do
|
203
203
|
class MyServer4
|
204
204
|
def my_method(param)
|
205
205
|
raise "Method Error"
|
@@ -213,16 +213,16 @@ module Cosmos
|
|
213
213
|
JsonDRb.send_data(socket, request)
|
214
214
|
response_data = JsonDRb.receive_message(socket, '')
|
215
215
|
response = JsonRpcResponse.from_json(response_data)
|
216
|
-
response.
|
217
|
-
response.error.code.
|
218
|
-
response.error.message.
|
216
|
+
expect(response).to be_a(JsonRpcErrorResponse)
|
217
|
+
expect(response.error.code).to eql -1
|
218
|
+
expect(response.error.message).to eql "Method Error"
|
219
219
|
socket.close
|
220
220
|
sleep 0.1
|
221
221
|
@json.stop_service
|
222
222
|
sleep(0.1)
|
223
223
|
end
|
224
224
|
|
225
|
-
it "
|
225
|
+
it "does not allow dangerous methods" do
|
226
226
|
@json.start_service('127.0.0.1', 7777, self)
|
227
227
|
socket = TCPSocket.open('127.0.0.1',7777)
|
228
228
|
sleep 0.1
|
@@ -230,16 +230,16 @@ module Cosmos
|
|
230
230
|
JsonDRb.send_data(socket, request)
|
231
231
|
response_data = JsonDRb.receive_message(socket, '')
|
232
232
|
response = JsonRpcResponse.from_json(response_data)
|
233
|
-
response.
|
234
|
-
response.error.code.
|
235
|
-
response.error.message.
|
233
|
+
expect(response).to be_a(JsonRpcErrorResponse)
|
234
|
+
expect(response.error.code).to eql -1
|
235
|
+
expect(response.error.message).to eql "Cannot call unauthorized methods"
|
236
236
|
socket.close
|
237
237
|
sleep 0.1
|
238
238
|
@json.stop_service
|
239
239
|
sleep(0.1)
|
240
240
|
end
|
241
241
|
|
242
|
-
it "
|
242
|
+
it "handles an invalid JsonDRB request" do
|
243
243
|
@json.start_service('127.0.0.1', 7777, self)
|
244
244
|
socket = TCPSocket.open('127.0.0.1',7777)
|
245
245
|
sleep 0.1
|
@@ -249,9 +249,9 @@ module Cosmos
|
|
249
249
|
JsonDRb.send_data(socket, request)
|
250
250
|
response_data = JsonDRb.receive_message(socket, '')
|
251
251
|
response = JsonRpcResponse.from_json(response_data)
|
252
|
-
response.
|
253
|
-
response.error.code.
|
254
|
-
response.error.message.
|
252
|
+
expect(response).to be_a(JsonRpcErrorResponse)
|
253
|
+
expect(response.error.code).to eql -32600
|
254
|
+
expect(response.error.message).to eql "Invalid Request"
|
255
255
|
socket.close
|
256
256
|
sleep 0.1
|
257
257
|
@json.stop_service
|
@@ -260,7 +260,7 @@ module Cosmos
|
|
260
260
|
end
|
261
261
|
|
262
262
|
describe "send_data" do
|
263
|
-
it "
|
263
|
+
it "retries if the socket blocks" do
|
264
264
|
@json.start_service('127.0.0.1', 7777, self)
|
265
265
|
socket = TCPSocket.open('127.0.0.1',7777)
|
266
266
|
# Stub write_nonblock so it blocks
|
@@ -281,7 +281,7 @@ module Cosmos
|
|
281
281
|
sleep(0.1)
|
282
282
|
end
|
283
283
|
|
284
|
-
it "
|
284
|
+
it "eventuallies timeout if the socket blocks" do
|
285
285
|
@json.start_service('127.0.0.1', 7777, self)
|
286
286
|
socket = TCPSocket.open('127.0.0.1',7777)
|
287
287
|
# Stub write_nonblock so it blocks
|
@@ -298,11 +298,11 @@ module Cosmos
|
|
298
298
|
end
|
299
299
|
|
300
300
|
describe "debug, debug?" do
|
301
|
-
it "
|
301
|
+
it "sets the debug level" do
|
302
302
|
JsonDRb.debug = true
|
303
|
-
JsonDRb.debug
|
303
|
+
expect(JsonDRb.debug?).to be_truthy
|
304
304
|
JsonDRb.debug = false
|
305
|
-
JsonDRb.debug
|
305
|
+
expect(JsonDRb.debug?).to be_falsey
|
306
306
|
end
|
307
307
|
end
|
308
308
|
|
data/spec/io/json_rpc_spec.rb
CHANGED
@@ -26,26 +26,26 @@ describe Object do
|
|
26
26
|
end
|
27
27
|
end
|
28
28
|
|
29
|
-
it "
|
30
|
-
Test1.new.as_json.
|
31
|
-
Test2.new.as_json.
|
29
|
+
it "implements as_json" do
|
30
|
+
expect(Test1.new.as_json).to eql [:@test]
|
31
|
+
expect(Test2.new.as_json).to eql Hash.new("test"=>0)
|
32
32
|
end
|
33
33
|
end
|
34
34
|
|
35
35
|
describe Struct do
|
36
|
-
it "
|
36
|
+
it "implements as_json" do
|
37
37
|
s = Struct.new(:test1, :test2)
|
38
38
|
instance = s.new(1,2)
|
39
39
|
hash = {"test1"=>1,"test2"=>2}
|
40
|
-
instance.as_json.
|
40
|
+
expect(instance.as_json).to eql hash
|
41
41
|
end
|
42
42
|
end
|
43
43
|
|
44
44
|
describe String do
|
45
|
-
it "
|
46
|
-
"test".as_json.
|
45
|
+
it "implements as_json" do
|
46
|
+
expect("test".as_json).to eql "test"
|
47
47
|
hash = {"json_class"=>"String","raw"=>[16]}
|
48
|
-
"\x10".as_json.
|
48
|
+
expect("\x10".as_json).to eql hash
|
49
49
|
end
|
50
50
|
end
|
51
51
|
|
@@ -58,42 +58,42 @@ describe Enumerable do
|
|
58
58
|
end
|
59
59
|
end
|
60
60
|
|
61
|
-
it "
|
62
|
-
Test.new.as_json.
|
61
|
+
it "implements as_json" do
|
62
|
+
expect(Test.new.as_json).to eql [1,2]
|
63
63
|
end
|
64
64
|
end
|
65
65
|
|
66
66
|
describe Array do
|
67
|
-
it "
|
68
|
-
[1,2,3].as_json.
|
67
|
+
it "implements as_json" do
|
68
|
+
expect([1,2,3].as_json).to eql [1,2,3]
|
69
69
|
end
|
70
70
|
end
|
71
71
|
|
72
72
|
describe Hash do
|
73
|
-
it "
|
73
|
+
it "implements as_json" do
|
74
74
|
hash = {"true"=>1,"false"=>0}
|
75
|
-
hash.as_json.
|
75
|
+
expect(hash.as_json).to eql hash
|
76
76
|
end
|
77
77
|
end
|
78
78
|
|
79
79
|
describe Time do
|
80
|
-
it "
|
80
|
+
it "implements as_json" do
|
81
81
|
time = Time.new(2020,01,31,12,20,10)
|
82
|
-
time.as_json.
|
82
|
+
expect(time.as_json).to match "2020-01-31 12:20:10"
|
83
83
|
end
|
84
84
|
end
|
85
85
|
|
86
86
|
describe Date do
|
87
|
-
it "
|
87
|
+
it "implements as_json" do
|
88
88
|
date = Date.new(2020,01,31)
|
89
|
-
date.as_json.
|
89
|
+
expect(date.as_json).to eql "2020-01-31"
|
90
90
|
end
|
91
91
|
end
|
92
92
|
|
93
93
|
describe DateTime do
|
94
|
-
it "
|
94
|
+
it "implements as_json" do
|
95
95
|
dt = DateTime.new(2020,01,31,12,20,10)
|
96
|
-
dt.as_json.
|
96
|
+
expect(dt.as_json).to match "2020-01-31T12:20:10"
|
97
97
|
end
|
98
98
|
end
|
99
99
|
|
@@ -105,26 +105,26 @@ describe Exception do
|
|
105
105
|
end
|
106
106
|
end
|
107
107
|
|
108
|
-
it "
|
108
|
+
it "implements as_json" do
|
109
109
|
json = TestError.new("Error").as_json
|
110
|
-
json["class"].
|
111
|
-
json["message"].
|
110
|
+
expect(json["class"]).to eql "TestError"
|
111
|
+
expect(json["message"]).to eql "Error"
|
112
112
|
hash = {"@test"=>"test"}
|
113
|
-
json["instance_variables"].
|
113
|
+
expect(json["instance_variables"]).to eql hash
|
114
114
|
end
|
115
115
|
|
116
|
-
it "
|
117
|
-
TestError.new("Error").to_json.
|
116
|
+
it "calls as_json from to_json" do
|
117
|
+
expect(TestError.new("Error").to_json).to be_a String
|
118
118
|
end
|
119
119
|
|
120
|
-
it "
|
120
|
+
it "creates an object from a hash" do
|
121
121
|
json = TestError.new("Error").as_json
|
122
122
|
error = Exception.from_hash(json)
|
123
|
-
error.
|
124
|
-
error.message.
|
123
|
+
expect(error).to be_a TestError
|
124
|
+
expect(error.message).to eql "Error"
|
125
125
|
end
|
126
126
|
|
127
|
-
it "
|
127
|
+
it "rescues creating an object" do
|
128
128
|
json = TestError.new("Error").as_json
|
129
129
|
json["class"] = "ClassWhichDoesNotExist"
|
130
130
|
json["message"] = "Error"
|
@@ -137,48 +137,48 @@ module Cosmos
|
|
137
137
|
|
138
138
|
describe JsonRpcRequest do
|
139
139
|
describe "method" do
|
140
|
-
it "
|
141
|
-
JsonRpcRequest.new("puts","test",10).method.
|
140
|
+
it "returns the method" do
|
141
|
+
expect(JsonRpcRequest.new("puts","test",10).method).to eql "puts"
|
142
142
|
end
|
143
143
|
end
|
144
144
|
|
145
145
|
describe "params" do
|
146
|
-
it "
|
147
|
-
JsonRpcRequest.new("puts",nil,10).params.
|
148
|
-
JsonRpcRequest.new("puts","test",10).params.
|
149
|
-
JsonRpcRequest.new("puts",["test",1],10).params.
|
146
|
+
it "returns the parameters" do
|
147
|
+
expect(JsonRpcRequest.new("puts",nil,10).params).to eql []
|
148
|
+
expect(JsonRpcRequest.new("puts","test",10).params).to eql "test"
|
149
|
+
expect(JsonRpcRequest.new("puts",["test",1],10).params).to eql ["test",1]
|
150
150
|
end
|
151
151
|
end
|
152
152
|
|
153
153
|
describe "id" do
|
154
|
-
it "
|
155
|
-
JsonRpcRequest.new("puts",nil,10).id.
|
154
|
+
it "returns the request id" do
|
155
|
+
expect(JsonRpcRequest.new("puts",nil,10).id).to eql 10
|
156
156
|
end
|
157
157
|
end
|
158
158
|
|
159
159
|
describe "as_json" do
|
160
|
-
it "
|
160
|
+
it "returns the json hash" do
|
161
161
|
json = JsonRpcRequest.new("puts","test",10).as_json
|
162
|
-
json["jsonrpc"].
|
163
|
-
json["method"].
|
164
|
-
json["params"].
|
165
|
-
json["id"].
|
162
|
+
expect(json["jsonrpc"]).to eql "2.0"
|
163
|
+
expect(json["method"]).to eql "puts"
|
164
|
+
expect(json["params"]).to eql "test"
|
165
|
+
expect(json["id"]).to eql 10
|
166
166
|
end
|
167
167
|
end
|
168
168
|
|
169
169
|
describe "to_json" do
|
170
|
-
it "
|
171
|
-
json = JsonRpcRequest.new("puts","test",10).to_json.
|
170
|
+
it "returns the json string" do
|
171
|
+
json = expect(JsonRpcRequest.new("puts","test",10).to_json).to be_a String
|
172
172
|
end
|
173
173
|
end
|
174
174
|
|
175
175
|
describe "from_json" do
|
176
|
-
it "
|
176
|
+
it "creates a request from the json string" do
|
177
177
|
request = JsonRpcRequest.new("puts","test",10)
|
178
|
-
request.
|
178
|
+
expect(request).to eq(JsonRpcRequest.from_json(request.to_json))
|
179
179
|
end
|
180
180
|
|
181
|
-
it "
|
181
|
+
it "rescues a bad json string" do
|
182
182
|
json = JsonRpcRequest.new("puts","test",10).to_json
|
183
183
|
json.gsub!("jsonrpc","version")
|
184
184
|
json.gsub!("2.0","1.1")
|
@@ -188,71 +188,71 @@ module Cosmos
|
|
188
188
|
end
|
189
189
|
|
190
190
|
describe "from_hash" do
|
191
|
-
it "
|
191
|
+
it "creates a request from the hash" do
|
192
192
|
request = JsonRpcRequest.new("puts","test",10)
|
193
|
-
request.
|
193
|
+
expect(request).to eq(JsonRpcRequest.from_hash(request.as_json))
|
194
194
|
end
|
195
195
|
end
|
196
196
|
end
|
197
197
|
|
198
198
|
describe JsonRpcResponse do
|
199
199
|
describe "as_json" do
|
200
|
-
it "
|
200
|
+
it "returns the json hash" do
|
201
201
|
json = JsonRpcResponse.new(10).as_json
|
202
|
-
json["jsonrpc"].
|
203
|
-
json["id"].
|
202
|
+
expect(json["jsonrpc"]).to eql "2.0"
|
203
|
+
expect(json["id"]).to eql 10
|
204
204
|
end
|
205
205
|
end
|
206
206
|
|
207
207
|
describe "to_json" do
|
208
|
-
it "
|
209
|
-
json = JsonRpcResponse.new(10).to_json.
|
208
|
+
it "returns the json string" do
|
209
|
+
json = expect(JsonRpcResponse.new(10).to_json).to be_a String
|
210
210
|
end
|
211
211
|
end
|
212
212
|
|
213
213
|
describe "from_json" do
|
214
|
-
it "
|
214
|
+
it "creates a success response from the json string" do
|
215
215
|
json = JsonRpcResponse.new(10).as_json
|
216
216
|
json['result'] = "true"
|
217
217
|
response = JsonRpcResponse.from_json(json.to_json)
|
218
|
-
response.
|
219
|
-
response.result.
|
218
|
+
expect(response).to be_a JsonRpcSuccessResponse
|
219
|
+
expect(response.result).to eql "true"
|
220
220
|
end
|
221
221
|
|
222
|
-
it "
|
222
|
+
it "creates a error response from the json string" do
|
223
223
|
json = JsonRpcResponse.new(10).as_json
|
224
224
|
json['error'] = {"code"=>-1, "message"=>"error", "data"=>{"message"=>"problem"}}
|
225
225
|
response = JsonRpcResponse.from_json(json.to_json)
|
226
|
-
response.
|
227
|
-
response.error.code.
|
228
|
-
response.error.message.
|
229
|
-
response.error.data['message'].
|
226
|
+
expect(response).to be_a JsonRpcErrorResponse
|
227
|
+
expect(response.error.code).to eql -1
|
228
|
+
expect(response.error.message).to eql "error"
|
229
|
+
expect(response.error.data['message']).to eql "problem"
|
230
230
|
end
|
231
231
|
|
232
|
-
it "
|
232
|
+
it "reports an error if there is no 'result' or 'error' key" do
|
233
233
|
json = JsonRpcResponse.new(10).as_json
|
234
234
|
expect { JsonRpcResponse.from_json(json.to_json) }.to raise_error("Invalid JSON-RPC 2.0 Response")
|
235
235
|
end
|
236
236
|
|
237
|
-
it "
|
237
|
+
it "reports an error if the version isn't 2.0" do
|
238
238
|
json = JsonRpcResponse.new(10).as_json
|
239
239
|
json['jsonrpc'] = "1.1"
|
240
240
|
json['result'] = "true"
|
241
241
|
expect { JsonRpcResponse.from_json(json.to_json) }.to raise_error("Invalid JSON-RPC 2.0 Response")
|
242
242
|
end
|
243
243
|
|
244
|
-
it "
|
244
|
+
it "reports an error if there is both a 'result' and 'error' key" do
|
245
245
|
json = JsonRpcResponse.new(10).as_json
|
246
246
|
json['result'] = "true"
|
247
247
|
json['error'] = {"code"=>-1, "message"=>"error"}
|
248
248
|
expect { JsonRpcResponse.from_json(json.to_json) }.to raise_error("Invalid JSON-RPC 2.0 Response")
|
249
249
|
end
|
250
250
|
|
251
|
-
it "
|
251
|
+
it "reports an error if it is not json" do
|
252
252
|
expect { JsonRpcResponse.from_json(Object.new) }.to raise_error("Invalid JSON-RPC 2.0 Response")
|
253
253
|
end
|
254
254
|
|
255
|
-
it "
|
255
|
+
it "reports an error if the error hash is bad" do
|
256
256
|
json = JsonRpcResponse.new(10).as_json
|
257
257
|
json['error'] = {"code"=>-1}
|
258
258
|
expect { JsonRpcResponse.from_json(json.to_json) }.to raise_error("Invalid JSON-RPC 2.0 Error")
|