kalibro_gem 0.0.1.rc7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (160) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +19 -0
  3. data/.ruby-gemset +1 -0
  4. data/.ruby-version +1 -0
  5. data/.travis.yml +21 -0
  6. data/AUTHORS +4 -0
  7. data/COPYING +674 -0
  8. data/COPYING.LESSER +165 -0
  9. data/Gemfile +4 -0
  10. data/README.md +77 -0
  11. data/Rakefile +6 -0
  12. data/cucumber.yml +1 -0
  13. data/features/base_tool/all_names.feature +8 -0
  14. data/features/base_tool/find_by_name.feature +12 -0
  15. data/features/configuration/all.feature +10 -0
  16. data/features/metric_configuration/find.feature +18 -0
  17. data/features/metric_configuration/metric_configurations_of.feature +18 -0
  18. data/features/metric_result/descendant_results.feature +19 -0
  19. data/features/metric_result/history_of.feature +20 -0
  20. data/features/metric_result/metric_results_of.feature +19 -0
  21. data/features/module_result/children.feature +18 -0
  22. data/features/module_result/find.feature +15 -0
  23. data/features/module_result/history_of.feature +11 -0
  24. data/features/processing/first_processing_after.feature +18 -0
  25. data/features/processing/first_processing_of.feature +18 -0
  26. data/features/processing/has_processing.feature +18 -0
  27. data/features/processing/has_processing_after.feature +18 -0
  28. data/features/processing/has_processing_before.feature +18 -0
  29. data/features/processing/has_ready_processing.feature +18 -0
  30. data/features/processing/last_processing_before.feature +18 -0
  31. data/features/processing/last_processing_of.feature +18 -0
  32. data/features/processing/last_processing_state_of.feature +18 -0
  33. data/features/processing/last_ready_processing_of.feature +18 -0
  34. data/features/processing/processing_of.feature +32 -0
  35. data/features/processing/processing_with_date_of.feature +32 -0
  36. data/features/project/all.feature +10 -0
  37. data/features/project/creation.feature +9 -0
  38. data/features/project/destroy.feature +10 -0
  39. data/features/project/exists.feature +9 -0
  40. data/features/project/find.feature +10 -0
  41. data/features/range/ranges_of.feature +22 -0
  42. data/features/range/save.feature +32 -0
  43. data/features/reading/find.feature +11 -0
  44. data/features/reading/readings_of.feature +11 -0
  45. data/features/reading_group/all.feature +10 -0
  46. data/features/repository/all.feature +14 -0
  47. data/features/repository/cancel_processing.feature +14 -0
  48. data/features/repository/exists.feature +14 -0
  49. data/features/repository/find.feature +14 -0
  50. data/features/repository/of.feature +15 -0
  51. data/features/repository/process.feature +16 -0
  52. data/features/repository/types.feature +9 -0
  53. data/features/step_definitions/base_tool_steps.rb +28 -0
  54. data/features/step_definitions/configuration_steps.rb +11 -0
  55. data/features/step_definitions/metric_configuration_steps.rb +52 -0
  56. data/features/step_definitions/metric_result_steps.rb +29 -0
  57. data/features/step_definitions/metric_steps.rb +3 -0
  58. data/features/step_definitions/module_result_steps.rb +30 -0
  59. data/features/step_definitions/processing_steps.rb +91 -0
  60. data/features/step_definitions/project_steps.rb +48 -0
  61. data/features/step_definitions/range_steps.rb +41 -0
  62. data/features/step_definitions/reading_group_steps.rb +19 -0
  63. data/features/step_definitions/reading_steps.rb +20 -0
  64. data/features/step_definitions/repository_steps.rb +61 -0
  65. data/features/support/env.rb +25 -0
  66. data/features/support/kalibro_cucumber_helpers.yml.sample +10 -0
  67. data/kalibro_gem.gemspec +48 -0
  68. data/lib/kalibro_gem.rb +61 -0
  69. data/lib/kalibro_gem/entities.rb +37 -0
  70. data/lib/kalibro_gem/entities/base_tool.rb +54 -0
  71. data/lib/kalibro_gem/entities/configuration.rb +33 -0
  72. data/lib/kalibro_gem/entities/date_metric_result.rb +39 -0
  73. data/lib/kalibro_gem/entities/date_module_result.rb +39 -0
  74. data/lib/kalibro_gem/entities/metric.rb +21 -0
  75. data/lib/kalibro_gem/entities/metric_configuration.rb +70 -0
  76. data/lib/kalibro_gem/entities/metric_configuration_snapshot.rb +57 -0
  77. data/lib/kalibro_gem/entities/metric_result.rb +74 -0
  78. data/lib/kalibro_gem/entities/model.rb +162 -0
  79. data/lib/kalibro_gem/entities/module.rb +27 -0
  80. data/lib/kalibro_gem/entities/module_result.rb +77 -0
  81. data/lib/kalibro_gem/entities/process_time.rb +31 -0
  82. data/lib/kalibro_gem/entities/processing.rb +113 -0
  83. data/lib/kalibro_gem/entities/project.rb +34 -0
  84. data/lib/kalibro_gem/entities/range.rb +75 -0
  85. data/lib/kalibro_gem/entities/range_snapshot.rb +37 -0
  86. data/lib/kalibro_gem/entities/reading.rb +51 -0
  87. data/lib/kalibro_gem/entities/reading_group.rb +43 -0
  88. data/lib/kalibro_gem/entities/repository.rb +86 -0
  89. data/lib/kalibro_gem/entities/repository_observer.rb +50 -0
  90. data/lib/kalibro_gem/entities/stack_trace_element.rb +31 -0
  91. data/lib/kalibro_gem/entities/throwable.rb +42 -0
  92. data/lib/kalibro_gem/errors.rb +18 -0
  93. data/lib/kalibro_gem/errors/record_not_found.rb +22 -0
  94. data/lib/kalibro_gem/errors/standard.rb +24 -0
  95. data/lib/kalibro_gem/helpers/aggregation_options.rb +25 -0
  96. data/lib/kalibro_gem/helpers/hash_converters.rb +48 -0
  97. data/lib/kalibro_gem/helpers/request_methods.rb +47 -0
  98. data/lib/kalibro_gem/helpers/xml_converters.rb +20 -0
  99. data/lib/kalibro_gem/kalibro_cucumber_helpers.rb +40 -0
  100. data/lib/kalibro_gem/kalibro_cucumber_helpers/configuration.rb +39 -0
  101. data/lib/kalibro_gem/kalibro_cucumber_helpers/hooks.rb +50 -0
  102. data/lib/kalibro_gem/kalibro_cucumber_helpers/scripts/delete_all_kalibro_entries.sh +23 -0
  103. data/lib/kalibro_gem/kalibro_cucumber_helpers/scripts/prepare_kalibro_query_file.sh +38 -0
  104. data/lib/kalibro_gem/kalibro_cucumber_helpers/scripts/put_kalibro_on_test_mode.sh +35 -0
  105. data/lib/kalibro_gem/kalibro_cucumber_helpers/scripts/return_kalibro_from_test_mode.sh +26 -0
  106. data/lib/kalibro_gem/version.rb +19 -0
  107. data/lib/rake/test_task.rb +57 -0
  108. data/spec/entities/base_tool_spec.rb +168 -0
  109. data/spec/entities/configuration_spec.rb +61 -0
  110. data/spec/entities/date_metric_result_spec.rb +62 -0
  111. data/spec/entities/date_module_result_spec.rb +61 -0
  112. data/spec/entities/metric_configuration_snapshot_spec.rb +107 -0
  113. data/spec/entities/metric_configuration_spec.rb +149 -0
  114. data/spec/entities/metric_result_spec.rb +201 -0
  115. data/spec/entities/metric_spec.rb +47 -0
  116. data/spec/entities/model_spec.rb +275 -0
  117. data/spec/entities/module_result_spec.rb +163 -0
  118. data/spec/entities/process_time_spec.rb +33 -0
  119. data/spec/entities/processing_spec.rb +334 -0
  120. data/spec/entities/project_spec.rb +68 -0
  121. data/spec/entities/range_snapshot_spec.rb +50 -0
  122. data/spec/entities/range_spec.rb +181 -0
  123. data/spec/entities/reading_group_spec.rb +90 -0
  124. data/spec/entities/reading_spec.rb +106 -0
  125. data/spec/entities/repository_observer_spec.rb +123 -0
  126. data/spec/entities/repository_spec.rb +191 -0
  127. data/spec/entities/stack_trace_element_spec.rb +26 -0
  128. data/spec/entities/throwable_spec.rb +51 -0
  129. data/spec/factories/base_tools.rb +31 -0
  130. data/spec/factories/configurations.rb +29 -0
  131. data/spec/factories/date_metric_results.rb +28 -0
  132. data/spec/factories/date_module_results.rb +22 -0
  133. data/spec/factories/metric_configurations.rb +28 -0
  134. data/spec/factories/metric_configurations_snapshot.rb +26 -0
  135. data/spec/factories/metric_results.rb +24 -0
  136. data/spec/factories/metrics.rb +35 -0
  137. data/spec/factories/models.rb +20 -0
  138. data/spec/factories/module_results.rb +33 -0
  139. data/spec/factories/modules.rb +22 -0
  140. data/spec/factories/process_times.rb +27 -0
  141. data/spec/factories/processings.rb +25 -0
  142. data/spec/factories/projects.rb +29 -0
  143. data/spec/factories/ranges.rb +30 -0
  144. data/spec/factories/ranges_snapshot.rb +26 -0
  145. data/spec/factories/reading_groups.rb +23 -0
  146. data/spec/factories/readings.rb +25 -0
  147. data/spec/factories/repositories.rb +34 -0
  148. data/spec/factories/repository_observers.rb +24 -0
  149. data/spec/factories/stack_trace_elements.rb +24 -0
  150. data/spec/factories/throwables.rb +23 -0
  151. data/spec/helpers/aggregation_options_spec.rb +31 -0
  152. data/spec/helpers/hash_converters_spec.rb +111 -0
  153. data/spec/helpers/xml_converters_spec.rb +64 -0
  154. data/spec/kalibro_entities_spec.rb +108 -0
  155. data/spec/savon/fixtures/config.yml +1 -0
  156. data/spec/savon/fixtures/invalid_config.yml +2 -0
  157. data/spec/savon/fixtures/project/does_not_exists.xml +1 -0
  158. data/spec/savon/savon_test_helper.rb +14 -0
  159. data/spec/spec_helper.rb +60 -0
  160. metadata +463 -0
