kalibro_client 3.0.1 → 4.0.0.alpha1
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/features/metric_collector_details/find_by_name.feature +12 -4
 - data/features/step_definitions/metric_collector_details_steps.rb +11 -7
 - data/features/step_definitions/metric_configuration_steps.rb +2 -2
 - data/features/step_definitions/module_result_steps.rb +1 -1
 - data/features/support/env.rb +0 -3
 - data/kalibro_client.gemspec +1 -0
 - data/lib/kalibro_client.rb +4 -39
 - data/lib/kalibro_client/entities/base.rb +12 -207
 - data/lib/kalibro_client/entities/configurations/base.rb +3 -3
 - data/lib/kalibro_client/entities/configurations/kalibro_configuration.rb +0 -4
 - data/lib/kalibro_client/entities/configurations/metric_configuration.rb +1 -19
 - data/lib/kalibro_client/entities/configurations/reading_group.rb +1 -5
 - data/lib/kalibro_client/entities/miscellaneous/base.rb +4 -2
 - data/lib/kalibro_client/entities/miscellaneous/metric.rb +0 -2
 - data/lib/kalibro_client/entities/processor/base.rb +3 -3
 - data/lib/kalibro_client/entities/processor/hotspot_metric_result.rb +1 -1
 - data/lib/kalibro_client/entities/processor/metric_collector_details.rb +19 -7
 - data/lib/kalibro_client/entities/processor/module_result.rb +0 -13
 - data/lib/kalibro_client/entities/processor/project.rb +0 -4
 - data/lib/kalibro_client/entities/processor/repository.rb +0 -4
 - data/lib/kalibro_client/entities/processor/tree_metric_result.rb +1 -1
 - data/lib/kalibro_client/errors.rb +1 -4
 - data/lib/kalibro_client/kalibro_cucumber_helpers.rb +7 -36
 - data/lib/kalibro_client/kalibro_cucumber_helpers/cleaner.rb +27 -0
 - data/lib/kalibro_client/version.rb +1 -1
 - data/spec/entities/base_spec.rb +17 -449
 - data/spec/entities/configurations/kalibro_configuration_spec.rb +0 -35
 - data/spec/entities/configurations/kalibro_range_spec.rb +3 -3
 - data/spec/entities/configurations/metric_configuration_spec.rb +1 -58
 - data/spec/entities/configurations/reading_group_spec.rb +0 -32
 - data/spec/entities/configurations/reading_spec.rb +3 -3
 - data/spec/entities/processor/metric_collector_details_spec.rb +46 -25
 - data/spec/entities/processor/module_result_spec.rb +0 -41
 - data/spec/entities/processor/project_spec.rb +1 -35
 - data/spec/entities/processor/repository_spec.rb +1 -14
 - data/spec/{savon/fixtures → fixtures}/config.yml +0 -0
 - data/spec/{savon/fixtures → fixtures}/invalid_config.yml +0 -0
 - data/spec/kalibro_cucumber_helpers/cleaner_spec.rb +32 -0
 - metadata +26 -32
 - data/lib/kalibro_client/errors/record_invalid.rb +0 -19
 - data/lib/kalibro_client/errors/record_not_found.rb +0 -22
 - data/lib/kalibro_client/errors/request_error.rb +0 -27
 - data/lib/kalibro_client/errors/standard.rb +0 -24
 - data/lib/kalibro_client/helpers/date_attributes.rb +0 -11
 - data/lib/kalibro_client/helpers/hash_converters.rb +0 -48
 - data/lib/kalibro_client/helpers/request_methods.rb +0 -64
 - data/lib/kalibro_client/helpers/xml_converters.rb +0 -20
 - data/lib/kalibro_client/kalibro_cucumber_helpers/configuration.rb +0 -30
 - data/spec/errors/record_invalid_spec.rb +0 -45
 - data/spec/helpers/date_attributes_spec.rb +0 -30
 - data/spec/helpers/hash_converters_spec.rb +0 -120
 - data/spec/helpers/xml_converters_spec.rb +0 -64
 - data/spec/kalibro_entities_spec.rb +0 -112
 - data/spec/savon/fixtures/project/does_not_exists.xml +0 -1
 - data/spec/savon/savon_test_helper.rb +0 -14
 
| 
         @@ -1,30 +0,0 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            require 'spec_helper'
         
     | 
