From 06e049c1a548b5300cd562ff9e125f3fe4f93c9d Mon Sep 17 00:00:00 2001 From: Cadu Ribeiro Date: Thu, 17 Dec 2020 16:35:52 -0300 Subject: [PATCH] Include tests --- test/base_test.rb | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/test/base_test.rb b/test/base_test.rb index a6730373..6f9101fb 100644 --- a/test/base_test.rb +++ b/test/base_test.rb @@ -6,6 +6,14 @@ class BaseTest < Minitest::Test get('/') { 'Hello World' } end + class TestKeywordArgumentInitializerApp < Sinatra::Base + def initialize(argument:) + @argument = argument + end + + get('/') { "Hello World with Keyword Arguments: #{@argument}" } + end + it 'include Rack::Utils' do assert TestApp.included_modules.include?(Rack::Utils) end @@ -48,6 +56,16 @@ class BaseTest < Minitest::Test TestApp.configure { context = self } assert_equal self, context end + + it "allows constructor to receive keyword arguments" do + app = TestKeywordArgumentInitializerApp.new(argument: "some argument") + request = Rack::MockRequest.new(app) + + response = request.get('/') + + assert response.ok? + assert_equal 'Hello World with Keyword Arguments: some argument', response.body + end end describe "Sinatra::Base#new" do