@@ -0,0 +1,15 @@
1
+ Feature: Repositories listing
2
+ In order to be able to visualize repositories
3
+ As a developer
4
+ I want to see all the repository from a given project
5
+
6
+ @kalibro_restart
7
+ Scenario: With existing project repository
8
+ Given I have a project with name "Kalibro"
9
+ And I have a configuration with name "Java"
10
+ And the given project has the following Repositories:
11
+ | name | type | address |
12
+ | "Kalibro" | GIT | https://github.com/mezuro/kalibro.git |
13
+ When I ask for repositories from the given project
14
+ Then I should get a list with the given repository
15
+ And the repositories should contain the project id
@@ -0,0 +1,16 @@
1
+ Feature: Process
2
+ In order to be have repositories
3
+ As a developer
4
+ I want to start the repository processing
5
+
6
+ @kalibro_restart
7
+ Scenario: With one repository
8
+ Given I have a project with name "Kalibro"
9
+ And I have a configuration with name "Java"
10
+ And I have a reading group with name "Group"
11
+ And I have a metric configuration within the given configuration
12
+ And the given project has the following Repositories:
13
+ | name | type | address |
14
+ | Kalibro | GIT | https://github.com/mezuro/kalibro.git |
15
+ When I call the process method for the given repository
16
+ Then I should get success
@@ -0,0 +1,9 @@
1
+ Feature: Types listing
2
+ In order to be able to create repositories
3
+ As a developer
4
+ I want to see all the repository types available
5
+
6
+ @kalibro_restart
7
+ Scenario: listing the types
8
+ When I list types
9
+ Then I should get an array of types
@@ -0,0 +1,28 @@
1
+ When(/^I get all base tool names$/) do
2
+ @base_tool_names = KalibroGem::Entities::BaseTool.all_names
3
+ end
4
+
5
+ When(/^I search base tool Analizo by name$/) do
6
+ @result = KalibroGem::Entities::BaseTool.find_by_name("Analizo")
7
+ end
8
+
9
+ When(/^I search base tool Avalio by name$/) do
10
+ @is_error = false
11
+ begin
12
+ KalibroGem::Entities::BaseTool.find_by_name("Avalio")
13
+ rescue KalibroGem::Errors::RecordNotFound
14
+ @is_error = true
15
+ end
16
+ end
17
+
18
+ Then(/^it should return Checkstyle and Analizo strings inside of an array$/) do
19
+ (@base_tool_names.include?("Checkstyle") && @base_tool_names.include?("Analizo")).should be_true
20
+ end
21
+
22
+ Then(/^I should get Analizo base tool$/) do
23
+ @result.name.should eq "Analizo"
24
+ end
25
+
26
+ Then(/^I should get an error$/) do
27
+ @is_error.should be_true
28
+ end
@@ -0,0 +1,11 @@
1
+ Given(/^I have a configuration with name "(.*?)"$/) do |name|
2
+ @configuration = FactoryGirl.create(:configuration, {name: name, id: nil})
3
+ end
4
+
5
+ When(/^I get all the configurations$/) do
6
+ @all_configurations = KalibroGem::Entities::Configuration.all
7
+ end
8
+
9
+ Then(/^I should get a list with the given configuration$/) do
10
+ @all_configurations.include?(@configuration)
11
+ end
@@ -0,0 +1,52 @@
1
+ Given(/^I have a metric configuration within the given configuration$/) do
2
+ @metric_configuration = FactoryGirl.create(:metric_configuration,
3
+ {id: nil,
4
+ reading_group_id: @reading_group.id,
5
+ configuration_id: @configuration.id})
6
+ end
7
+
8
+ Given(/^I have a metric configuration within the given configuration with the given metric$/) do
9
+ @metric_configuration = FactoryGirl.create(:metric_configuration,
10
+ {id: nil,
11
+ metric: @metric,
12
+ reading_group_id: @reading_group.id,
13
+ configuration_id: @configuration.id})
14
+ end
15
+
16
+ Given(/^I have a loc configuration within the given configuration$/) do
17
+ @metric_configuration = FactoryGirl.create(:metric_configuration,
18
+ {id: nil,
19
+ metric: FactoryGirl.create(:loc),
20
+ reading_group_id: @reading_group.id,
21
+ configuration_id: @configuration.id})
22
+ end
23
+
24
+ When(/^I search a metric configuration with the same id of the given metric configuration$/) do
25
+ @found_metric_configuration = KalibroGem::Entities::MetricConfiguration.find(@metric_configuration.id)
26
+ end
27
+
28
+ When(/^I search an inexistent metric configuration$/) do
29
+ @is_error = false
30
+ inexistent_id = rand(Time.now.to_i)
31
+ begin
32
+ KalibroGem::Entities::MetricConfiguration.find(inexistent_id)
33
+ rescue KalibroGem::Errors::RecordNotFound
34
+ @is_error = true
35
+ end
36
+ end
37
+
38
+ When(/^I request all metric configurations of the given configuration$/) do
39
+ @metric_configurations = KalibroGem::Entities::MetricConfiguration.metric_configurations_of(@configuration.id)
40
+ end
41
+
42
+ Then(/^it should return the same metric configuration as the given one$/) do
43
+ @found_metric_configuration == @metric_configuration
44
+ end
45
+
46
+ Then(/^I should get a list of its metric configurations$/) do
47
+ @metric_configurations == [@metric_configuration]
48
+ end
49
+
50
+ Then(/^I should get an empty list of metric configurations$/) do
51
+ @metric_configurations == []
52
+ end
@@ -0,0 +1,29 @@
1
+ When(/^I call the metric results of method with the results root id of the given processing$/) do
2
+ @response = KalibroGem::Entities::MetricResult.metric_results_of(@response.results_root_id)
3
+ end
4
+
5
+ Given(/^I search a metric result with descendant results for the given metric result$/) do
6
+ first_module_result = KalibroGem::Entities::ModuleResult.find(@response.results_root_id)
7
+
8
+ metric_results = KalibroGem::Entities::MetricResult.metric_results_of(first_module_result.id)
9
+ @response = metric_results.first.descendant_results
10
+ end
11
+
12
+ When(/^I call the history of method with the metric name and the results root id of the given processing$/) do
13
+ @response = KalibroGem::Entities::MetricResult.history_of(@metric.name, @response.results_root_id)
14
+ end
15
+
16
+ Then (/^I should get a Float list$/) do
17
+ @response.should be_a(Array)
18
+ @response.first.should be_a(Float)
19
+ end
20
+
21
+ Then(/^I should get a list of metric results$/) do
22
+ @response.should be_a(Array)
23
+ @response.first.should be_a(KalibroGem::Entities::MetricResult)
24
+ end
25
+
26
+ Then(/^I should get a list of date metric results$/) do
27
+ @response.should be_a(Array)
28
+ @response.first.should be_a(KalibroGem::Entities::DateMetricResult)
29
+ end
@@ -0,0 +1,3 @@
1
+ Given(/^I have a metric with name "(.*?)"$/) do |name|
2
+ @metric = FactoryGirl.create(:metric, {name: name})
3
+ end
@@ -0,0 +1,30 @@
1
+ Given(/^I have a module result$/) do
2
+ Pending
3
+ @module_result = FactoryGirl.create(:module_result)
4
+ end
5
+
6
+ When(/^I ask a module result with the same id of the given module result$/) do
7
+ @found_module_result = KalibroGem::Entities::ModuleResult.find(@module_result.id)
8
+ end
9
+
10
+ When(/^I ask for an inexistent module result$/) do
11
+ @is_error = false
12
+ begin
13
+ KalibroGem::Entities::ModuleResult.find(-1)
14
+ rescue KalibroGem::Errors::RecordNotFound
15
+ @is_error = true
16
+ end
17
+ end
18
+
19
+ Then(/^I should get the given module result$/) do
20
+ @found_module_result == @module_result
21
+ end
22
+
23
+ When(/^I ask for the children of the processing root module result$/) do
24
+ @children = KalibroGem::Entities::ModuleResult.
25
+ find(KalibroGem::Entities::Processing.processing_of(@repository.id).results_root_id)
26
+ end
27
+
28
+ Then(/^I should get a list with the children module results$/) do
29
+ @children.should be_a(KalibroGem::Entities::ModuleResult)
30
+ end
@@ -0,0 +1,91 @@
1
+ Given(/^I wait up to (\d+) seconds$/) do |seconds|
2
+ sleep(seconds.to_i)
3
+ end
4
+
5
+ Given(/^I wait up for a ready processing$/) do
6
+ unless KalibroGem::Entities::Processing.has_ready_processing(@repository.id)
7
+ while(true)
8
+ if KalibroGem::Entities::Processing.has_ready_processing(@repository.id)
9
+ break
10
+ else
11
+ sleep(10)
12
+ end
13
+ end
14
+ end
15
+ end
16
+
17
+ When(/^I call the has_processing for the given repository$/) do
18
+ @response = KalibroGem::Entities::Processing.has_processing(@repository.id)
19
+ end
20
+
21
+ When(/^I call the has_ready_processing for the given repository$/) do
22
+ @response = KalibroGem::Entities::Processing.has_ready_processing(@repository.id)
23
+ end
24
+
25
+ When(/^I call the has_processing_after for the given repository with yerterday's date$/) do
26
+ @response = KalibroGem::Entities::Processing.has_processing_after(@repository.id, DateTime.now - 1)
27
+ end
28
+
29
+ When(/^I call the has_processing_before for the given repository with tomorrows's date$/) do
30
+ @response = KalibroGem::Entities::Processing.has_processing_before(@repository.id, DateTime.now + 1)
31
+ end
32
+
33
+ When(/^I call the last_processing_state_of method for the given repository$/) do
34
+ @response = KalibroGem::Entities::Processing.last_processing_state_of(@repository.id)
35
+ end
36
+
37
+ When(/^I call the last_ready_processing_of method for the given repository$/) do
38
+ @response = KalibroGem::Entities::Processing.last_ready_processing_of(@repository.id)
39
+ end
40
+
41
+ When(/^I call the first_processing_of method for the given repository$/) do
42
+ @response = KalibroGem::Entities::Processing.first_processing_of(@repository.id)
43
+ end
44
+
45
+ When(/^I call the last_processing_of method for the given repository$/) do
46
+ @response = KalibroGem::Entities::Processing.last_processing_of(@repository.id)
47
+ end
48
+
49
+ When(/^I call the first_processing_after method for the given repository and yesterday's date$/) do
50
+ @response = KalibroGem::Entities::Processing.first_processing_after(@repository.id, DateTime.now - 1)
51
+ end
52
+
53
+ When(/^I call the last_processing_before method for the given repository and tomorrow's date$/) do
54
+ @response = KalibroGem::Entities::Processing.last_processing_before(@repository.id, DateTime.now + 1)
55
+ end
56
+
57
+ When(/^I call the processing_of method for the given repository$/) do
58
+ @response = KalibroGem::Entities::Processing.processing_of(@repository.id)
59
+ end
60
+
61
+ When(/^I call the processing_with_date_of method for the given repository and tomorrow's date$/) do
62
+ @response = KalibroGem::Entities::Processing.processing_with_date_of(@repository.id, DateTime.now + 1)
63
+ end
64
+
65
+ When(/^I call the processing_with_date_of method for the given repository and yesterday's date$/) do
66
+ @response = KalibroGem::Entities::Processing.processing_with_date_of(@repository.id, DateTime.now - 1)
67
+ end
68
+
69
+ Then(/^I should get a Processing with state "(.*?)"$/) do |state|
70
+ @response.state.should eq(state)
71
+ end
72
+
73
+ Then(/^I should get nil$/) do
74
+ @response.should be_nil
75
+ end
76
+
77
+ Then(/^I should get "(.*?)"$/) do |state|
78
+ @response.should eq(state)
79
+ end
80
+
81
+ Then(/^I should get false$/) do
82
+ @response.should be_false
83
+ end
84
+
85
+ Then(/^I should get true$/) do
86
+ @response.should be_true
87
+ end
88
+
89
+ Then(/^I should get a Processing$/) do
90
+ @response.should be_a(KalibroGem::Entities::Processing)
91
+ end
@@ -0,0 +1,48 @@
1
+ Given(/^I have a project$/) do
2
+ @project = FactoryGirl.build(:project)
3
+ end
4
+
5
+ Given(/^the project name is "(.*?)"$/) do |name|
6
+ @project.name = name
7
+ end
8
+
9
+ Given(/^I have a project with name "(.*?)"$/) do |name|
10
+ @project = FactoryGirl.create(:project, {name: name, id: nil})
11
+ end
12
+
13
+ When(/^I save the project$/) do
14
+ @project.save
15
+ end
16
+
17
+ When(/^I create the project with name "(.*?)"$/) do |name|
18
+ @project = FactoryGirl.create(:project, {name: name, id: nil})
19
+ end
20
+
21
+ When(/^I search a project with the same id of the given project$/) do
22
+ @found_project = KalibroGem::Entities::Project.find(@project.id)
23
+ end
24
+
25
+ When(/^I destroy the project with the same id of the given project$/) do
26
+ @found_project = KalibroGem::Entities::Project.find(@project.id)
27
+ @found_project.destroy
28
+ end
29
+
30
+ When(/^I ask for all the projects$/) do
31
+ @all_projects = KalibroGem::Entities::Project.all
32
+ end
33
+
34
+ Then(/^the project should exist$/) do
35
+ KalibroGem::Entities::Project.exists?(@project.id)
36
+ end
37
+
38
+ Then(/^it should return the same project as the given one$/) do
39
+ @found_project == @project
40
+ end
41
+
42
+ Then(/^the project should not exist$/) do
43
+ !KalibroGem::Entities::Project.exists?(@found_project.id)
44
+ end
45
+
46
+ Then(/^I should get a list with the given project$/) do
47
+ @all_projects.include?(@project)
48
+ end
@@ -0,0 +1,41 @@
1
+ Given(/^I have a range within the given reading$/) do
2
+ @range = FactoryGirl.build(:range, {id: nil, reading_id: @reading.id})
3
+ @range.save @metric_configuration.id
4
+ end
5
+
6
+ Given(/^I have an unsaved range$/) do
7
+ @range = FactoryGirl.build(:range, {id: nil})
8
+ end
9
+
10
+ Given(/^I have an unsaved range within the given reading$/) do
11
+ @range = FactoryGirl.build(:range, {id: nil, reading_id: @reading.id})
12
+ end
13
+
14
+ When(/^I ask to save the given range$/) do
15
+ @range.save @metric_configuration.id
16
+ end
17
+
18
+ When(/^I ask to save the given range with an inexistent metric configuration$/) do
19
+ @range.save rand(Time.now.to_i)
20
+ end
21
+
22
+ When(/^I ask ranges of the given metric configuration$/) do
23
+ @response = KalibroGem::Entities::Range.ranges_of @metric_configuration.id
24
+ end
25
+
26
+ Then(/^I should get an empty list$/) do
27
+ @response.should eq([])
28
+ end
29
+
30
+ Then(/^I should get a list with the given range$/) do
31
+ @response.size.should eq(1)
32
+ @response.first.comments.should eq(@range.comments)
33
+ end
34
+
35
+ Then(/^I should get an error in range kalibro errors attribute$/) do
36
+ @range.kalibro_errors.should_not eq([])
37
+ end
38
+
39
+ Then(/^the id of the given range should be set$/) do
40
+ @range.id.should_not eq(0)
41
+ end
@@ -0,0 +1,19 @@
1
+ Given(/^I have a reading group with name "(.*?)"$/) do |name|
2
+ @reading_group = FactoryGirl.create(:reading_group, {id: nil, name: name})
3
+ end
4
+
5
+ When(/^I ask for all the reading groups$/) do
6
+ @all_reading_groups = KalibroGem::Entities::ReadingGroup.all
7
+ end
8
+
9
+ When(/^I call the reading_group_of method for the given MetricConfiguration$/) do
10
+ @metric_configuration_reading_group = KalibroGem::Entities::ReadingGroup.reading_group_of(@metric_configuration.id)
11
+ end
12
+
13
+ Then(/^I should get a list with the given reading group$/) do
14
+ @all_reading_groups.include?(@reading_group)
15
+ end
16
+
17
+ Then(/^I should get the given RedingGroup$/) do
18
+ @metric_configuration_reading_group.should eq(@reading_group)
19
+ end
@@ -0,0 +1,20 @@
1
+ Given(/^I have a reading within the given reading group$/) do
2
+ @reading = FactoryGirl.create(:reading, {id: nil, group_id: @reading_group.id})
3
+ end
4
+
5
+ When(/^I ask for a reading with the same id of the given reading$/) do
6
+ @found_reading = KalibroGem::Entities::Reading.find @reading.id
7
+ end
8
+
9
+ When(/^I ask for the readings of the given reading group$/) do
10
+ @found_readings = KalibroGem::Entities::Reading.readings_of @reading_group.id
11
+ end
12
+
13
+ Then(/^I should get the given reading$/) do
14
+ @found_reading == @reading
15
+ end
16
+
17
+ Then(/^I should get a list with the given reading$/) do
18
+ @found_readings.first == @reading
19
+ end
20
+
@@ -0,0 +1,61 @@
1
+ Given(/^the given project has the following Repositories:$/) do |table|
2
+ hash = table.hashes.first
3
+ hash[:project_id] = @project.id
4
+ hash[:configuration_id] = @configuration.id
5
+ hash[:id] = nil
6
+
7
+ @repository = FactoryGirl.create(:repository, hash)
8
+ end
9
+
10
+ When(/^I call the cancel_process method for the given repository$/) do
11
+ @response = @repository.cancel_processing_of_repository
12
+ end
13
+
14
+ When(/^I ask for repositories from the given project$/) do
15
+ @response = KalibroGem::Entities::Repository.repositories_of(@project.id)
16
+ end
17
+
18
+ When(/^I call the process method for the given repository$/) do
19
+ @response = @repository.process
20
+ end
21
+
22
+ When(/^I list types$/) do
23
+ @repository_types = KalibroGem::Entities::Repository.repository_types
24
+ end
25
+
26
+ When(/^I ask for all the repositories$/) do
27
+ @response = KalibroGem::Entities::Repository.all
28
+ end
29
+
30
+ When(/^I ask to find the given repository$/) do
31
+ @response = KalibroGem::Entities::Repository.find(@repository.id)
32
+ end
33
+
34
+ When(/^I ask to check if the given repository exists$/) do
35
+ @response = KalibroGem::Entities::Repository.exists?(@repository.id)
36
+ end
37
+
38
+ Then(/^I should get success$/) do
39
+ @response == true
40
+ end
41
+
42
+ Then(/^I should get a list with the given repository$/) do
43
+ @response.should include(@repository)
44
+ end
45
+
46
+ Then(/^I should get an array of types$/) do
47
+ @repository_types.is_a?(Array)
48
+ @repository_types.count >= 1
49
+ end
50
+
51
+ Then(/^I should get the given repository$/) do
52
+ @response.should eq(@repository)
53
+ end
54
+
55
+ Then(/^the response should contain the given repository$/) do
56
+ @response.first.project_id.should eq(@project.id)
57
+ end
58
+
59
+ Then(/^the repositories should contain the project id$/) do
60
+ @response.first.project_id.should eq(@project.id)
61
+ end