| 
       2 
     | 
    
         
            -
            require 'kalibro_client/helpers/date_attributes'
         
     | 
| 
       3 
     | 
    
         
            -
             
     | 
| 
       4 
     | 
    
         
            -
            include DateAttributes
         
     | 
| 
       5 
     | 
    
         
            -
             
     | 
| 
       6 
     | 
    
         
            -
            class Klass
         
     | 
| 
       7 
     | 
    
         
            -
              include DateAttributes
         
     | 
| 
       8 
     | 
    
         
            -
            end
         
     | 
| 
       9 
     | 
    
         
            -
             
     | 
| 
       10 
     | 
    
         
            -
             
     | 
| 
       11 
     | 
    
         
            -
            describe 'DateAttributes' do
         
     | 
| 
       12 
     | 
    
         
            -
              subject { Klass.new }
         
     | 
| 
       13 
     | 
    
         
            -
              let(:time){ "2015-02-04T15:53:18.452Z" }
         
     | 
| 
       14 
     | 
    
         
            -
             
     | 
| 
       15 
     | 
    
         
            -
              describe 'created_at=' do
         
     | 
| 
       16 
     | 
    
         
            -
                it 'is expected to parse it to DateTime' do
         
     | 
| 
       17 
     | 
    
         
            -
                  DateTime.expects(:parse).with(time)
         
     | 
| 
       18 
     | 
    
         
            -
             
     | 
| 
       19 
     | 
    
         
            -
                  subject.created_at = time
         
     | 
| 
       20 
     | 
    
         
            -
                end
         
     | 
| 
       21 
     | 
    
         
            -
              end
         
     | 
| 
       22 
     | 
    
         
            -
             
     | 
| 
       23 
     | 
    
         
            -
              describe 'updated_at=' do
         
     | 
| 
       24 
     | 
    
         
            -
                it 'is expected to parse it to DateTime' do
         
     | 
| 
       25 
     | 
    
         
            -
                  DateTime.expects(:parse).with(time)
         
     | 
| 
       26 
     | 
    
         
            -
             
     | 
| 
       27 
     | 
    
         
            -
                  subject.updated_at = time
         
     | 
| 
       28 
     | 
    
         
            -
                end
         
     | 
| 
       29 
     | 
    
         
            -
              end
         
     | 
| 
       30 
     | 
    
         
            -
            end
         
     | 
| 
         @@ -1,120 +0,0 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            # This file is part of KalibroClient
         
     | 
| 
       2 
     | 
    
         
            -
            # Copyright (C) 2013  it's respectives authors (please see the AUTHORS file)
         
     | 
| 
       3 
     | 
    
         
            -
            #
         
     | 
| 
       4 
     | 
    
         
            -
            # This program is free software: you can redistribute it and/or modify
         
     | 
| 
       5 
     | 
    
         
            -
            # it under the terms of the GNU General Public License as published by
         
     | 
| 
       6 
     | 
    
         
            -
            # the Free Software Foundation, either version 3 of the License, or
         
     | 
| 
       7 
     | 
    
         
            -
            # (at your option) any later version.
         
     | 
| 
       8 
     | 
    
         
            -
            #
         
     | 
| 
       9 
     | 
    
         
            -
            # This program is distributed in the hope that it will be useful,
         
     | 
| 
       10 
     | 
    
         
            -
            # but WITHOUT ANY WARRANTY; without even the implied warranty of
         
     | 
| 
       11 
     | 
    
         
            -
            # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
         
     | 
| 
       12 
     | 
    
         
            -
            # GNU General Public License for more details.
         
     | 
| 
       13 
     | 
    
         
            -
             
     | 
| 
       14 
     | 
    
         
            -
            # You should have received a copy of the GNU General Public License
         
     | 
| 
       15 
     | 
    
         
            -
            # along with this program.  If not, see <http://www.gnu.org/licenses/>.
         
     | 
| 
       16 
     | 
    
         
            -
             
     | 
| 
       17 
     | 
    
         
            -
            require 'spec_helper'
         
     | 
| 
       18 
     | 
    
         
            -
            require 'kalibro_client/helpers/hash_converters'
         
     | 
| 
       19 
     | 
    
         
            -
             
     | 
| 
       20 
     | 
    
         
            -
            include HashConverters
         
     | 
| 
       21 
     | 
    
         
            -
             
     | 
| 
       22 
     | 
    
         
            -
            describe HashConverters do
         
     | 
