minitest-default_http_header 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: c0860a37eba0e3c9e4011adf358879d0ed219ef9f0cce342387f34ee0b5bb36d
4
+ data.tar.gz: febd8660e4d20c41fbd2c959b075b8a9ed9a130ca2483e726ce8ea8f97aea078
5
+ SHA512:
6
+ metadata.gz: 6faf9a1ac28dfd462e6d1dda8f6282e74af03c1185b1b4d774664fdd5cf12208db43346822c6b1fd59686e869787d8bf207d3e72d5210907afc6fe655a2d57ac
7
+ data.tar.gz: 8dbd87a998fc2471cb4229470a80e1601435f286f9c7f9b090045ae1056a2478d794c13dc80ffd8378ee253ecb195341de81918c81daa5009bce19ca5dc1f3e0
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2026 Keita Urashima
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,58 @@
1
+ # Minitest::DefaultHttpHeader
2
+
3
+ Set default HTTP headers in Rails integration tests.
4
+
5
+ Minitest version of [rspec-default_http_header](https://github.com/kenchan/rspec-default_http_header).
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'minitest-default_http_header'
13
+ ```
14
+
15
+ ## Usage
16
+
17
+ Use `default_headers` to set HTTP headers that are automatically included in every request:
18
+
19
+ ```ruby
20
+ class UsersApiTest < ActionDispatch::IntegrationTest
21
+ setup do
22
+ user = create(:user)
23
+ default_headers['Authorization'] = user.token
24
+ end
25
+
26
+ test 'index' do
27
+ get '/api/users.json'
28
+ # Authorization header is sent automatically
29
+
30
+ assert_response :success
31
+ end
32
+ end
33
+ ```
34
+
35
+ Per-request headers are merged with default headers:
36
+
37
+ ```ruby
38
+ class UsersApiTest < ActionDispatch::IntegrationTest
39
+ setup do
40
+ default_headers['Authorization'] = 'your-authorization-token'
41
+ end
42
+
43
+ test 'index as JSON' do
44
+ get '/api/users', headers: {'Accept' => 'application/json'}
45
+ # Both Authorization and Accept headers are sent
46
+
47
+ assert_response :success
48
+ end
49
+ end
50
+ ```
51
+
52
+ ## Contributing
53
+
54
+ 1. Fork it
55
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
56
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
57
+ 4. Push to the branch (`git push origin my-new-feature`)
58
+ 5. Create a new Pull Request
@@ -0,0 +1,5 @@
1
+ module Minitest
2
+ module DefaultHttpHeader
3
+ VERSION = '0.1.0'
4
+ end
5
+ end
@@ -0,0 +1,27 @@
1
+ require 'minitest/default_http_header/version'
2
+ require 'active_support/concern'
3
+ require 'active_support/lazy_load_hooks'
4
+
5
+ module Minitest
6
+ module DefaultHttpHeader
7
+ extend ActiveSupport::Concern
8
+
9
+ HTTP_METHODS = %w(get post put patch delete).freeze
10
+
11
+ def default_headers
12
+ @default_headers ||= {}
13
+ end
14
+
15
+ HTTP_METHODS.each do |m|
16
+ define_method(m) do |path, *args, **kwargs|
17
+ kwargs[:headers] = default_headers.merge(kwargs[:headers] || {})
18
+
19
+ super(path, *args, **kwargs)
20
+ end
21
+ end
22
+ end
23
+ end
24
+
25
+ ActiveSupport.on_load(:action_dispatch_integration_test) do
26
+ include Minitest::DefaultHttpHeader
27
+ end
@@ -0,0 +1 @@
1
+ require 'minitest/default_http_header'
metadata ADDED
@@ -0,0 +1,72 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: minitest-default_http_header
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Keita Urashima
8
+ bindir: bin
9
+ cert_chain: []
10
+ date: 1980-01-02 00:00:00.000000000 Z
11
+ dependencies:
12
+ - !ruby/object:Gem::Dependency
13
+ name: actionpack
14
+ requirement: !ruby/object:Gem::Requirement
15
+ requirements:
16
+ - - ">="
17
+ - !ruby/object:Gem::Version
18
+ version: '7.1'
19
+ type: :runtime
20
+ prerelease: false
21
+ version_requirements: !ruby/object:Gem::Requirement
22
+ requirements:
23
+ - - ">="
24
+ - !ruby/object:Gem::Version
25
+ version: '7.1'
26
+ - !ruby/object:Gem::Dependency
27
+ name: activesupport
28
+ requirement: !ruby/object:Gem::Requirement
29
+ requirements:
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: '7.1'
33
+ type: :runtime
34
+ prerelease: false
35
+ version_requirements: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - ">="
38
+ - !ruby/object:Gem::Version
39
+ version: '7.1'
40
+ email:
41
+ - ursm@ursm.jp
42
+ executables: []
43
+ extensions: []
44
+ extra_rdoc_files: []
45
+ files:
46
+ - LICENSE.txt
47
+ - README.md
48
+ - lib/minitest-default_http_header.rb
49
+ - lib/minitest/default_http_header.rb
50
+ - lib/minitest/default_http_header/version.rb
51
+ homepage: https://github.com/ursm/minitest-default_http_header
52
+ licenses:
53
+ - MIT
54
+ metadata: {}
55
+ rdoc_options: []
56
+ require_paths:
57
+ - lib
58
+ required_ruby_version: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - ">="
61
+ - !ruby/object:Gem::Version
62
+ version: '3.3'
63
+ required_rubygems_version: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - ">="
66
+ - !ruby/object:Gem::Version
67
+ version: '0'
68
+ requirements: []
69
+ rubygems_version: 3.6.9
70
+ specification_version: 4
71
+ summary: Set default HTTP headers in integration tests
72
+ test_files: []