Skip to content

Commit

Permalink
Merge pull request #12 from aristotelesbr/development
Browse files Browse the repository at this point in the history
Add assign_params to Reques class
  • Loading branch information
aristotelesbr authored Nov 25, 2023
2 parents 2fe8402 + 04d5600 commit 114725e
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 2 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [0.1.5] - 2023-25-11

### Added

- Add `assign_params` method to Request class

## [0.1.4] - 2023-25-11

### Fixed
Expand Down
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
lennarb (0.1.4)
lennarb (0.1.5)
colorize (~> 1.1)
puma (~> 6.4)
rack (~> 3.0, >= 3.0.8)
Expand Down
10 changes: 10 additions & 0 deletions lib/lenna/router/request.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,16 @@ class Router
# @attr body [Hash] the request body
# @attr params [Hash] the request params
class Request < ::Rack::Request

# This method is used to set the request params.
#
# @param params [Hash] the request params
#
# @return [Hash] the request params
#
# @api public
def assign_params(params) = @params = params

# This method is used to parse the body params.
#
# @return [Hash] the request params
Expand Down
2 changes: 1 addition & 1 deletion lib/lennarb/version.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# frozen_string_literal: true

module Lennarb
VERSION = '0.1.4'
VERSION = '0.1.5'

public_constant :VERSION
end
9 changes: 9 additions & 0 deletions test/lib/lenna/router/test_request.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,15 @@
module Lenna
class Router
class TestRequest < Minitest::Test
def test_assing_params
env = ::Rack::MockRequest.env_for('/', method: 'POST')
request = Request.new(env)

request.assign_params({ 'foo' => 'bar' })

assert_equal({ 'foo' => 'bar' }, request.params)
end

def test_with_query_string
env = ::Rack::MockRequest.env_for('/?foo=bar')

Expand Down

0 comments on commit 114725e

Please sign in to comment.