| 
       23 
     | 
    
         
            -
              describe 'date_with_miliseconds' do
         
     | 
| 
       24 
     | 
    
         
            -
                context 'with 21/12/1995 (first Ruby publication)' do
         
     | 
| 
       25 
     | 
    
         
            -
                  it 'should return 1995-12-21T00:00:00.0/1+00:00' do
         
     | 
| 
       26 
     | 
    
         
            -
                    expect(date_with_milliseconds(DateTime.parse("21/12/1995"))).to eq("1995-12-21T00:00:00.0/1+00:00")
         
     | 
| 
       27 
     | 
    
         
            -
                  end
         
     | 
| 
       28 
     | 
    
         
            -
                end
         
     | 
| 
       29 
     | 
    
         
            -
              end
         
     | 
| 
       30 
     | 
    
         
            -
             
     | 
| 
       31 
     | 
    
         
            -
              describe 'convert_to_hash' do
         
     | 
| 
       32 
     | 
    
         
            -
                context 'with a nil value' do
         
     | 
| 
       33 
     | 
    
         
            -
                  it 'should return nil' do
         
     | 
| 
       34 
     | 
    
         
            -
                    expect(convert_to_hash(nil)).to be_nil
         
     | 
| 
       35 
     | 
    
         
            -
                  end
         
     | 
| 
       36 
     | 
    
         
            -
                end
         
     | 
| 
       37 
     | 
    
         
            -
             
     | 
| 
       38 
     | 
    
         
            -
                context 'with an Array' do
         
     | 
| 
       39 
     | 
    
         
            -
                  before :each do
         
     | 
| 
       40 
     | 
    
         
            -
                    @array = []
         
     | 
| 
       41 
     | 
    
         
            -
                    @element1 = :kalibro
         
     | 
| 
       42 
     | 
    
         
            -
             
     | 
| 
       43 
     | 
    
         
            -
                    @array << @element1
         
     | 
| 
       44 
     | 
    
         
            -
                  end
         
     | 
| 
       45 
     | 
    
         
            -
             
     | 
| 
       46 
     | 
    
         
            -
                  it 'should return the Array wth its elements converted' do
         
     | 
| 
       47 
     | 
    
         
            -
                    expect(convert_to_hash(@array)[0]).to eq(@element1.to_s)
         
     | 
| 
       48 
     | 
    
         
            -
                  end
         
     | 
| 
       49 
     | 
    
         
            -
                end
         
     | 
| 
       50 
     | 
    
         
            -
             
     | 
| 
       51 
     | 
    
         
            -
                context 'with a Base' do
         
     | 
| 
       52 
     | 
    
         
            -
                  before :each do
         
     | 
| 
       53 
     | 
    
         
            -
                    @model = KalibroClient::Entities::Base.new
         
     | 
| 
       54 
     | 
    
         
            -
                  end
         
     | 
| 
       55 
     | 
    
         
            -
             
     | 
| 
       56 
     | 
    
         
            -
                  it "should return the Base's Hash" do
         
     | 
| 
       57 
     | 
    
         
            -
                    expect(convert_to_hash(@model)).to eq(@model.to_hash)
         
     | 
| 
       58 
     | 
    
         
            -
                  end
         
     | 
| 
       59 
     | 
    
         
            -
                end
         
     | 
| 
       60 
     | 
    
         
            -
             
     | 
| 
       61 
     | 
    
         
            -
                context 'with a DateTime' do
         
     | 
| 
       62 
     | 
    
         
            -
                  before :each do
         
     | 
| 
       63 
     | 
    
         
            -
                    @date = DateTime.parse("21/12/1995")
         
     | 
| 
       64 
     | 
    
         
            -
                  end
         
     | 
| 
       65 
     | 
    
         
            -
             
     | 
| 
       66 
     | 
    
         
            -
                  it 'should return th date with miliseconds' do
         
     | 
| 
       67 
     | 
    
         
            -
                    expect(convert_to_hash(@date)).to eq(date_with_milliseconds(@date))
         
     | 
| 
       68 
     | 
    
         
            -
                  end
         
     | 
| 
       69 
     | 
    
         
            -
                end
         
     | 
| 
       70 
     | 
    
         
            -
             
     | 
| 
       71 
     | 
    
         
            -
                context 'with an + infinite Float' do
         
     | 
