require_relative './test_config' require 'helix_web_services_client' describe 'HelixWebServicesClient counters' do randstr = (0...8).map { (65 + rand(26)).chr }.join counter_1 = "#{randstr}_test_1" counter_2 = "#{randstr}_test_2" context '#set_counter' do it 'can create a numerical counter' do client_as_super do |c| c.set_counter(counter: counter_1, value: '1') end end it 'can create a text counter' do client_as_super do |c| c.set_counter(counter: counter_2, value: randstr) end end end context '#counters' do it 'can include our test counters in the list' do client_as_super do |c| counters = c.counters expect(counters.map(&:counter)).to include(counter_1) expect(counters.map(&:counter)).to include(counter_2) end end end context '#counter' do it 'can list our numerical counter' do client_as_super do |c| counter = c.counter(counter_1) expect(counter.value).to eq('1') end end it 'can list the text counter' do client_as_super do |c| counter = c.counter(counter_2) expect(counter.value).to eq(randstr) end end end context '#increment_counter' do it 'can increment the numerical counter' do client_as_super do |c| c.increment_counter(counter_1) counter = c.counter(counter_1) expect(counter.value).to eq('2') end end end context '#delete_counter' do it 'can delete our test counters' do client_as_super do |c| c.delete_counter(counter_1) c.delete_counter(counter_2) counters = c.counters expect(counters.map(&:counter)).to_not include(counter_1) expect(counters.map(&:counter)).to_not include(counter_2) end end end end