Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve specs on Upperkut::Configuration #34

Merged
merged 1 commit into from
Apr 3, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 42 additions & 6 deletions spec/upperkut_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,52 @@ def call(_worker, _items); end
default = Upperkut::Configuration.default

expect(default.polling_interval).to eq 5
end
end

describe '#server_middlewares' do
let(:config) { Upperkut::Configuration.default }

context 'when block is given' do
it 'yields the current server middlewares configuration and return it' do
config.server_middlewares do |chain|
expect(chain).to be_an(Upperkut::Middleware::Chain)
chain.add MyMiddleware
end
expect(config.server_middlewares.items).to eq([MyMiddleware])
end
end

default.server_middlewares do |chain|
chain.add MyMiddleware
context 'when no block is given' do
it 'returns memoized server middlewares with current configuration' do
server_middlewares = config.server_middlewares
expect(server_middlewares).to eq(config.server_middlewares)
expect(server_middlewares).to be_an(Upperkut::Middleware::Chain)
expect(server_middlewares.items).to eq([])
end
end
end

describe '#client_middlewares' do
let(:config) { Upperkut::Configuration.default }

context 'when block is given' do
it 'yields the current client middlewares configuration and return it' do
config.client_middlewares do |chain|
expect(chain).to be_an(Upperkut::Middleware::Chain)
chain.add MyMiddleware
end
expect(config.client_middlewares.items).to eq([MyMiddleware])
end
end

default.client_middlewares do |chain|
chain.add MyMiddleware
context 'when no block is given' do
it 'returns memoized client middlewares with current configuration' do
client_middlewares = config.client_middlewares
expect(client_middlewares).to eq(config.client_middlewares)
expect(client_middlewares).to be_an(Upperkut::Middleware::Chain)
expect(client_middlewares.items).to eq([])
end
expect(default.server_middlewares.items).to eq([MyMiddleware])
expect(default.client_middlewares.items).to eq([MyMiddleware])
end
end
end