| 
       72 
     | 
    
         
            -
                  it 'should return INF' do
         
     | 
| 
       73 
     | 
    
         
            -
                    expect(convert_to_hash(1.0/0.0)).to eq('INF')
         
     | 
| 
       74 
     | 
    
         
            -
                  end
         
     | 
| 
       75 
     | 
    
         
            -
                end
         
     | 
| 
       76 
     | 
    
         
            -
             
     | 
| 
       77 
     | 
    
         
            -
                context 'with an - infinite Float' do
         
     | 
| 
       78 
     | 
    
         
            -
                  it 'should return -INF' do
         
     | 
| 
       79 
     | 
    
         
            -
                    expect(convert_to_hash(-1.0/0.0)).to eq('-INF')
         
     | 
| 
       80 
     | 
    
         
            -
                  end
         
     | 
| 
       81 
     | 
    
         
            -
                end
         
     | 
| 
       82 
     | 
    
         
            -
             
     | 
| 
       83 
     | 
    
         
            -
                context 'with a granularity' do
         
     | 
| 
       84 
     | 
    
         
            -
                  let(:granularity) { FactoryGirl.build(:granularity) }
         
     | 
| 
       85 
     | 
    
         
            -
             
     | 
| 
       86 
     | 
    
         
            -
                  it 'is expected to convert the granularity to a hash' do
         
     | 
| 
       87 
     | 
    
         
            -
                    expect(convert_to_hash(granularity)).to be_a Hash
         
     | 
| 
       88 
     | 
    
         
            -
                    expect(convert_to_hash(granularity)).to include 'type'
         
     | 
| 
       89 
     | 
    
         
            -
                  end
         
     | 
| 
       90 
     | 
    
         
            -
                end
         
     | 
| 
       91 
     | 
    
         
            -
              end
         
     | 
| 
       92 
     | 
    
         
            -
             
     | 
| 
       93 
     | 
    
         
            -
              describe 'field_to_hash' do
         
     | 
| 
       94 
     | 
    
         
            -
                context 'with a nil field value' do
         
     | 
| 
       95 
     | 
    
         
            -
                  before do
         
     | 
| 
       96 
     | 
    
         
            -
                    @model = KalibroClient::Entities::Base.new
         
     | 
| 
       97 
     | 
    
         
            -
                    @model.expects(:send).with(:field_getter).returns(nil)
         
     | 
| 
       98 
     | 
    
         
            -
                  end
         
     | 
| 
       99 
     | 
    
         
            -
             
     | 
| 
       100 
     | 
    
         
            -
                  it 'should return an instance of Hash' do
         
     | 
| 
       101 
     | 
    
         
            -
                    expect(@model.field_to_hash(:field_getter)).to be_a(Hash)
         
     | 
| 
       102 
     | 
    
         
            -
                  end
         
     | 
| 
       103 
     | 
    
         
            -
             
     | 
| 
       104 
     | 
    
         
            -
                  it 'should return an empty Hash' do
         
     | 
| 
       105 
     | 
    
         
            -
                    expect(@model.field_to_hash(:field_getter)).to eq({})
         
     | 
| 
       106 
     | 
    
         
            -
                  end
         
     | 
| 
       107 
     | 
    
         
            -
                end
         
     | 
| 
       108 
     | 
    
         
            -
             
     | 
| 
       109 
     | 
    
         
            -
                context 'with a Float field value' do
         
     | 
| 
       110 
     | 
    
         
            -
                  before do
         
     | 
| 
       111 
     | 
    
         
            -
                    @model = KalibroClient::Entities::Base.new
         
     | 
| 
       112 
     | 
    
         
            -
                    @model.expects(:send).with(:field_getter).returns(1.0)
         
     | 
| 
       113 
     | 
    
         
            -
                  end
         
     | 
| 
       114 
     | 
    
         
            -
             
     | 
| 
       115 
     | 
    
         
            -
                  it 'should return an instance of Hash' do
         
     | 
| 
       116 
     | 
    
         
            -
                    expect(@model.field_to_hash(:field_getter)).to be_a(Hash)
         
     | 
| 
       117 
     | 
    
         
            -
                  end
         
     | 
| 
       118 
     | 
    
         
            -
                end
         
     | 
| 
       119 
     | 
    
         
            -
              end
         
     | 
| 
       120 
     | 
    
         
            -
            end
         
     | 
| 
         @@ -1,64 +0,0 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            # This file is part of KalibroClient
         
     | 
