1
- require File . expand_path ( File . join ( File . dirname ( __FILE__ ) , %w{ .. spec_helper } ) )
2
-
3
- require 'ovirt_metrics'
4
-
5
1
describe OvirtMetrics ::HostSamplesHistory do
6
2
shared_examples_for "HostSamplesHistory" do
7
3
context "#cpu_usagemhz_rate_average" do
8
4
9
5
it "when host_configuration is nil" do
10
6
host_history = described_class . new ( :host_configuration => nil )
11
- host_history . cpu_usagemhz_rate_average . should == 0
7
+ expect ( host_history . cpu_usagemhz_rate_average ) . to eq ( 0 )
12
8
end
13
9
14
10
context "when host_configuration exists" do
15
11
before ( :each ) { @host_configuration = OvirtMetrics ::HostConfiguration . new }
16
12
it "and speed_in_mhz and number_of_cores is nil" do
17
13
host_history = described_class . new ( :host_configuration => @host_configuration )
18
- host_history . cpu_usagemhz_rate_average . should == 0
14
+ expect ( host_history . cpu_usagemhz_rate_average ) . to eq ( 0 )
19
15
end
20
16
21
17
it "and speed_in_mhz is nil and number_of_cores is numeric" do
22
18
host_history = described_class . new ( :host_configuration => @host_configuration )
23
- @host_configuration . stub ( :number_of_cores => 1 )
24
- host_history . cpu_usagemhz_rate_average . should == 0
19
+ allow ( @host_configuration ) . to receive_messages ( :number_of_cores => 1 )
20
+ expect ( host_history . cpu_usagemhz_rate_average ) . to eq ( 0 )
25
21
end
26
22
27
23
it "and speed_in_mhz is numeric and number_of_cores is nil" do
28
24
host_history = described_class . new ( :host_configuration => @host_configuration )
29
- @host_configuration . stub ( :speed_in_mhz => 2048.0 )
30
- host_history . cpu_usagemhz_rate_average . should == 0
25
+ allow ( @host_configuration ) . to receive_messages ( :speed_in_mhz => 2048.0 )
26
+ expect ( host_history . cpu_usagemhz_rate_average ) . to eq ( 0 )
31
27
end
32
28
33
29
it "and speed_in_mhz is numeric and number_of_cores is numeric" do
34
- host_configuration = OvirtMetrics ::HostConfiguration . new
35
- @host_configuration . stub ( :speed_in_mhz => 2048.0 )
36
- @host_configuration . stub ( :number_of_cores => 2 )
30
+ allow ( @host_configuration ) . to receive_messages ( :speed_in_mhz => 2048.0 )
31
+ allow ( @host_configuration ) . to receive_messages ( :number_of_cores => 2 )
37
32
38
33
host_history = described_class . new (
39
34
:cpu_usage_percent => 50 ,
40
35
:host_configuration => @host_configuration
41
36
)
42
- host_history . cpu_usagemhz_rate_average . should == 2048.0
37
+ expect ( host_history . cpu_usagemhz_rate_average ) . to eq ( 2048.0 )
43
38
end
44
39
end
45
40
end
54
49
before ( :each ) { load_rhev_31 }
55
50
it_should_behave_like "HostSamplesHistory"
56
51
end
57
- end
52
+ end
0 commit comments