configuration_client_test.rb
1.71 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
require "test_helper"
class ConfigurationClientTest < ActiveSupport::TestCase
def setup
@port = mock
Kalibro::Client::Port.expects(:new).with('Configuration').returns(@port)
@client = Kalibro::Client::ConfigurationClient.new
end
should 'save configuration' do
configuration = ConfigurationTest.kalibro_configuration
@port.expects(:request).with(:save_configuration, {:configuration => configuration.to_hash})
@client.save(configuration)
end
should 'get configuration names (zero)' do
@port.expects(:request).with(:get_configuration_names).returns({})
assert_equal [], @client.configuration_names
end
should 'get configuration names (one)' do
name = 'Kalibro for Java'
@port.expects(:request).with(:get_configuration_names).returns({:configuration_name => name})
assert_equal [name], @client.configuration_names
end
should 'get configuration names' do
names = ['Kalibro for Java', 'ConfigurationClientTest configuration']
@port.expects(:request).with(:get_configuration_names).returns({:configuration_name => names})
assert_equal names, @client.configuration_names
end
should 'get configuration by name' do
configuration = ConfigurationTest.kalibro_configuration
request_body = {:configuration_name => configuration.name}
response_hash = {:configuration => configuration.to_hash}
@port.expects(:request).with(:get_configuration, request_body).returns(response_hash)
assert_equal configuration, @client.configuration(configuration.name)
end
should 'remove configuration by name' do
name = 'ConfigurationClientTest'
@port.expects(:request).with(:remove_configuration, {:configuration_name => name})
@client.remove(name)
end
end