| 
       2 
     | 
    
         
            -
            # Copyright (C) 2013  it's respectives authors (please see the AUTHORS file)
         
     | 
| 
       3 
     | 
    
         
            -
            #
         
     | 
| 
       4 
     | 
    
         
            -
            # This program is free software: you can redistribute it and/or modify
         
     | 
| 
       5 
     | 
    
         
            -
            # it under the terms of the GNU General Public License as published by
         
     | 
| 
       6 
     | 
    
         
            -
            # the Free Software Foundation, either version 3 of the License, or
         
     | 
| 
       7 
     | 
    
         
            -
            # (at your option) any later version.
         
     | 
| 
       8 
     | 
    
         
            -
            #
         
     | 
| 
       9 
     | 
    
         
            -
            # This program is distributed in the hope that it will be useful,
         
     | 
| 
       10 
     | 
    
         
            -
            # but WITHOUT ANY WARRANTY; without even the implied warranty of
         
     | 
| 
       11 
     | 
    
         
            -
            # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
         
     | 
| 
       12 
     | 
    
         
            -
            # GNU General Public License for more details.
         
     | 
| 
       13 
     | 
    
         
            -
             
     | 
| 
       14 
     | 
    
         
            -
            # You should have received a copy of the GNU General Public License
         
     | 
| 
       15 
     | 
    
         
            -
            # along with this program.  If not, see <http://www.gnu.org/licenses/>.
         
     | 
| 
       16 
     | 
    
         
            -
             
     | 
| 
       17 
     | 
    
         
            -
            require 'spec_helper'
         
     | 
| 
       18 
     | 
    
         
            -
            require 'kalibro_client/helpers/xml_converters'
         
     | 
| 
       19 
     | 
    
         
            -
             
     | 
| 
       20 
     | 
    
         
            -
            include XMLConverters
         
     | 
| 
       21 
     | 
    
         
            -
             
     | 
| 
       22 
     | 
    
         
            -
            describe XMLConverters do
         
     | 
| 
       23 
     | 
    
         
            -
              describe 'xml_instance_class_name' do
         
     | 
| 
       24 
     | 
    
         
            -
                before { @model = KalibroClient::Entities::Base.new }
         
     | 
| 
       25 
     | 
    
         
            -
             
     | 
| 
       26 
     | 
    
         
            -
                it 'should return modelXml' do
         
     | 
| 
       27 
     | 
    
         
            -
                  expect(xml_instance_class_name(@model)).to eq('baseXml')
         
     | 
| 
       28 
     | 
    
         
            -
                end
         
     | 
| 
       29 
     | 
    
         
            -
              end
         
     | 
| 
       30 
     | 
    
         
            -
             
     | 
| 
       31 
     | 
    
         
            -
              describe 'get_xml' do
         
     | 
| 
       32 
     | 
    
         
            -
                context 'with an object that is not an instance of Base' do
         
     | 
| 
       33 
     | 
    
         
            -
                  before { @object = "kalibro" }
         
     | 
| 
       34 
     | 
    
         
            -
             
     | 
| 
       35 
     | 
    
         
            -
                  it 'should return a Hash' do
         
     | 
| 
       36 
     | 
    
         
            -
                    expect(get_xml("field", @object)).to be_a(Hash)
         
     | 
| 
       37 
     | 
    
         
            -
                  end
         
     | 
| 
       38 
     | 
    
         
            -
             
     | 
| 
       39 
     | 
    
         
            -
                  it 'should return an empty Hash' do
         
     | 
| 
       40 
     | 
    
         
            -
                    expect(get_xml("field", @object)).to eq({})
         
     | 
| 
       41 
     | 
    
         
            -
                  end
         
     | 
| 
       42 
     | 
    
         
            -
                end
         
     | 
| 
       43 
     | 
    
         
            -
             
     | 
| 
       44 
     | 
    
         
            -
                context 'with an instance of Base' do
         
     | 
| 
       45 
     | 
    
         
            -
                  before { @object = KalibroClient::Entities::Base.new }
         
     | 
| 
       46 
     | 
    
         
            -
             
     | 
| 
       47 
     | 
    
         
            -
                  it 'should return a Hash' do
         
     | 
| 
       48 
     | 
    
         
            -
                    expect(get_xml("field", @object)).to be_a(Hash)
         
     | 
