teamcapybara--capybara/spec/counter_spec.rb

36 lines
744 B
Ruby
Raw Normal View History

# frozen_string_literal: true
require 'spec_helper'
RSpec.describe Capybara::Server::Middleware::Counter do
2022-07-09 18:20:40 +00:00
let(:counter) { described_class.new }
let(:uri) { '/example' }
2022-07-09 18:20:40 +00:00
describe '#increment' do
it 'successfully' do
counter.increment(uri)
2022-07-09 18:20:40 +00:00
expect(counter).to be_positive
end
end
2022-07-09 18:20:40 +00:00
describe '#decrement' do
before do
counter.increment(uri)
end
context 'successfully' do
it 'with same uri' do
2022-07-09 18:20:40 +00:00
expect(counter).to be_positive
counter.decrement(uri)
2022-07-09 18:20:40 +00:00
expect(counter).not_to be_positive
end
it 'with changed uri' do
2022-07-09 18:20:40 +00:00
expect(counter).to be_positive
counter.decrement('/')
2022-07-09 18:20:40 +00:00
expect(counter).not_to be_positive
end
end
end
end