spec/integration/hawkular_client_spec.rb in hawkular-client-2.1.0 vs spec/integration/hawkular_client_spec.rb in hawkular-client-2.2.0
- old
+ new
@@ -2,17 +2,22 @@
require "#{File.dirname(__FILE__)}/../spec_helper"
require 'securerandom'
# examples that tests the main client which delegates all the calls to Hawkular component clients
module Hawkular::Client::RSpec
+ HOST = 'http://localhost:8080'
+
describe 'HawkularClient' do
before(:all) do
@creds = {
username: 'jdoe',
password: 'password'
}
- @hawkular_client = Hawkular::Client.new(credentials: @creds)
+ ::RSpec::Mocks.with_temporary_scope do
+ mock_inventory_client
+ @hawkular_client = Hawkular::Client.new(entrypoint: HOST, credentials: @creds)
+ end
@state = {
hostname: 'localhost.localdomain',
feed: nil
}
end
@@ -26,11 +31,14 @@
expect { @hawkular_client.inventory_lyst_feeds }.to raise_error(NoMethodError)
end
context 'and Inventory client', vcr: { decode_compressed_response: true } do
before(:all) do
- @client = Hawkular::Inventory::InventoryClient.create(credentials: @creds)
+ ::RSpec::Mocks.with_temporary_scope do
+ mock_inventory_client
+ @client = Hawkular::Inventory::InventoryClient.create(entrypoint: HOST, credentials: @creds)
+ end
end
it 'Should list the same feeds' do
feeds1 = @client.list_feeds
feeds2 = @hawkular_client.inventory_list_feeds
@@ -91,11 +99,11 @@
context 'and Metrics client' do
include Hawkular::Metrics::RSpec
before(:all) do
- @client = Hawkular::Metrics::Client.new('http://localhost:8080/hawkular/metrics', @creds)
+ @client = Hawkular::Metrics::Client.new(HOST, @creds)
end
it 'Should both work the same way when pushing metric data to non-existing counter' do
id = SecureRandom.uuid
@@ -186,10 +194,10 @@
operationName: 'Redeploy',
resourcePath: path.to_s
}
actual_data = {}
- client = Hawkular::Operations::OperationsClient.new(entrypoint: 'http://localhost:8080', credentials: @creds)
+ client = Hawkular::Operations::OperationsClient.new(entrypoint: HOST, credentials: @creds)
client.invoke_generic_operation(redeploy) do |on|
on.success do |data|
actual_data[:data] = data
end
on.failure do |error|