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,12 +19,10 @@ Feature: Metric Configuration Creation | ||
| 19 | And I click the Add Metric link | 19 | And I click the Add Metric link |
| 20 | And I click the "Analizo" h3 | 20 | And I click the "Analizo" h3 |
| 21 | And I click the Total Lines of Code link | 21 | And I click the Total Lines of Code link |
| 22 | - And I fill the Code field with "My Code" | ||
| 23 | And I fill the Weight field with "2" | 22 | And I fill the Weight field with "2" |
| 24 | And I set the select field "Aggregation Form" as "Average" | 23 | And I set the select field "Aggregation Form" as "Average" |
| 25 | And I set the select field "Reading Group" as "Scholar" | 24 | And I set the select field "Reading Group" as "Scholar" |
| 26 | When I press the Save button | 25 | When I press the Save button |
| 27 | - Then I should see "My Code" | ||
| 28 | Then I should see "Total Lines of Code" | 26 | Then I should see "Total Lines of Code" |
| 29 | Then I should see "2" | 27 | Then I should see "2" |
| 30 | 28 |
features/metric_configuration/delete.feature
| @@ -10,7 +10,7 @@ Feature: Metric Configuration Deletion | @@ -10,7 +10,7 @@ Feature: Metric Configuration Deletion | ||
| 10 | And I own a sample configuration | 10 | And I own a sample configuration |
| 11 | And I have a sample reading group | 11 | And I have a sample reading group |
| 12 | And I have a sample metric configuration within the given mezuro configuration | 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 | And I click the Destroy link | 14 | And I click the Destroy link |
| 15 | Then I should see "There are no metric configurations yet!" | 15 | Then I should see "There are no metric configurations yet!" |
| 16 | 16 | ||
| @@ -21,5 +21,5 @@ Feature: Metric Configuration Deletion | @@ -21,5 +21,5 @@ Feature: Metric Configuration Deletion | ||
| 21 | And I have a sample configuration | 21 | And I have a sample configuration |
| 22 | And I have a sample reading group | 22 | And I have a sample reading group |
| 23 | And I have a sample metric configuration within the given mezuro configuration | 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 | Then I should not see "Destroy" | 25 | Then I should not see "Destroy" |
| 26 | \ No newline at end of file | 26 | \ No newline at end of file |
features/metric_configuration/edition.feature
| @@ -22,22 +22,9 @@ Feature: Metric Configuration edition | @@ -22,22 +22,9 @@ Feature: Metric Configuration edition | ||
| 22 | And I have a sample metric configuration within the given mezuro configuration | 22 | And I have a sample metric configuration within the given mezuro configuration |
| 23 | And I am at the Sample Configuration page | 23 | And I am at the Sample Configuration page |
| 24 | When I click the Edit link | 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 | And I press the Save button | 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 | @kalibro_restart | 29 | @kalibro_restart |
| 43 | Scenario: trying to edit with blank fields | 30 | Scenario: trying to edit with blank fields |
| @@ -47,8 +34,6 @@ Feature: Metric Configuration edition | @@ -47,8 +34,6 @@ Feature: Metric Configuration edition | ||
| 47 | And I have a sample reading group | 34 | And I have a sample reading group |
| 48 | And I have a sample metric configuration within the given mezuro configuration | 35 | And I have a sample metric configuration within the given mezuro configuration |
| 49 | When I visit the sample metric configuration edit page | 36 | When I visit the sample metric configuration edit page |
| 50 | - And I fill the Code field with " " | ||
| 51 | And I fill the Weight field with " " | 37 | And I fill the Weight field with " " |
| 52 | And I press the Save button | 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 | \ No newline at end of file | 39 | \ No newline at end of file |
| 40 | + Then I should see "Weight can't be blank" | ||
| 56 | \ No newline at end of file | 41 | \ No newline at end of file |
spec/controllers/metric_configurations_controller_spec.rb
| @@ -48,6 +48,7 @@ describe MetricConfigurationsController, :type => :controller do | @@ -48,6 +48,7 @@ describe MetricConfigurationsController, :type => :controller do | ||
| 48 | end | 48 | end |
| 49 | 49 | ||
| 50 | describe 'create' do | 50 | describe 'create' do |
| 51 | + let!(:metric_configuration) { FactoryGirl.build(:metric_configuration) } | ||
| 51 | 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 | 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 | let(:mezuro_configuration) { FactoryGirl.build(:mezuro_configuration) } | 53 | let(:mezuro_configuration) { FactoryGirl.build(:mezuro_configuration) } |
| 53 | let(:base_tool) { FactoryGirl.build(:base_tool) } | 54 | let(:base_tool) { FactoryGirl.build(:base_tool) } |
| @@ -65,8 +66,9 @@ describe MetricConfigurationsController, :type => :controller do | @@ -65,8 +66,9 @@ describe MetricConfigurationsController, :type => :controller do | ||
| 65 | before :each do | 66 | before :each do |
| 66 | MetricConfiguration.any_instance.expects(:save).returns(true) | 67 | MetricConfiguration.any_instance.expects(:save).returns(true) |
| 67 | KalibroGatekeeperClient::Entities::BaseTool.expects(:find_by_name).with(base_tool.name).returns(base_tool) | 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 | end | 72 | end |
| 71 | 73 | ||
| 72 | it { is_expected.to respond_with(:redirect) } | 74 | it { is_expected.to respond_with(:redirect) } |
| @@ -76,15 +78,16 @@ describe MetricConfigurationsController, :type => :controller do | @@ -76,15 +78,16 @@ describe MetricConfigurationsController, :type => :controller do | ||
| 76 | before :each do | 78 | before :each do |
| 77 | MetricConfiguration.any_instance.expects(:save).returns(false) | 79 | MetricConfiguration.any_instance.expects(:save).returns(false) |
| 78 | KalibroGatekeeperClient::Entities::BaseTool.expects(:find_by_name).with(base_tool.name).returns(base_tool) | 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 | end | 84 | end |
| 82 | 85 | ||
| 83 | it { is_expected.to render_template(:new) } | 86 | it { is_expected.to render_template(:new) } |
| 84 | end | 87 | end |
| 85 | end | 88 | end |
| 86 | end | 89 | end |
| 87 | - | 90 | + |
| 88 | describe 'show' do | 91 | describe 'show' do |
| 89 | let(:metric_configuration) { FactoryGirl.build(:metric_configuration) } | 92 | let(:metric_configuration) { FactoryGirl.build(:metric_configuration) } |
| 90 | let(:reading_group) { FactoryGirl.build(:reading_group) } | 93 | let(:reading_group) { FactoryGirl.build(:reading_group) } |
spec/factories/metric_configurations.rb
| 1 | FactoryGirl.define do | 1 | FactoryGirl.define do |
| 2 | factory :metric_configuration, class: MetricConfiguration do | 2 | factory :metric_configuration, class: MetricConfiguration do |
| 3 | id 1 | 3 | id 1 |
| 4 | - code 'native' | 4 | + code 'total_abstract_classes' |
| 5 | metric {FactoryGirl.build(:metric)} | 5 | metric {FactoryGirl.build(:metric)} |
| 6 | base_tool_name "Analizo" | 6 | base_tool_name "Analizo" |
| 7 | weight 1 | 7 | weight 1 |
spec/factories/metrics.rb
| 1 | FactoryGirl.define do | 1 | FactoryGirl.define do |
| 2 | factory :metric, class: KalibroGatekeeperClient::Entities::Metric do | 2 | factory :metric, class: KalibroGatekeeperClient::Entities::Metric do |
| 3 | name "Total Abstract Classes" | 3 | name "Total Abstract Classes" |
| 4 | + code "total_abstract_classes" | ||
| 4 | compound false | 5 | compound false |
| 5 | scope "SOFTWARE" | 6 | scope "SOFTWARE" |
| 6 | description nil | 7 | description nil |
| @@ -10,6 +11,7 @@ FactoryGirl.define do | @@ -10,6 +11,7 @@ FactoryGirl.define do | ||
| 10 | 11 | ||
| 11 | factory :loc, class: KalibroGatekeeperClient::Entities::Metric do | 12 | factory :loc, class: KalibroGatekeeperClient::Entities::Metric do |
| 12 | name "Lines of Code" | 13 | name "Lines of Code" |
| 14 | + code "loc" | ||
| 13 | compound false | 15 | compound false |
| 14 | scope "CLASS" | 16 | scope "CLASS" |
| 15 | description nil | 17 | description nil |
| @@ -19,6 +21,7 @@ FactoryGirl.define do | @@ -19,6 +21,7 @@ FactoryGirl.define do | ||
| 19 | 21 | ||
| 20 | factory :compound_metric, class: KalibroGatekeeperClient::Entities::Metric do | 22 | factory :compound_metric, class: KalibroGatekeeperClient::Entities::Metric do |
| 21 | name "Compound" | 23 | name "Compound" |
| 24 | + code "compound" | ||
| 22 | compound true | 25 | compound true |
| 23 | scope "CLASS" | 26 | scope "CLASS" |
| 24 | description nil | 27 | description nil |