kalibro_gatekeeper_client 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.rspec +2 -0
- data/.ruby-version +1 -1
- data/.travis.yml +8 -6
- data/features/step_definitions/base_tool_steps.rb +5 -5
- data/features/step_definitions/configuration_steps.rb +5 -5
- data/features/step_definitions/metric_configuration_steps.rb +5 -3
- data/features/step_definitions/metric_result_steps.rb +6 -6
- data/features/step_definitions/module_result_steps.rb +5 -5
- data/features/step_definitions/processing_steps.rb +6 -6
- data/features/step_definitions/project_steps.rb +4 -4
- data/features/step_definitions/range_steps.rb +11 -11
- data/features/step_definitions/reading_group_steps.rb +2 -2
- data/features/step_definitions/reading_steps.rb +6 -3
- data/features/step_definitions/repository_steps.rb +7 -7
- data/kalibro_gatekeeper_client.gemspec +2 -2
- data/lib/kalibro_gatekeeper_client/entities/metric.rb +5 -1
- data/lib/kalibro_gatekeeper_client/version.rb +1 -1
- data/spec/entities/base_tool_spec.rb +13 -13
- data/spec/entities/configuration_spec.rb +5 -5
- data/spec/entities/date_metric_result_spec.rb +5 -5
- data/spec/entities/date_module_result_spec.rb +5 -5
- data/spec/entities/metric_configuration_snapshot_spec.rb +10 -10
- data/spec/entities/metric_configuration_spec.rb +14 -14
- data/spec/entities/metric_result_spec.rb +16 -16
- data/spec/entities/metric_spec.rb +22 -4
- data/spec/entities/model_spec.rb +33 -33
- data/spec/entities/module_result_spec.rb +14 -14
- data/spec/entities/process_time_spec.rb +2 -2
- data/spec/entities/processing_spec.rb +23 -23
- data/spec/entities/project_spec.rb +5 -5
- data/spec/entities/range_snapshot_spec.rb +5 -5
- data/spec/entities/range_spec.rb +21 -21
- data/spec/entities/reading_group_spec.rb +5 -5
- data/spec/entities/reading_spec.rb +11 -11
- data/spec/entities/repository_observer_spec.rb +14 -14
- data/spec/entities/repository_spec.rb +12 -12
- data/spec/entities/stack_trace_element_spec.rb +1 -1
- data/spec/entities/throwable_spec.rb +4 -4
- data/spec/helpers/aggregation_options_spec.rb +1 -1
- data/spec/helpers/hash_converters_spec.rb +10 -10
- data/spec/helpers/xml_converters_spec.rb +5 -5
- data/spec/kalibro_entities_spec.rb +9 -9
- data/spec/spec_helper.rb +61 -6
- metadata +7 -6
@@ -20,7 +20,7 @@ describe KalibroGatekeeperClient::Entities::Configuration do
|
|
20
20
|
describe 'id=' do
|
21
21
|
it 'should set the value of the attribute id as an Integer' do
|
22
22
|
subject.id = "42"
|
23
|
-
subject.id.
|
23
|
+
expect(subject.id).to eq(42)
|
24
24
|
end
|
25
25
|
end
|
26
26
|
|
@@ -34,7 +34,7 @@ describe KalibroGatekeeperClient::Entities::Configuration do
|
|
34
34
|
end
|
35
35
|
|
36
36
|
it 'should return nil' do
|
37
|
-
KalibroGatekeeperClient::Entities::Configuration.all.
|
37
|
+
expect(KalibroGatekeeperClient::Entities::Configuration.all).to be_empty
|
38
38
|
end
|
39
39
|
end
|
40
40
|
|
@@ -52,9 +52,9 @@ describe KalibroGatekeeperClient::Entities::Configuration do
|
|
52
52
|
it 'should return the two elements' do
|
53
53
|
configurations = KalibroGatekeeperClient::Entities::Configuration.all
|
54
54
|
|
55
|
-
configurations.size.
|
56
|
-
configurations.first.name.
|
57
|
-
configurations.last.name.
|
55
|
+
expect(configurations.size).to eq(2)
|
56
|
+
expect(configurations.first.name).to eq(configuration.name)
|
57
|
+
expect(configurations.last.name).to eq(another_configuration.name)
|
58
58
|
end
|
59
59
|
end
|
60
60
|
end
|
@@ -22,8 +22,8 @@ describe KalibroGatekeeperClient::Entities::DateMetricResult do
|
|
22
22
|
it 'should set the date and convert it to DateTime' do
|
23
23
|
subject.date = "21/12/1995" # Ruby's first publication
|
24
24
|
|
25
|
-
subject.date.
|
26
|
-
subject.date.
|
25
|
+
expect(subject.date).to be_a(DateTime)
|
26
|
+
expect(subject.date).to eq(DateTime.parse("21/12/1995"))
|
27
27
|
end
|
28
28
|
end
|
29
29
|
|
@@ -31,7 +31,7 @@ describe KalibroGatekeeperClient::Entities::DateMetricResult do
|
|
31
31
|
it 'should just set the value' do
|
32
32
|
subject.date = :something_else
|
33
33
|
|
34
|
-
subject.date.
|
34
|
+
expect(subject.date).to eq(:something_else)
|
35
35
|
end
|
36
36
|
end
|
37
37
|
end
|
@@ -48,7 +48,7 @@ describe KalibroGatekeeperClient::Entities::DateMetricResult do
|
|
48
48
|
|
49
49
|
it 'should set the metric_result with the given one' do
|
50
50
|
subject.metric_result = metric_result.to_hash
|
51
|
-
subject.metric_result.
|
51
|
+
expect(subject.metric_result).to eq(metric_result)
|
52
52
|
end
|
53
53
|
end
|
54
54
|
|
@@ -56,7 +56,7 @@ describe KalibroGatekeeperClient::Entities::DateMetricResult do
|
|
56
56
|
subject { FactoryGirl.build(:date_metric_result) }
|
57
57
|
|
58
58
|
it 'should return the metric result value' do
|
59
|
-
subject.result.
|
59
|
+
expect(subject.result).to eq(10)
|
60
60
|
end
|
61
61
|
end
|
62
62
|
end
|
@@ -22,8 +22,8 @@ describe KalibroGatekeeperClient::Entities::DateModuleResult do
|
|
22
22
|
it 'should set the date and convert it to DateTime' do
|
23
23
|
subject.date = "21/12/1995" # Ruby's first publication
|
24
24
|
|
25
|
-
subject.date.
|
26
|
-
subject.date.
|
25
|
+
expect(subject.date).to be_a(DateTime)
|
26
|
+
expect(subject.date).to eq(DateTime.parse("21/12/1995"))
|
27
27
|
end
|
28
28
|
end
|
29
29
|
|
@@ -31,7 +31,7 @@ describe KalibroGatekeeperClient::Entities::DateModuleResult do
|
|
31
31
|
it 'should just set the value' do
|
32
32
|
subject.date = :something_else
|
33
33
|
|
34
|
-
subject.date.
|
34
|
+
expect(subject.date).to eq(:something_else)
|
35
35
|
end
|
36
36
|
end
|
37
37
|
end
|
@@ -47,7 +47,7 @@ describe KalibroGatekeeperClient::Entities::DateModuleResult do
|
|
47
47
|
|
48
48
|
it 'should set the module_result with the given one' do
|
49
49
|
subject.module_result = module_result.to_hash
|
50
|
-
subject.module_result.
|
50
|
+
expect(subject.module_result).to eq(module_result)
|
51
51
|
end
|
52
52
|
end
|
53
53
|
|
@@ -55,7 +55,7 @@ describe KalibroGatekeeperClient::Entities::DateModuleResult do
|
|
55
55
|
subject {FactoryGirl.build(:date_module_result)}
|
56
56
|
|
57
57
|
it 'should return the module_result grade' do
|
58
|
-
subject.result.
|
58
|
+
expect(subject.result).to eq(10)
|
59
59
|
end
|
60
60
|
end
|
61
61
|
end
|
@@ -20,7 +20,7 @@ describe KalibroGatekeeperClient::Entities::MetricConfigurationSnapshot do
|
|
20
20
|
describe 'weight=' do
|
21
21
|
it 'should set the value of the attribute weight' do
|
22
22
|
subject.weight = "0.6"
|
23
|
-
subject.weight.
|
23
|
+
expect(subject.weight).to eq(0.6)
|
24
24
|
end
|
25
25
|
end
|
26
26
|
|
@@ -30,7 +30,7 @@ describe KalibroGatekeeperClient::Entities::MetricConfigurationSnapshot do
|
|
30
30
|
context 'when it is not a hash' do
|
31
31
|
it 'should set the value of the attribute metric' do
|
32
32
|
subject.metric = metric
|
33
|
-
subject.metric.
|
33
|
+
expect(subject.metric).to eq(metric)
|
34
34
|
end
|
35
35
|
end
|
36
36
|
|
@@ -45,7 +45,7 @@ describe KalibroGatekeeperClient::Entities::MetricConfigurationSnapshot do
|
|
45
45
|
|
46
46
|
it 'should set the value of the attribute metric as an object' do
|
47
47
|
subject.metric = metric.to_hash
|
48
|
-
subject.metric.
|
48
|
+
expect(subject.metric).to eq(metric)
|
49
49
|
end
|
50
50
|
end
|
51
51
|
end
|
@@ -64,7 +64,7 @@ describe KalibroGatekeeperClient::Entities::MetricConfigurationSnapshot do
|
|
64
64
|
|
65
65
|
it 'should set the value of the attribute range' do
|
66
66
|
subject.range = range_snapshot_hash
|
67
|
-
subject.range.
|
67
|
+
expect(subject.range).to eq([range_snapshot])
|
68
68
|
end
|
69
69
|
end
|
70
70
|
|
@@ -79,9 +79,9 @@ describe KalibroGatekeeperClient::Entities::MetricConfigurationSnapshot do
|
|
79
79
|
it 'should set the value of the attribute range' do
|
80
80
|
subject.range = [range_snapshot_hash, range_snapshot_hash]
|
81
81
|
ranges = subject.range
|
82
|
-
ranges.size.
|
83
|
-
ranges.first.
|
84
|
-
ranges.last.
|
82
|
+
expect(ranges.size).to eq(2)
|
83
|
+
expect(ranges.first).to eq (range_snapshot)
|
84
|
+
expect(ranges.last).to eq (range_snapshot)
|
85
85
|
end
|
86
86
|
end
|
87
87
|
end
|
@@ -90,7 +90,7 @@ describe KalibroGatekeeperClient::Entities::MetricConfigurationSnapshot do
|
|
90
90
|
subject { FactoryGirl.build(:metric_configuration_snapshot) }
|
91
91
|
|
92
92
|
it 'should return the value of the range attribute' do
|
93
|
-
subject.range_snapshot.
|
93
|
+
expect(subject.range_snapshot).to eq(subject.range)
|
94
94
|
end
|
95
95
|
end
|
96
96
|
|
@@ -99,8 +99,8 @@ describe KalibroGatekeeperClient::Entities::MetricConfigurationSnapshot do
|
|
99
99
|
|
100
100
|
it 'should override the default to_hash method' do
|
101
101
|
hash = subject.to_hash
|
102
|
-
hash[:attributes!][:range].
|
103
|
-
|
102
|
+
expect(hash[:attributes!][:range]).
|
103
|
+
to eq({'xmlns:xsi'=> 'http://www.w3.org/2001/XMLSchema-instance',
|
104
104
|
'xsi:type' => 'kalibro:rangeSnapshotXml' })
|
105
105
|
end
|
106
106
|
end
|
@@ -20,14 +20,14 @@ describe KalibroGatekeeperClient::Entities::MetricConfiguration do
|
|
20
20
|
describe 'id=' do
|
21
21
|
it 'should set the id as an Integer' do
|
22
22
|
subject.id = "42"
|
23
|
-
subject.id.
|
23
|
+
expect(subject.id).to eq(42)
|
24
24
|
end
|
25
25
|
end
|
26
26
|
|
27
27
|
describe 'reading_group_id=' do
|
28
28
|
it 'should set the reading group id' do
|
29
29
|
subject.reading_group_id = "1"
|
30
|
-
subject.reading_group_id.
|
30
|
+
expect(subject.reading_group_id).to eq(1)
|
31
31
|
end
|
32
32
|
end
|
33
33
|
|
@@ -43,14 +43,14 @@ describe KalibroGatekeeperClient::Entities::MetricConfiguration do
|
|
43
43
|
|
44
44
|
it 'should convert the argument and set the metric' do
|
45
45
|
subject.metric = metric.to_hash
|
46
|
-
subject.metric.
|
46
|
+
expect(subject.metric).to eq(metric)
|
47
47
|
end
|
48
48
|
end
|
49
49
|
|
50
50
|
describe 'weight=' do
|
51
51
|
it 'should set the weight' do
|
52
52
|
subject.weight = "10"
|
53
|
-
subject.weight.
|
53
|
+
expect(subject.weight).to eq(10)
|
54
54
|
end
|
55
55
|
end
|
56
56
|
|
@@ -65,7 +65,7 @@ describe KalibroGatekeeperClient::Entities::MetricConfiguration do
|
|
65
65
|
|
66
66
|
it 'should set the attributes and save' do
|
67
67
|
subject.update_attributes(metric_configuration.to_hash)
|
68
|
-
subject.code.
|
68
|
+
expect(subject.code).to eq(metric_configuration.code)
|
69
69
|
end
|
70
70
|
end
|
71
71
|
|
@@ -73,7 +73,7 @@ describe KalibroGatekeeperClient::Entities::MetricConfiguration do
|
|
73
73
|
subject {FactoryGirl.build(:metric_configuration)}
|
74
74
|
|
75
75
|
it 'should not include the configuration_id' do
|
76
|
-
subject.to_hash[:configuration_id].
|
76
|
+
expect(subject.to_hash[:configuration_id]).to be_nil
|
77
77
|
end
|
78
78
|
end
|
79
79
|
|
@@ -91,8 +91,8 @@ describe KalibroGatekeeperClient::Entities::MetricConfiguration do
|
|
91
91
|
it 'should return a array with a metric configuration' do
|
92
92
|
metric_configurations = KalibroGatekeeperClient::Entities::MetricConfiguration.metric_configurations_of(configuration.id)
|
93
93
|
|
94
|
-
metric_configurations.
|
95
|
-
metric_configurations.first.id.
|
94
|
+
expect(metric_configurations).to be_an(Array)
|
95
|
+
expect(metric_configurations.first.id).to eq(metric_configuration.id)
|
96
96
|
end
|
97
97
|
end
|
98
98
|
|
@@ -108,8 +108,8 @@ describe KalibroGatekeeperClient::Entities::MetricConfiguration do
|
|
108
108
|
end
|
109
109
|
|
110
110
|
it 'should make a request to save model with id and return true without errors' do
|
111
|
-
subject.save.
|
112
|
-
subject.kalibro_errors.
|
111
|
+
expect(subject.save).to be_truthy
|
112
|
+
expect(subject.kalibro_errors).to be_empty
|
113
113
|
end
|
114
114
|
end
|
115
115
|
|
@@ -122,7 +122,7 @@ describe KalibroGatekeeperClient::Entities::MetricConfiguration do
|
|
122
122
|
end
|
123
123
|
|
124
124
|
it 'should return true' do
|
125
|
-
KalibroGatekeeperClient::Entities::MetricConfiguration.exists?(subject.id).
|
125
|
+
expect(KalibroGatekeeperClient::Entities::MetricConfiguration.exists?(subject.id)).to be_truthy
|
126
126
|
end
|
127
127
|
end
|
128
128
|
|
@@ -132,7 +132,7 @@ describe KalibroGatekeeperClient::Entities::MetricConfiguration do
|
|
132
132
|
end
|
133
133
|
|
134
134
|
it 'should return false' do
|
135
|
-
KalibroGatekeeperClient::Entities::MetricConfiguration.exists?(subject.id).
|
135
|
+
expect(KalibroGatekeeperClient::Entities::MetricConfiguration.exists?(subject.id)).to be_falsey
|
136
136
|
end
|
137
137
|
end
|
138
138
|
end
|
@@ -149,8 +149,8 @@ describe KalibroGatekeeperClient::Entities::MetricConfiguration do
|
|
149
149
|
end
|
150
150
|
|
151
151
|
it 'should return the metric_configuration' do
|
152
|
-
KalibroGatekeeperClient::Entities::MetricConfiguration.find(metric_configuration.id).
|
153
|
-
id.
|
152
|
+
expect(KalibroGatekeeperClient::Entities::MetricConfiguration.find(metric_configuration.id).
|
153
|
+
id).to eq(metric_configuration.id)
|
154
154
|
end
|
155
155
|
end
|
156
156
|
|
@@ -24,7 +24,7 @@ describe KalibroGatekeeperClient::Entities::MetricResult do
|
|
24
24
|
context 'with value NaN' do
|
25
25
|
it 'should set the value with aggregated_value' do
|
26
26
|
metric_result = KalibroGatekeeperClient::Entities::MetricResult.new( FactoryGirl.attributes_for(:metric_result, {value: "NaN", aggregated_value: 1.6}) )
|
27
|
-
metric_result.value.
|
27
|
+
expect(metric_result.value).to eq(1.6)
|
28
28
|
end
|
29
29
|
end
|
30
30
|
end
|
@@ -32,35 +32,35 @@ describe KalibroGatekeeperClient::Entities::MetricResult do
|
|
32
32
|
describe 'id=' do
|
33
33
|
it 'should set the value of the attribute id' do
|
34
34
|
subject.id = 42
|
35
|
-
subject.id.
|
35
|
+
expect(subject.id).to eq(42)
|
36
36
|
end
|
37
37
|
end
|
38
38
|
|
39
39
|
describe 'configuration=' do
|
40
40
|
it 'should set the configuration' do
|
41
41
|
subject.configuration = metric_configuration_snapshot.to_hash
|
42
|
-
subject.configuration.code.
|
42
|
+
expect(subject.configuration.code).to eq(metric_configuration_snapshot.code)
|
43
43
|
end
|
44
44
|
end
|
45
45
|
|
46
46
|
describe 'metric_configuration_snapshot' do
|
47
47
|
it 'should be an alias to configuration' do
|
48
48
|
subject.configuration = metric_configuration_snapshot.to_hash
|
49
|
-
subject.metric_configuration_snapshot.code.
|
49
|
+
expect(subject.metric_configuration_snapshot.code).to eq(metric_configuration_snapshot.code)
|
50
50
|
end
|
51
51
|
end
|
52
52
|
|
53
53
|
describe 'value=' do
|
54
54
|
it 'should set the value of the attribute value' do
|
55
55
|
subject.value = 42
|
56
|
-
subject.value.
|
56
|
+
expect(subject.value).to eq(42)
|
57
57
|
end
|
58
58
|
end
|
59
59
|
|
60
60
|
describe 'aggregated_value=' do
|
61
61
|
it 'should set the value of the attribute aggregated_value' do
|
62
62
|
subject.aggregated_value = 42
|
63
|
-
subject.aggregated_value.
|
63
|
+
expect(subject.aggregated_value).to eq(42)
|
64
64
|
end
|
65
65
|
end
|
66
66
|
|
@@ -74,7 +74,7 @@ describe KalibroGatekeeperClient::Entities::MetricResult do
|
|
74
74
|
end
|
75
75
|
|
76
76
|
it 'should return an unitary list with the descendant result' do
|
77
|
-
subject.descendant_results.
|
77
|
+
expect(subject.descendant_results).to eq([13.3])
|
78
78
|
end
|
79
79
|
end
|
80
80
|
|
@@ -87,7 +87,7 @@ describe KalibroGatekeeperClient::Entities::MetricResult do
|
|
87
87
|
end
|
88
88
|
|
89
89
|
it 'should return an empty list' do
|
90
|
-
subject.descendant_results.
|
90
|
+
expect(subject.descendant_results).to eq([])
|
91
91
|
end
|
92
92
|
end
|
93
93
|
end
|
@@ -102,7 +102,7 @@ describe KalibroGatekeeperClient::Entities::MetricResult do
|
|
102
102
|
end
|
103
103
|
|
104
104
|
it 'should return an unitary list with the metric result' do
|
105
|
-
KalibroGatekeeperClient::Entities::MetricResult.metric_results_of(123).first.value.
|
105
|
+
expect(KalibroGatekeeperClient::Entities::MetricResult.metric_results_of(123).first.value).to eq(subject.value)
|
106
106
|
end
|
107
107
|
end
|
108
108
|
|
@@ -115,7 +115,7 @@ describe KalibroGatekeeperClient::Entities::MetricResult do
|
|
115
115
|
end
|
116
116
|
|
117
117
|
it 'should return an empty list' do
|
118
|
-
KalibroGatekeeperClient::Entities::MetricResult.metric_results_of(42).
|
118
|
+
expect(KalibroGatekeeperClient::Entities::MetricResult.metric_results_of(42)).to eq([])
|
119
119
|
end
|
120
120
|
end
|
121
121
|
|
@@ -129,7 +129,7 @@ describe KalibroGatekeeperClient::Entities::MetricResult do
|
|
129
129
|
end
|
130
130
|
|
131
131
|
it 'should return a list with the descendant results' do
|
132
|
-
metric_results.first.value.
|
132
|
+
expect(metric_results.first.value).to eq(subject.value)
|
133
133
|
end
|
134
134
|
end
|
135
135
|
end
|
@@ -147,7 +147,7 @@ describe KalibroGatekeeperClient::Entities::MetricResult do
|
|
147
147
|
end
|
148
148
|
|
149
149
|
it 'should return an empty list' do
|
150
|
-
KalibroGatekeeperClient::Entities::MetricResult.history_of(metric.name, module_result.id).
|
150
|
+
expect(KalibroGatekeeperClient::Entities::MetricResult.history_of(metric.name, module_result.id)).to eq([])
|
151
151
|
end
|
152
152
|
end
|
153
153
|
|
@@ -162,8 +162,8 @@ describe KalibroGatekeeperClient::Entities::MetricResult do
|
|
162
162
|
end
|
163
163
|
|
164
164
|
it 'should return the date metric result as an object into a list' do
|
165
|
-
KalibroGatekeeperClient::Entities::MetricResult.history_of(metric.name, module_result.id).
|
166
|
-
first.metric_result.id.
|
165
|
+
expect(KalibroGatekeeperClient::Entities::MetricResult.history_of(metric.name, module_result.id).
|
166
|
+
first.metric_result.id).to eq(subject.id)
|
167
167
|
end
|
168
168
|
end
|
169
169
|
|
@@ -180,8 +180,8 @@ describe KalibroGatekeeperClient::Entities::MetricResult do
|
|
180
180
|
|
181
181
|
it 'should return a list of date metric results as objects' do
|
182
182
|
response = KalibroGatekeeperClient::Entities::MetricResult.history_of(metric.name, module_result.id)
|
183
|
-
response.first.metric_result.id.
|
184
|
-
response.last.metric_result.id.
|
183
|
+
expect(response.first.metric_result.id).to eq(date_metric_result.metric_result.id)
|
184
|
+
expect(response.last.metric_result.id).to eq(another_date_metric_result.metric_result.id)
|
185
185
|
end
|
186
186
|
end
|
187
187
|
end
|
@@ -5,7 +5,7 @@
|
|
5
5
|
# it under the terms of the GNU General Public License as published by
|
6
6
|
# the Free Software Foundation, either version 3 of the License, or
|
7
7
|
# (at your option) any later version.
|
8
|
-
#
|
8
|
+
#
|
9
9
|
# This program is distributed in the hope that it will be useful,
|
10
10
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
11
11
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
@@ -21,14 +21,14 @@ describe KalibroGatekeeperClient::Entities::Metric do
|
|
21
21
|
subject { FactoryGirl.build(:metric) }
|
22
22
|
|
23
23
|
it 'should return the value of the language attribute' do
|
24
|
-
subject.languages.
|
24
|
+
expect(subject.languages).to eq(["C", "CPP", "JAVA"])
|
25
25
|
end
|
26
26
|
end
|
27
27
|
|
28
28
|
describe 'languages=' do
|
29
29
|
it 'should set the value of the attribute language' do
|
30
30
|
subject.languages = ["Java", "C"]
|
31
|
-
subject.languages.
|
31
|
+
expect(subject.languages).to eq(["Java", "C"])
|
32
32
|
end
|
33
33
|
end
|
34
34
|
|
@@ -41,7 +41,25 @@ describe KalibroGatekeeperClient::Entities::Metric do
|
|
41
41
|
|
42
42
|
it 'should convert the value to an array of objects' do
|
43
43
|
subject.language = "Java"
|
44
|
-
subject.languages.
|
44
|
+
expect(subject.languages).to eq(["Java"])
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
describe 'compound' do
|
49
|
+
context "when it is a supported String" do
|
50
|
+
subject { FactoryGirl.build(:metric, compound: "false") }
|
51
|
+
|
52
|
+
it 'is expected to return a Boolean' do
|
53
|
+
expect(subject.compound).to be_falsey
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
context "when it is a unsupported String" do
|
58
|
+
subject { FactoryGirl.build(:metric, compound: "motaboolea") }
|
59
|
+
|
60
|
+
it 'is expected to raise a Error' do
|
61
|
+
expect {subject.compound}.to raise_error(ArgumentError)
|
62
|
+
end
|
45
63
|
end
|
46
64
|
end
|
47
65
|
end
|
data/spec/entities/model_spec.rb
CHANGED
@@ -22,17 +22,17 @@ describe KalibroGatekeeperClient::Entities::Model do
|
|
22
22
|
describe 'new' do
|
23
23
|
it 'should create a model from an empty hash' do
|
24
24
|
subject = KalibroGatekeeperClient::Entities::Model.new {}
|
25
|
-
subject.kalibro_errors.
|
25
|
+
expect(subject.kalibro_errors).to eq([])
|
26
26
|
end
|
27
27
|
end
|
28
28
|
|
29
29
|
describe 'class_name' do
|
30
30
|
it 'should be a String' do
|
31
|
-
subject.class.class_name.
|
31
|
+
expect(subject.class.class_name).to be_a(String)
|
32
32
|
end
|
33
33
|
|
34
34
|
it 'should return Model' do
|
35
|
-
subject.class.class_name.
|
35
|
+
expect(subject.class.class_name).to eq('Model')
|
36
36
|
end
|
37
37
|
end
|
38
38
|
|
@@ -40,13 +40,13 @@ describe KalibroGatekeeperClient::Entities::Model do
|
|
40
40
|
it 'should return the class_name' do
|
41
41
|
endpoint = 'tests'
|
42
42
|
KalibroGatekeeperClient::Entities::Model.expects(:class_name).returns(endpoint)
|
43
|
-
KalibroGatekeeperClient::Entities::Model.endpoint.
|
43
|
+
expect(KalibroGatekeeperClient::Entities::Model.endpoint).to eq(endpoint)
|
44
44
|
end
|
45
45
|
end
|
46
46
|
|
47
47
|
describe 'client' do
|
48
48
|
it 'returns a Faraday::Connection' do
|
49
|
-
KalibroGatekeeperClient::Entities::Model.client.
|
49
|
+
expect(KalibroGatekeeperClient::Entities::Model.client).to be_a(Faraday::Connection)
|
50
50
|
end
|
51
51
|
end
|
52
52
|
|
@@ -65,8 +65,8 @@ describe KalibroGatekeeperClient::Entities::Model do
|
|
65
65
|
expects(:client).
|
66
66
|
with(any_parameters).
|
67
67
|
returns(client)
|
68
|
-
KalibroGatekeeperClient::Entities::Model.
|
69
|
-
request('exists', {id: 1})[:exists].
|
68
|
+
expect(KalibroGatekeeperClient::Entities::Model.
|
69
|
+
request('exists', {id: 1})[:exists]).to eq(false)
|
70
70
|
end
|
71
71
|
end
|
72
72
|
|
@@ -82,36 +82,36 @@ describe KalibroGatekeeperClient::Entities::Model do
|
|
82
82
|
expects(:client).
|
83
83
|
with(any_parameters).
|
84
84
|
returns(client)
|
85
|
-
Child.
|
86
|
-
request('exists', {id: 1})[:exists].
|
85
|
+
expect(Child.
|
86
|
+
request('exists', {id: 1})[:exists]).to eq(false)
|
87
87
|
end
|
88
88
|
end
|
89
89
|
end
|
90
90
|
|
91
91
|
describe 'to_hash' do
|
92
92
|
it 'should return an empty hash' do
|
93
|
-
subject.to_hash.
|
93
|
+
expect(subject.to_hash).to be_empty
|
94
94
|
end
|
95
95
|
end
|
96
96
|
|
97
97
|
describe 'to_object' do
|
98
98
|
it 'should return an Object with an empty hash' do
|
99
|
-
KalibroGatekeeperClient::Entities::Model.to_object({}).
|
99
|
+
expect(KalibroGatekeeperClient::Entities::Model.to_object({})).to eq(FactoryGirl.build(:model))
|
100
100
|
end
|
101
101
|
|
102
102
|
it "should remain an object if it isn't a Hash" do
|
103
|
-
KalibroGatekeeperClient::Entities::Model.to_object(Object.new).
|
103
|
+
expect(KalibroGatekeeperClient::Entities::Model.to_object(Object.new)).to be_an(Object)
|
104
104
|
end
|
105
105
|
end
|
106
106
|
|
107
107
|
describe 'to_objects_array' do
|
108
108
|
it 'should convert [{}] to [Model]' do
|
109
|
-
KalibroGatekeeperClient::Entities::Model.to_objects_array({}).
|
109
|
+
expect(KalibroGatekeeperClient::Entities::Model.to_objects_array({})).to eq([FactoryGirl.build(:model)])
|
110
110
|
end
|
111
111
|
|
112
112
|
it 'should remain an array if it already is one' do
|
113
113
|
object = Object.new
|
114
|
-
KalibroGatekeeperClient::Entities::Model.to_objects_array([object]).
|
114
|
+
expect(KalibroGatekeeperClient::Entities::Model.to_objects_array([object])).to eq([object])
|
115
115
|
end
|
116
116
|
end
|
117
117
|
|
@@ -124,8 +124,8 @@ describe KalibroGatekeeperClient::Entities::Model do
|
|
124
124
|
|
125
125
|
context "when it doesn't have the method id=" do
|
126
126
|
it 'should make a request to save model with id returning false and an error' do
|
127
|
-
subject.save.
|
128
|
-
subject.kalibro_errors[0].
|
127
|
+
expect(subject.save).to be(false)
|
128
|
+
expect(subject.kalibro_errors[0]).to be_a(NoMethodError)
|
129
129
|
end
|
130
130
|
end
|
131
131
|
|
@@ -138,8 +138,8 @@ describe KalibroGatekeeperClient::Entities::Model do
|
|
138
138
|
end
|
139
139
|
|
140
140
|
it 'should make a request to save model with id and return true without errors' do
|
141
|
-
subject.save.
|
142
|
-
subject.kalibro_errors.
|
141
|
+
expect(subject.save).to be(true)
|
142
|
+
expect(subject.kalibro_errors).to be_empty
|
143
143
|
end
|
144
144
|
end
|
145
145
|
end
|
@@ -163,14 +163,14 @@ describe KalibroGatekeeperClient::Entities::Model do
|
|
163
163
|
end
|
164
164
|
|
165
165
|
it 'should instantiate and save the model' do
|
166
|
-
(KalibroGatekeeperClient::Entities::Model.create {}).
|
166
|
+
expect(KalibroGatekeeperClient::Entities::Model.create {}).to eq(subject)
|
167
167
|
end
|
168
168
|
end
|
169
169
|
|
170
170
|
describe '==' do
|
171
171
|
context 'comparing objects from different classes' do
|
172
172
|
it 'should return false' do
|
173
|
-
subject.
|
173
|
+
expect(subject).not_to eq(Object.new)
|
174
174
|
end
|
175
175
|
end
|
176
176
|
|
@@ -183,13 +183,13 @@ describe KalibroGatekeeperClient::Entities::Model do
|
|
183
183
|
end
|
184
184
|
|
185
185
|
it 'should return false' do
|
186
|
-
subject.
|
186
|
+
expect(subject).not_to eq(another_model)
|
187
187
|
end
|
188
188
|
end
|
189
189
|
|
190
190
|
context 'with two empty models' do
|
191
191
|
it 'should return true' do
|
192
|
-
subject.
|
192
|
+
expect(subject).to eq(FactoryGirl.build(:model))
|
193
193
|
end
|
194
194
|
end
|
195
195
|
end
|
@@ -204,7 +204,7 @@ describe KalibroGatekeeperClient::Entities::Model do
|
|
204
204
|
end
|
205
205
|
|
206
206
|
it 'should return false' do
|
207
|
-
KalibroGatekeeperClient::Entities::Model.exists?(0).
|
207
|
+
expect(KalibroGatekeeperClient::Entities::Model.exists?(0)).to eq(false)
|
208
208
|
end
|
209
209
|
end
|
210
210
|
|
@@ -217,7 +217,7 @@ describe KalibroGatekeeperClient::Entities::Model do
|
|
217
217
|
end
|
218
218
|
|
219
219
|
it 'should return false' do
|
220
|
-
KalibroGatekeeperClient::Entities::Model.exists?(42).
|
220
|
+
expect(KalibroGatekeeperClient::Entities::Model.exists?(42)).to eq(true)
|
221
221
|
end
|
222
222
|
end
|
223
223
|
end
|
@@ -244,7 +244,7 @@ describe KalibroGatekeeperClient::Entities::Model do
|
|
244
244
|
end
|
245
245
|
|
246
246
|
it 'should return an empty model' do
|
247
|
-
KalibroGatekeeperClient::Entities::Model.find(42).
|
247
|
+
expect(KalibroGatekeeperClient::Entities::Model.find(42)).to eq(subject)
|
248
248
|
end
|
249
249
|
end
|
250
250
|
end
|
@@ -260,7 +260,7 @@ describe KalibroGatekeeperClient::Entities::Model do
|
|
260
260
|
|
261
261
|
it 'should remain with the errors array empty' do
|
262
262
|
subject.destroy
|
263
|
-
subject.kalibro_errors.
|
263
|
+
expect(subject.kalibro_errors).to be_empty
|
264
264
|
end
|
265
265
|
end
|
266
266
|
|
@@ -275,7 +275,7 @@ describe KalibroGatekeeperClient::Entities::Model do
|
|
275
275
|
it "should have an exception inside it's errors" do
|
276
276
|
subject.destroy
|
277
277
|
|
278
|
-
subject.kalibro_errors[0].
|
278
|
+
expect(subject.kalibro_errors[0]).to be_an(Exception)
|
279
279
|
end
|
280
280
|
end
|
281
281
|
end
|
@@ -283,13 +283,13 @@ describe KalibroGatekeeperClient::Entities::Model do
|
|
283
283
|
describe 'create_objects_array_from_hash' do
|
284
284
|
context 'with nil' do
|
285
285
|
it 'should return an empty array' do
|
286
|
-
KalibroGatekeeperClient::Entities::Model.create_objects_array_from_hash(nil).
|
286
|
+
expect(KalibroGatekeeperClient::Entities::Model.create_objects_array_from_hash(nil)).to eq([])
|
287
287
|
end
|
288
288
|
end
|
289
289
|
|
290
290
|
context 'with a Hash' do
|
291
291
|
it 'should return the correspondent object to the given hash inside of an Array' do
|
292
|
-
KalibroGatekeeperClient::Entities::Model.create_objects_array_from_hash({}).
|
292
|
+
expect(KalibroGatekeeperClient::Entities::Model.create_objects_array_from_hash({})).to eq([subject])
|
293
293
|
end
|
294
294
|
end
|
295
295
|
end
|
@@ -297,25 +297,25 @@ describe KalibroGatekeeperClient::Entities::Model do
|
|
297
297
|
describe 'is_valid?' do
|
298
298
|
context 'with a global var' do
|
299
299
|
it 'should return false' do
|
300
|
-
KalibroGatekeeperClient::Entities::Model.is_valid?('@test').
|
300
|
+
expect(KalibroGatekeeperClient::Entities::Model.is_valid?('@test')).to be_falsey
|
301
301
|
end
|
302
302
|
end
|
303
303
|
|
304
304
|
context 'with the attributes var' do
|
305
305
|
it 'should return false' do
|
306
|
-
KalibroGatekeeperClient::Entities::Model.is_valid?(:attributes!).
|
306
|
+
expect(KalibroGatekeeperClient::Entities::Model.is_valid?(:attributes!)).to be_falsey
|
307
307
|
end
|
308
308
|
end
|
309
309
|
|
310
310
|
context 'with a xsi var' do
|
311
311
|
it 'should return false' do
|
312
|
-
KalibroGatekeeperClient::Entities::Model.is_valid?('test_xsi').
|
312
|
+
expect(KalibroGatekeeperClient::Entities::Model.is_valid?('test_xsi')).to be_falsey
|
313
313
|
end
|
314
314
|
end
|
315
315
|
|
316
316
|
context 'with a valid var' do
|
317
317
|
it 'should return true' do
|
318
|
-
KalibroGatekeeperClient::Entities::Model.is_valid?('test').
|
318
|
+
expect(KalibroGatekeeperClient::Entities::Model.is_valid?('test')).to be_truthy
|
319
319
|
end
|
320
320
|
end
|
321
321
|
end
|