Commit ff7342cc9a1903a98f354955519e77c8b9d879fd
Committed by
Diego Camarinha
1 parent
1c0b357d
Exists in
colab
and in
4 other branches
Fixed test related to code.
Signed off by: Daniel Alves <danpaulalves@gmail.com>
Showing
6 changed files
with
15 additions
and
26 deletions
Show diff stats
features/metric_configuration/create.feature
| ... | ... | @@ -19,12 +19,10 @@ Feature: Metric Configuration Creation |
| 19 | 19 | And I click the Add Metric link |
| 20 | 20 | And I click the "Analizo" h3 |
| 21 | 21 | And I click the Total Lines of Code link |
| 22 | - And I fill the Code field with "My Code" | |
| 23 | 22 | And I fill the Weight field with "2" |
| 24 | 23 | And I set the select field "Aggregation Form" as "Average" |
| 25 | 24 | And I set the select field "Reading Group" as "Scholar" |
| 26 | 25 | When I press the Save button |
| 27 | - Then I should see "My Code" | |
| 28 | 26 | Then I should see "Total Lines of Code" |
| 29 | 27 | Then I should see "2" |
| 30 | 28 | ... | ... |
features/metric_configuration/delete.feature
| ... | ... | @@ -10,7 +10,7 @@ Feature: Metric Configuration Deletion |
| 10 | 10 | And I own a sample configuration |
| 11 | 11 | And I have a sample reading group |
| 12 | 12 | And I have a sample metric configuration within the given mezuro configuration |
| 13 | - When I am at the Sample Configuration page | |
| 13 | + When I am at the Sample Configuration page | |
| 14 | 14 | And I click the Destroy link |
| 15 | 15 | Then I should see "There are no metric configurations yet!" |
| 16 | 16 | |
| ... | ... | @@ -21,5 +21,5 @@ Feature: Metric Configuration Deletion |
| 21 | 21 | And I have a sample configuration |
| 22 | 22 | And I have a sample reading group |
| 23 | 23 | And I have a sample metric configuration within the given mezuro configuration |
| 24 | - When I am at the Sample Configuration page | |
| 24 | + When I am at the Sample Configuration page | |
| 25 | 25 | Then I should not see "Destroy" |
| 26 | 26 | \ No newline at end of file | ... | ... |
features/metric_configuration/edition.feature
| ... | ... | @@ -22,22 +22,9 @@ Feature: Metric Configuration edition |
| 22 | 22 | And I have a sample metric configuration within the given mezuro configuration |
| 23 | 23 | And I am at the Sample Configuration page |
| 24 | 24 | When I click the Edit link |
| 25 | - And I fill the Code field with "Another_Code" | |
| 25 | + And I fill the Weight field with "3.0" | |
| 26 | 26 | And I press the Save button |
| 27 | - Then I should see "Another_Code" | |
| 28 | - | |
| 29 | - @kalibro_restart | |
| 30 | - Scenario: trying to edit with an existing code | |
| 31 | - Given I am a regular user | |
| 32 | - And I am signed in | |
| 33 | - And I own a sample configuration | |
| 34 | - And I have a sample reading group | |
| 35 | - And I have a sample metric configuration within the given mezuro configuration | |
| 36 | - And I have another metric configuration with code "Another_Code" within the given mezuro configuration | |
| 37 | - When I visit the sample metric configuration edit page | |
| 38 | - And I fill the Code field with "Another_Code" | |
| 39 | - And I press the Save button | |
| 40 | - Then I should see "Code There's already" | |
| 27 | + Then I should see "3.0" | |
| 41 | 28 | |
| 42 | 29 | @kalibro_restart |
| 43 | 30 | Scenario: trying to edit with blank fields |
| ... | ... | @@ -47,8 +34,6 @@ Feature: Metric Configuration edition |
| 47 | 34 | And I have a sample reading group |
| 48 | 35 | And I have a sample metric configuration within the given mezuro configuration |
| 49 | 36 | When I visit the sample metric configuration edit page |
| 50 | - And I fill the Code field with " " | |
| 51 | 37 | And I fill the Weight field with " " |
| 52 | 38 | And I press the Save button |
| 53 | - Then I should see "Code can't be blank" | |
| 54 | - And I should see "Weight can't be blank" | |
| 55 | 39 | \ No newline at end of file |
| 40 | + Then I should see "Weight can't be blank" | |
| 56 | 41 | \ No newline at end of file | ... | ... |
spec/controllers/metric_configurations_controller_spec.rb
| ... | ... | @@ -48,6 +48,7 @@ describe MetricConfigurationsController, :type => :controller do |
| 48 | 48 | end |
| 49 | 49 | |
| 50 | 50 | describe 'create' do |
| 51 | + let!(:metric_configuration) { FactoryGirl.build(:metric_configuration) } | |
| 51 | 52 | let(:metric_configuration_params) { Hash[FactoryGirl.attributes_for(:metric_configuration).map { |k,v| [k.to_s, v.to_s] }] } #FIXME: Mocha is creating the expectations with strings, but FactoryGirl returns everything with symbols and integers |
| 52 | 53 | let(:mezuro_configuration) { FactoryGirl.build(:mezuro_configuration) } |
| 53 | 54 | let(:base_tool) { FactoryGirl.build(:base_tool) } |
| ... | ... | @@ -65,8 +66,9 @@ describe MetricConfigurationsController, :type => :controller do |
| 65 | 66 | before :each do |
| 66 | 67 | MetricConfiguration.any_instance.expects(:save).returns(true) |
| 67 | 68 | KalibroGatekeeperClient::Entities::BaseTool.expects(:find_by_name).with(base_tool.name).returns(base_tool) |
| 69 | + base_tool.expects(:metric).with(metric_configuration.metric.name).returns(metric_configuration.metric) | |
| 68 | 70 | |
| 69 | - post :create, mezuro_configuration_id: mezuro_configuration.id, metric_configuration: metric_configuration_params, base_tool_name: base_tool.name | |
| 71 | + post :create, mezuro_configuration_id: mezuro_configuration.id, metric_configuration: metric_configuration_params, base_tool_name: base_tool.name, metric_name: metric_configuration.metric.name | |
| 70 | 72 | end |
| 71 | 73 | |
| 72 | 74 | it { is_expected.to respond_with(:redirect) } |
| ... | ... | @@ -76,15 +78,16 @@ describe MetricConfigurationsController, :type => :controller do |
| 76 | 78 | before :each do |
| 77 | 79 | MetricConfiguration.any_instance.expects(:save).returns(false) |
| 78 | 80 | KalibroGatekeeperClient::Entities::BaseTool.expects(:find_by_name).with(base_tool.name).returns(base_tool) |
| 81 | + base_tool.expects(:metric).with(metric_configuration.metric.name).returns(metric_configuration.metric) | |
| 79 | 82 | |
| 80 | - post :create, mezuro_configuration_id: mezuro_configuration.id, metric_configuration: metric_configuration_params, base_tool_name: base_tool.name | |
| 83 | + post :create, mezuro_configuration_id: mezuro_configuration.id, metric_configuration: metric_configuration_params, base_tool_name: base_tool.name, metric_name: metric_configuration.metric.name | |
| 81 | 84 | end |
| 82 | 85 | |
| 83 | 86 | it { is_expected.to render_template(:new) } |
| 84 | 87 | end |
| 85 | 88 | end |
| 86 | 89 | end |
| 87 | - | |
| 90 | + | |
| 88 | 91 | describe 'show' do |
| 89 | 92 | let(:metric_configuration) { FactoryGirl.build(:metric_configuration) } |
| 90 | 93 | let(:reading_group) { FactoryGirl.build(:reading_group) } | ... | ... |
spec/factories/metric_configurations.rb
spec/factories/metrics.rb
| 1 | 1 | FactoryGirl.define do |
| 2 | 2 | factory :metric, class: KalibroGatekeeperClient::Entities::Metric do |
| 3 | 3 | name "Total Abstract Classes" |
| 4 | + code "total_abstract_classes" | |
| 4 | 5 | compound false |
| 5 | 6 | scope "SOFTWARE" |
| 6 | 7 | description nil |
| ... | ... | @@ -10,6 +11,7 @@ FactoryGirl.define do |
| 10 | 11 | |
| 11 | 12 | factory :loc, class: KalibroGatekeeperClient::Entities::Metric do |
| 12 | 13 | name "Lines of Code" |
| 14 | + code "loc" | |
| 13 | 15 | compound false |
| 14 | 16 | scope "CLASS" |
| 15 | 17 | description nil |
| ... | ... | @@ -19,6 +21,7 @@ FactoryGirl.define do |
| 19 | 21 | |
| 20 | 22 | factory :compound_metric, class: KalibroGatekeeperClient::Entities::Metric do |
| 21 | 23 | name "Compound" |
| 24 | + code "compound" | |
| 22 | 25 | compound true |
| 23 | 26 | scope "CLASS" |
| 24 | 27 | description nil | ... | ... |