diff --git a/test/minitest_helper.rb b/test/minitest_helper.rb index b1c4efd..7ae3a72 100644 --- a/test/minitest_helper.rb +++ b/test/minitest_helper.rb @@ -5,13 +5,17 @@ require "yaml" require_relative "../lib/obsws" class OBSWSTest < Minitest::Test + class << self + attr_reader :r_client + end + def self.before_run conn = YAML.load_file("obs.yml", symbolize_names: true)[:connection] - @@r_client = OBSWS::Requests::Client.new(**conn) + @r_client = OBSWS::Requests::Client.new(**conn) - @@r_client.create_scene("START_TEST") - @@r_client.create_scene("BRB_TEST") - @@r_client.create_scene("END_TEST") + r_client.create_scene("START_TEST") + r_client.create_scene("BRB_TEST") + r_client.create_scene("END_TEST") end before_run @@ -23,9 +27,9 @@ class OBSWSTest < Minitest::Test end Minitest.after_run do - @@r_client.remove_scene("START_TEST") - @@r_client.remove_scene("BRB_TEST") - @@r_client.remove_scene("END_TEST") - @@r_client.close + r_client.remove_scene("START_TEST") + r_client.remove_scene("BRB_TEST") + r_client.remove_scene("END_TEST") + r_client.close end end diff --git a/test/obsws/attrs_test.rb b/test/obsws/attrs_test.rb index a3d21f7..26a80b5 100644 --- a/test/obsws/attrs_test.rb +++ b/test/obsws/attrs_test.rb @@ -2,7 +2,7 @@ require_relative "../minitest_helper" class AttrsTest < OBSWSTest def test_get_version_attrs - resp = @@r_client.get_version + resp = OBSWSTest.r_client.get_version assert resp.attrs == %w[ available_requests diff --git a/test/obsws/request_test.rb b/test/obsws/request_test.rb index 7a6ad84..946ce5b 100644 --- a/test/obsws/request_test.rb +++ b/test/obsws/request_test.rb @@ -2,21 +2,21 @@ require_relative "../minitest_helper" class RequestTest < OBSWSTest def test_it_checks_obs_major_version - resp = @@r_client.get_version + resp = OBSWSTest.r_client.get_version ver = resp.obs_version.split(".").map(&:to_i) assert ver[0] >= 28 end def test_it_checks_ws_major_version - resp = @@r_client.get_version + resp = OBSWSTest.r_client.get_version ver = resp.obs_web_socket_version.split(".").map(&:to_i) assert ver[0] >= 5 end def test_it_sets_and_gets_current_program_scene %w[START_TEST BRB_TEST END_TEST].each do |s| - @@r_client.set_current_program_scene(s) - resp = @@r_client.get_current_program_scene + OBSWSTest.r_client.set_current_program_scene(s) + resp = OBSWSTest.r_client.get_current_program_scene assert resp.current_program_scene_name == s end end @@ -26,8 +26,8 @@ class RequestTest < OBSWSTest server: "rtmp://addressofrtmpserver", key: "live_myvery_secretkey" } - @@r_client.set_stream_service_settings("rtmp_common", settings) - resp = @@r_client.get_stream_service_settings + OBSWSTest.r_client.set_stream_service_settings("rtmp_common", settings) + resp = OBSWSTest.r_client.get_stream_service_settings assert resp.stream_service_type == "rtmp_common" assert resp.stream_service_settings == {