| 
       49 
     | 
    
         
            -
                  end
         
     | 
| 
       50 
     | 
    
         
            -
             
     | 
| 
       51 
     | 
    
         
            -
                  it 'should return the XML Hash' do
         
     | 
| 
       52 
     | 
    
         
            -
                    field_xml_hash = {:attributes! =>
         
     | 
| 
       53 
     | 
    
         
            -
                                        {:field =>
         
     | 
| 
       54 
     | 
    
         
            -
                                          {"xmlns:xsi" => "http://www.w3.org/2001/XMLSchema-instance", 
         
     | 
| 
       55 
     | 
    
         
            -
                                           "xsi:type"=>"kalibro:baseXml"
         
     | 
| 
       56 
     | 
    
         
            -
                                          }
         
     | 
| 
       57 
     | 
    
         
            -
                                        }
         
     | 
| 
       58 
     | 
    
         
            -
                                      }
         
     | 
| 
       59 
     | 
    
         
            -
             
     | 
| 
       60 
     | 
    
         
            -
                    expect(get_xml("field", @object)).to eq(field_xml_hash)
         
     | 
| 
       61 
     | 
    
         
            -
                  end
         
     | 
| 
       62 
     | 
    
         
            -
                end
         
     | 
| 
       63 
     | 
    
         
            -
              end
         
     | 
| 
       64 
     | 
    
         
            -
            end
         
     | 
| 
         @@ -1,112 +0,0 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            # This file is part of KalibroClient
         
     | 
| 
       2 
     | 
    
         
            -
            # Copyright (C) 2013  it's respectives authors (please see the AUTHORS file)
         
     | 
| 
       3 
     | 
    
         
            -
            #
         
     | 
| 
       4 
     | 
    
         
            -
            # This program is free software: you can redistribute it and/or modify
         
     | 
| 
       5 
     | 
    
         
            -
            # it under the terms of the GNU General Public License as published by
         
     | 
| 
       6 
     | 
    
         
            -
            # the Free Software Foundation, either version 3 of the License, or
         
     | 
| 
       7 
     | 
    
         
            -
            # (at your option) any later version.
         
     | 
| 
       8 
     | 
    
         
            -
            #
         
     | 
| 
       9 
     | 
    
         
            -
            # This program is distributed in the hope that it will be useful,
         
     | 
| 
       10 
     | 
    
         
            -
            # but WITHOUT ANY WARRANTY; without even the implied warranty of
         
     | 
| 
       11 
     | 
    
         
            -
            # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
         
     | 
| 
       12 
     | 
    
         
            -
            # GNU General Public License for more details.
         
     | 
| 
       13 
     | 
    
         
            -
             
     | 
| 
       14 
     | 
    
         
            -
            # You should have received a copy of the GNU General Public License
         
     | 
| 
       15 
     | 
    
         
            -
            # along with this program.  If not, see <http://www.gnu.org/licenses/>.
         
     | 
| 
       16 
     | 
    
         
            -
             
     | 
| 
       17 
     | 
    
         
            -
            require 'spec_helper'
         
     | 
| 
       18 
     | 
    
         
            -
             
     | 
| 
       19 
     | 
    
         
            -
            describe KalibroClient do
         
     | 
| 
       20 
     | 
    
         
            -
             
     | 
| 
       21 
     | 
    
         
            -
              context 'configuration' do
         
     | 
| 
       22 
     | 
    
         
            -
                #FIXME: there should be a better way to keep the default values
         
     | 
| 
       23 
     | 
    
         
            -
                let(:config) { { processor_address: "http://localhost:8082",
         
     | 
| 
       24 
     | 
    
         
            -
                               configurations_address: "http://localhost:8083" } }
         
     | 
| 
       25 
     | 
    
         
            -
             
     | 
| 
       26 
     | 
    
         
            -
                describe 'config' do
         
     | 
| 
       27 
     | 
    
         
            -
                  it 'should return the default configuration' do
         
     | 
| 
       28 
     | 
    
         
            -
                    expect(KalibroClient.config).to eq({
         
     | 
| 
       29 
     | 
    
         
            -
                      processor_address: "http://localhost:8082",
         
     | 
| 
       30 
     | 
    
         
            -
                      configurations_address: "http://localhost:8083"
         
     | 
| 
       31 
     | 
    
         
            -
                    })
         
     | 
| 
       32 
     | 
    
         
            -
                  end
         
     | 
