spec/support/test_app.rb in ably-0.7.5 vs spec/support/test_app.rb in ably-0.7.6

- old
+ new

@@ -1,31 +1,18 @@ require 'singleton' class TestApp - APP_SPEC = { - 'keys' => [ - {}, - { - 'capability' => '{ "cansubscribe:*":["subscribe"], "canpublish:*":["publish"], "canpublish:andpresence":["presence","publish"] }' - } - ], - 'namespaces' => [ - { 'id' => 'persisted', 'persisted' => true } - ], - 'channels' => [ - { - 'name' => 'persisted:presence_fixtures', - 'presence' => [ - { 'clientId' => 'client_bool', 'data' => 'true' }, - { 'clientId' => 'client_int', 'data' => '24' }, - { 'clientId' => 'client_string', 'data' => 'This is a string clientData payload' }, - { 'clientId' => 'client_json', 'data' => '{ "test" => \'This is a JSONObject clientData payload\'}' } - ] - } - ] - } + TEST_RESOURCES_PATH = File.expand_path('../../../lib/submodules/ably-common/test-resources', __FILE__) + # App configuration for test app + # See https://github.com/ably/ably-common/blob/master/test-resources/test-app-setup.json + APP_SPEC = JSON.parse(File.read(File.join(TEST_RESOURCES_PATH, 'test-app-setup.json')))['post_apps'] + + # Cipher details used for client_encoded presence data in test app + # See https://github.com/ably/ably-common/blob/master/test-resources/test-app-setup.json + APP_SPEC_CIPHER = JSON.parse(File.read(File.join(TEST_RESOURCES_PATH, 'test-app-setup.json')))['cipher'] + # If an app has already been created and we need a new app, create a new test app # This is sometimes needed when a test needs to be isolated from any other tests def self.reload if instance_variable_get('@singleton__instance__') instance.delete @@ -105,15 +92,15 @@ def realtime_host host.gsub(/rest/, 'realtime') end def create_test_stats(stats) - client = Ably::Rest::Client.new(api_key: api_key, environment: environment) + client = Ably::Rest::Client.new(key: api_key, environment: environment) response = client.post('/stats', stats) raise "Could not create stats fixtures. Ably responded with status #{response.status}\n#{response.body}" unless (200..299).include?(response.status) end private def sandbox_client - @sandbox_client ||= Ably::Rest::Client.new(api_key: 'app.key:secret', tls: true, environment: environment) + @sandbox_client ||= Ably::Rest::Client.new(key: 'app.key:secret', tls: true, environment: environment) end end