lib/submodules/ably-ruby/spec/support/test_app.rb in ably-rest-0.7.3 vs lib/submodules/ably-ruby/spec/support/test_app.rb in ably-rest-0.7.5

- old
+ new

@@ -13,14 +13,14 @@ ], 'channels' => [ { 'name' => 'persisted:presence_fixtures', 'presence' => [ - { 'clientId' => 'client_bool', 'clientData' => 'true' }, - { 'clientId' => 'client_int', 'clientData' => '24' }, - { 'clientId' => 'client_string', 'clientData' => 'This is a string clientData payload' }, - { 'clientId' => 'client_json', 'clientData' => '{ "test" => \'This is a JSONObject clientData payload\'}' } + { '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\'}' } ] } ] } @@ -77,22 +77,27 @@ Faraday.delete(url, nil, headers) end def environment - 'sandbox' + ENV['ABLY_ENV'] || 'sandbox' end def create_test_app url = "#{sandbox_client.endpoint}/apps" headers = { 'Accept' => 'application/json', 'Content-Type' => 'application/json' } - @attributes = JSON.parse(Faraday.post(url, APP_SPEC.to_json, headers).body) + response = Faraday.post(url, APP_SPEC.to_json, headers) + raise "Could not create test app. Ably responded with status #{response.status}\n#{response.body}" unless (200..299).include?(response.status) + + @attributes = JSON.parse(response.body) + + puts "Test app '#{app_id}' created in #{environment} environment" end def host sandbox_client.endpoint.host end @@ -101,10 +106,11 @@ host.gsub(/rest/, 'realtime') end def create_test_stats(stats) client = Ably::Rest::Client.new(api_key: api_key, environment: environment) - client.post('/stats', stats) + 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)