| 
       33 
     | 
    
         
            -
                end
         
     | 
| 
       34 
     | 
    
         
            -
             
     | 
| 
       35 
     | 
    
         
            -
                describe 'configure' do
         
     | 
| 
       36 
     | 
    
         
            -
                  after(:each) {KalibroClient.configure(config)}
         
     | 
| 
       37 
     | 
    
         
            -
             
     | 
| 
       38 
     | 
    
         
            -
                  it 'should set the address' do
         
     | 
| 
       39 
     | 
    
         
            -
                    KalibroClient.configure({processor_address: 'http://test.test'})
         
     | 
| 
       40 
     | 
    
         
            -
                    expect(KalibroClient.config[:processor_address]).to eq('http://test.test')
         
     | 
| 
       41 
     | 
    
         
            -
                  end
         
     | 
| 
       42 
     | 
    
         
            -
                end
         
     | 
| 
       43 
     | 
    
         
            -
             
     | 
| 
       44 
     | 
    
         
            -
                describe 'configure_with' do
         
     | 
| 
       45 
     | 
    
         
            -
                  context 'with an existent YAML' do
         
     | 
| 
       46 
     | 
    
         
            -
                    after(:each) {KalibroClient.configure(config)}
         
     | 
| 
       47 
     | 
    
         
            -
             
     | 
| 
       48 
     | 
    
         
            -
                    it 'should set the config' do
         
     | 
| 
       49 
     | 
    
         
            -
                      KalibroClient.configure_with('spec/savon/fixtures/config.yml')
         
     | 
| 
       50 
     | 
    
         
            -
             
     | 
| 
       51 
     | 
    
         
            -
                      expect(KalibroClient.config).to eq({
         
     | 
| 
       52 
     | 
    
         
            -
                        processor_address: 'http://test1.test1',
         
     | 
| 
       53 
     | 
    
         
            -
                        configurations_address: 'http://test2.test2'})
         
     | 
| 
       54 
     | 
    
         
            -
                    end
         
     | 
| 
       55 
     | 
    
         
            -
                  end
         
     | 
| 
       56 
     | 
    
         
            -
             
     | 
| 
       57 
     | 
    
         
            -
                  context 'with an inexistent YAML' do
         
     | 
| 
       58 
     | 
    
         
            -
                    before :each do
         
     | 
| 
       59 
     | 
    
         
            -
                      @logger = Logger.new(File::NULL)
         
     | 
| 
       60 
     | 
    
         
            -
                      KalibroClient.expects(:logger).returns(@logger)
         
     | 
| 
       61 
     | 
    
         
            -
                    end
         
     | 
| 
       62 
     | 
    
         
            -
             
     | 
| 
       63 
     | 
    
         
            -
                    it 'should keep the defaults' do
         
     | 
| 
       64 
     | 
    
         
            -
                      KalibroClient.configure_with('spec/savon/fixtures/inexistent_file.yml')
         
     | 
| 
       65 
     | 
    
         
            -
                      expect(KalibroClient.config).to eq(config)
         
     | 
| 
       66 
     | 
    
         
            -
                    end
         
     | 
| 
       67 
     | 
    
         
            -
             
     | 
| 
       68 
     | 
    
         
            -
                    it 'should log an warning' do
         
     | 
| 
       69 
     | 
    
         
            -
                      @logger.expects(:warn).with("YAML configuration file couldn't be found. Using defaults.")
         
     | 
| 
       70 
     | 
    
         
            -
             
     | 
| 
       71 
     | 
    
         
            -
                      KalibroClient.configure_with('spec/savon/fixtures/inexistent_file.yml')
         
     | 
| 
       72 
     | 
    
         
            -
                    end
         
     | 
| 
       73 
     | 
    
         
            -
                  end
         
     | 
| 
       74 
     | 
    
         
            -
             
     | 
| 
       75 
     | 
    
         
            -
                  context 'with an invalid YAML' do
         
     | 
| 
       76 
     | 
    
         
            -
                    before :each do
         
     | 
| 
       77 
     | 
    
         
            -
                      @logger = Logger.new(File::NULL)
         
     | 
| 
       78 
     | 
    
         
            -
                      KalibroClient.expects(:logger).returns(@logger)
         
     | 
| 
       79 
     | 
    
         
            -
                    end
         
     | 
| 
       80 
     | 
    
         
            -
             
     | 
| 
       81 
     | 
    
         
            -
                    it 'should keep the defaults' do
         
     | 
| 
       82 
     | 
    
         
            -
                      KalibroClient.configure_with('spec/savon/fixtures/invalid_config.yml')
         
     | 
| 
       83 
     | 
    
         
            -
                      expect(KalibroClient.config).to eq(config)
         
     | 
| 
       84 
     | 
    
         
            -
                    end
         
     | 
| 
       85 
     | 
    
         
            -
             
     | 
| 
       86 
     | 
    
         
            -
                    it 'should log an warning' do
         
     | 
| 
       87 
     | 
    
         
            -
                      @logger.expects(:warn).with("YAML configuration file contains invalid syntax. Using defaults.")
         
     | 
| 
       88 
     | 
    
         
            -
             
     | 
| 
       89 
     | 
    
         
            -
                      KalibroClient.configure_with('spec/savon/fixtures/invalid_config.yml')
         
     | 
| 
       90 
     | 
    
         
            -
                    end
         
     | 
| 
       91 
     | 
    
         
            -
                  end
         
     | 
| 
       92 
     | 
    
         
            -
                end
         
     | 
| 
       93 
     | 
    
         
            -
              end
         
     | 
| 
       94 
     | 
    
         
            -
             
     | 
| 
       95 
     | 
    
         
            -
              context 'Logger' do
         
     | 
| 
       96 
     | 
    
         
            -
                describe 'logger' do
         
     | 
| 
       97 
     | 
    
         
            -
                  it 'should return the default logger' do
         
     | 
| 
       98 
     | 
    
         
            -
                    expect(KalibroClient.logger).to be_a(Logger)
         
     | 
| 
       99 
     | 
    
         
            -
                  end
         
     | 
| 
       100 
     | 
    
         
            -
                end
         
     | 
| 
       101 
     | 
    
         
            -
             
     | 
| 
       102 
     | 
    
         
            -
                describe 'logger=' do
         
     | 
| 
       103 
     | 
    
         
            -
                  it 'should set the logger' do
         
     | 
| 
       104 
     | 
    
         
            -
                    logger = Logger.new(STDOUT)
         
     | 
| 
       105 
     | 
    
         
            -
             
     | 
| 
       106 
     | 
    
         
            -
                    KalibroClient.logger = logger
         
     | 
| 
       107 
     | 
    
         
            -
             
     | 
| 
       108 
     | 
    
         
            -
                    expect(KalibroClient.logger).to eq(logger)
         
     | 
| 
       109 
     | 
    
         
            -
                  end
         
     | 
| 
       110 
     | 
    
         
            -
                end
         
     | 
| 
       111 
     | 
    
         
            -
              end
         
     | 
| 
       112 
     | 
    
         
            -
            end
         
     | 
| 
         @@ -1 +0,0 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            <?xml version="1.0" ?><S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/"><S:Body><ns2:projectExistsResponse xmlns:ns2="http://service.kalibro.org/"><exists>false</exists></ns2:projectExistsResponse></S:Body></S:Envelope>
         
     | 
| 
         @@ -1,14 +0,0 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            module SavonTestHelper
         
     | 
| 
       2 
     | 
    
         
            -
              HttpMock = Struct.new(:code, :headers, :body) do
         
     | 
| 
       3 
     | 
    
         
            -
                def error?
         
     | 
| 
       4 
     | 
    
         
            -
                  false
         
     | 
| 
       5 
     | 
    
         
            -
                end
         
     | 
| 
       6 
     | 
    
         
            -
              end
         
     | 
| 
       7 
     | 
    
         
            -
             
     | 
| 
       8 
     | 
    
         
            -
              def mock_savon_response(xml_response, code = 200, headers = {})
         
     | 
| 
       9 
     | 
    
         
            -
                http = HttpMock.new(code, headers, xml_response)
         
     | 
| 
       10 
     | 
    
         
            -
                savon_local_options = Savon::LocalOptions.new
         
     | 
| 
       11 
     | 
    
         
            -
                savon_global_options = Savon::GlobalOptions.new
         
     | 
| 
       12 
     | 
    
         
            -
                savon_response = Savon::Response.new(http, savon_global_options, savon_local_options)
         
     | 
| 
       13 
     | 
    
         
            -
              end
         
     | 
| 
       14 
     | 
    
         
            -
            end
         
     |