rack-test_app 1.0.0 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8f2ce0590323aed326f765838e0e0ff9fcbafa23
4
- data.tar.gz: ac91d827a933137c4b1a44b15d453f64f3d4c094
3
+ metadata.gz: bcda18c27ea20de2cac4ccd10eb02dd825082316
4
+ data.tar.gz: bb4e19bbf2cfc3fbbeba4eb31a4552423df9dab7
5
5
  SHA512:
6
- metadata.gz: 084c7935751936114289ab16209e1b2e537d9acd4945ad34790ee611fc5cf8a24ef0e0efa6909fe01a0d3c3f2baaed3cc47cb585b51c2378fae373320a58fb85
7
- data.tar.gz: 3982adf894d08f028bded159fe9f6e30ee9a3142a0e21cad104402e88b09abf9fc8f18b39f741075a79b5852db877fb3473d56ca428c6d0ec1149e160521a987
6
+ metadata.gz: fc9e70351334d583198c599ce3f5fe01f058af68f817532feafdff86191efdbf62f390ba9cb8d7739168dbfab036012d7c799ef0cff2ad14e9bc0e3dfed10fc9
7
+ data.tar.gz: fcb95b8bc2656ed4423595586c3e55e7ab1f6ed989374325a7703851fc5c8de8d320805f3f0704969cebfef86c8af5fc39e25be9bb03318c415370c057f63223
data/README.md CHANGED
@@ -36,7 +36,7 @@ app = proc {|env|
36
36
  [200, headers, [text]]
37
37
  }
38
38
 
39
- ## crate wrapper objects
39
+ ## create wrapper objects
40
40
  http = Rack::TestApp.wrap(Rack::Lint.new(app))
41
41
  https = Rack::TestApp.wrap(Rack::Lint.new(app), env: {'HTTPS'=>'on'})
42
42
 
@@ -1,3 +1,7 @@
1
+ # -*- coding: utf-8 -*-
2
+
3
+ copyright = "copyright(c) 2015-2021 kuwata-lab.com all rights reserved"
4
+
1
5
  require "bundler/gem_tasks"
2
6
  require "rake/testtask"
3
7
 
@@ -25,8 +29,11 @@ How to release:
25
29
  $ git commit -a -m "release preparation for 1.0.0"
26
30
  $ rake build # for confirmation
27
31
  $ rake install # for confirmation
28
- $ rake release
29
- $ git push -u --tags origin rel-1.0
32
+ $ #rake release
33
+ $ gem push pkg/rack-test_app-1.0.0.gem
34
+ $ git tag rel-1.0.0
35
+ $ git push -u origin rel-1.0
36
+ $ git push --tags
30
37
  END
31
38
 
32
39
  end
@@ -38,12 +45,27 @@ task :edit do
38
45
  raise "ERROR: 'rel' environment variable expected."
39
46
  filenames = Dir[*%w[lib/**/*.rb test/**/*_test.rb]]
40
47
  filenames.each do |fname|
41
- File.open(fname, 'r+', encoding: 'utf-8') do |f|
42
- content = f.read()
43
- x = content.gsub!(/\$Release:.*?\$/, "$Release: #{rel} $")
48
+ changed = edit_file(fname) {|s|
49
+ s = s.gsub(/\$Release:.*?\$/, "$"+"Release: #{rel} $")
50
+ #s = s.gsub(/\$Copyright:.*?\$/, "$"+"Copyright: #{copyright} $")
51
+ s
52
+ }
53
+ puts "[changed] #{fname}" if changed
54
+ end
55
+ end
56
+
57
+
58
+ def edit_file(fname, &b)
59
+ File.open(fname, 'r+', encoding: 'utf-8') do |f|
60
+ s1 = f.read()
61
+ s2 = yield s1
62
+ if s1 != s2
44
63
  f.rewind()
45
64
  f.truncate(0)
46
- f.write(content)
65
+ f.write(s2)
66
+ return true
67
+ else
68
+ return false
47
69
  end
48
70
  end
49
71
  end
data/lib/rack/test_app.rb CHANGED
@@ -1,8 +1,8 @@
1
1
  # -*- coding: utf-8 -*-
2
2
 
3
3
  ###
4
- ### $Release: 1.0.0 $
5
- ### $Copyright: copyright(c) 2015 kuwata-lab.com all rights reserved $
4
+ ### $Release: 1.1.0 $
5
+ ### $Copyright: copyright(c) 2015-2021 kuwata-lab.com all rights reserved $
6
6
  ### $License: MIT License $
7
7
  ###
8
8
 
@@ -20,7 +20,7 @@ module Rack
20
20
 
21
21
  module TestApp
22
22
 
23
- VERSION = '$Release: 1.0.0 $'.split()[1]
23
+ VERSION = '$Release: 1.1.0 $'.split()[1]
24
24
 
25
25
 
26
26
  module Util
@@ -232,7 +232,7 @@ module Rack
232
232
  end
233
233
  input = multipart.to_s
234
234
  #; [!dq33d] sets content type with 'multipart/form-data'.
235
- m = /\A--(\S+)\r\n/.match(input) or
235
+ input =~ /\A--(\S+)\r\n/ or
236
236
  raise ArgumentError.new("invalid multipart format.")
237
237
  boundary = $1
238
238
  ctype = "multipart/form-data; boundary=#{boundary}"
@@ -428,7 +428,7 @@ module Rack
428
428
  def with(headers: nil, cookies: nil, env: nil)
429
429
  tmp_env = TestApp.new_env(headers: headers, cookies: cookies, env: env)
430
430
  new_env = @env ? @env.dup : {}
431
- http_headers = tmp_env.each do |k, v|
431
+ tmp_env.each do |k, v|
432
432
  new_env[k] = v if k.start_with?('HTTP_')
433
433
  end
434
434
  new_wrapper = self.class.new(@app, new_env)
@@ -452,14 +452,14 @@ module Rack
452
452
  return Result.new(status, headers, body)
453
453
  end
454
454
 
455
- def GET path, kwargs={}; request(:GET , path, kwargs); end
456
- def POST path, kwargs={}; request(:POST , path, kwargs); end
457
- def PUT path, kwargs={}; request(:PUT , path, kwargs); end
458
- def DELETE path, kwargs={}; request(:DELETE , path, kwargs); end
459
- def HEAD path, kwargs={}; request(:HEAD , path, kwargs); end
460
- def PATCH path, kwargs={}; request(:PATCH , path, kwargs); end
461
- def OPTIONS path, kwargs={}; request(:OPTIONS, path, kwargs); end
462
- def TRACE path, kwargs={}; request(:TRACE , path, kwargs); end
455
+ def GET path, kwargs={}; request(:GET , path, **kwargs); end
456
+ def POST path, kwargs={}; request(:POST , path, **kwargs); end
457
+ def PUT path, kwargs={}; request(:PUT , path, **kwargs); end
458
+ def DELETE path, kwargs={}; request(:DELETE , path, **kwargs); end
459
+ def HEAD path, kwargs={}; request(:HEAD , path, **kwargs); end
460
+ def PATCH path, kwargs={}; request(:PATCH , path, **kwargs); end
461
+ def OPTIONS path, kwargs={}; request(:OPTIONS, path, **kwargs); end
462
+ def TRACE path, kwargs={}; request(:TRACE , path, **kwargs); end
463
463
 
464
464
  ## define aliases because ruby programmer prefers #get() rather than #GET().
465
465
  alias get GET
@@ -6,8 +6,8 @@ require 'rack/test_app'
6
6
  Gem::Specification.new do |spec|
7
7
  spec.name = "rack-test_app"
8
8
  spec.version = Rack::TestApp::VERSION
9
- spec.authors = ["makoto kuwata"]
10
- spec.email = ["kwa@kuwata-lab.com"]
9
+ spec.authors = ["kwatch"]
10
+ spec.email = ["kwatch@gmail.com"]
11
11
  spec.summary = "more intuitive testing helper library for Rack app"
12
12
  spec.description = <<END
13
13
  Rack::TestApp is another testing helper library for Rack application.
@@ -16,7 +16,7 @@ END
16
16
  spec.homepage = "https://github.com/kwatch/rack-test_app"
17
17
  spec.license = "MIT-LICENCE"
18
18
  spec.files = Dir[*%w[
19
- README.md MIT-LICENSE.txt Rakefile rack-test_app.gemspec
19
+ README.md MIT-LICENSE.txt Rakefile.rb rack-test_app.gemspec
20
20
  lib/rack/test_app.rb
21
21
  test/test_helper.rb
22
22
  test/rack/**/*_test.rb
@@ -24,8 +24,6 @@ END
24
24
  ]]
25
25
  spec.require_paths = ["lib"]
26
26
  spec.required_ruby_version = '>= 2.0'
27
- spec.add_runtime_dependency 'rack'
28
- spec.add_development_dependency "bundler", "~> 1.10"
29
- spec.add_development_dependency "rake", "~> 10.0"
27
+ spec.add_runtime_dependency "rack"
30
28
  spec.add_development_dependency "minitest"
31
29
  end
@@ -1,8 +1,8 @@
1
1
  # -*- coding: utf-8 -*-
2
2
 
3
3
  ###
4
- ### $Release: 1.0.0 $
5
- ### $Copyright: copyright(c) 2015 kuwata-lab.com all rights reserved $
4
+ ### $Release: 1.1.0 $
5
+ ### $Copyright: copyright(c) 2015-2021 kuwata-lab.com all rights reserved $
6
6
  ### $License: MIT License $
7
7
  ###
8
8
 
@@ -1,8 +1,8 @@
1
1
  # -*- coding: utf-8 -*-
2
2
 
3
3
  ###
4
- ### $Release: 1.0.0 $
5
- ### $Copyright: copyright(c) 2015 kuwata-lab.com all rights reserved $
4
+ ### $Release: 1.1.0 $
5
+ ### $Copyright: copyright(c) 2015-2021 kuwata-lab.com all rights reserved $
6
6
  ### $License: MIT License $
7
7
  ###
8
8
 
@@ -175,7 +175,7 @@ describe Rack::TestApp::Result do
175
175
  it "[!oapns] returns nil if cookie not exists." do
176
176
  headers = {'Set-Cookie' => 'name1=value1'}
177
177
  r = Rack::TestApp::Result.new(200, headers, [])
178
- assert_equal nil, r.cookie_value('name2')
178
+ assert_nil r.cookie_value('name2')
179
179
  end
180
180
 
181
181
  end
@@ -1,8 +1,8 @@
1
1
  # -*- coding: utf-8 -*-
2
2
 
3
3
  ###
4
- ### $Release: 1.0.0 $
5
- ### $Copyright: copyright(c) 2015 kuwata-lab.com all rights reserved $
4
+ ### $Release: 1.1.0 $
5
+ ### $Copyright: copyright(c) 2015-2021 kuwata-lab.com all rights reserved $
6
6
  ### $License: MIT License $
7
7
  ###
8
8
 
@@ -20,7 +20,7 @@ describe Rack::TestApp do
20
20
  describe '::VERSION' do
21
21
 
22
22
  it "represents release version number." do
23
- expected = '$Release: 1.0.0 $'.split()[1]
23
+ expected = '$Release: 1.1.0 $'.split()[1]
24
24
  assert_equal expected, Rack::TestApp::VERSION
25
25
  end
26
26
 
@@ -103,7 +103,8 @@ describe Rack::TestApp do
103
103
 
104
104
  it "[!dq33d] sets content type with 'multipart/form-data'." do
105
105
  env = Rack::TestApp.new_env(multipart: {})
106
- assert_match /\Amultipart\/form-data; boundary=\S+\z/, env['CONTENT_TYPE']
106
+ rexp = /\Amultipart\/form-data; boundary=\S+\z/
107
+ assert_match rexp, env['CONTENT_TYPE']
107
108
  end
108
109
 
109
110
  it "[!gko8g] 'multipart:' kwarg accepts Hash object (which is converted into multipart data)." do
@@ -149,7 +150,7 @@ describe Rack::TestApp do
149
150
  #
150
151
  assert_equal Rack::VERSION , env['rack.version']
151
152
  assert_kind_of Array , env['rack.version']
152
- assert_match /\A\[1, \d+\]\z/, env['rack.version'].inspect
153
+ assert_match(/\A\[1, \d+\]\z/, env['rack.version'].inspect)
153
154
  assert_kind_of StringIO , env['rack.input']
154
155
  assert_kind_of StringIO , env['rack.errors']
155
156
  assert_equal true , env['rack.multithread']
@@ -166,7 +167,7 @@ describe Rack::TestApp do
166
167
  assert_equal 'off' , env['HTTPS']
167
168
  assert_equal '' , env['SCRIPT_NAME']
168
169
  assert_equal '0' , env['CONTENT_LENGTH']
169
- assert_equal nil , env['CONTENT_TYPE']
170
+ assert_nil env['CONTENT_TYPE']
170
171
  end
171
172
 
172
173
  it "[!ezvdn] unsets CONTENT_TYPE when not input." do
@@ -1,8 +1,8 @@
1
1
  # -*- coding: utf-8 -*-
2
2
 
3
3
  ###
4
- ### $Release: 1.0.0 $
5
- ### $Copyright: copyright(c) 2015 kuwata-lab.com all rights reserved $
4
+ ### $Release: 1.1.0 $
5
+ ### $Copyright: copyright(c) 2015-2021 kuwata-lab.com all rights reserved $
6
6
  ### $License: MIT License $
7
7
  ###
8
8
 
@@ -36,8 +36,7 @@ describe Rack::TestApp::Util do
36
36
  describe '.#build_query_string()' do
37
37
 
38
38
  it "[!098ac] returns nil when argument is nil." do
39
- expected = nil
40
- assert_equal expected, Rack::TestApp::Util.build_query_string(nil)
39
+ assert_nil Rack::TestApp::Util.build_query_string(nil)
41
40
  end
42
41
 
43
42
  it "[!z9ds2] returns argument itself when it is a string." do
@@ -116,7 +115,7 @@ describe Rack::TestApp::Util do
116
115
  set_cookie = "name1=value1; Max-Age=3600"
117
116
  c = Rack::TestApp::Util.parse_set_cookie(set_cookie)
118
117
  assert_equal 3600, c[:max_age]
119
- assert_kind_of Fixnum, c[:max_age]
118
+ assert_kind_of Integer, c[:max_age]
120
119
  end
121
120
 
122
121
  it "[!wgzyz] raises error when Max-Age attribute value is not a positive integer." do
@@ -140,7 +139,7 @@ describe Rack::TestApp::Util do
140
139
  arr = (1..1000).map { Rack::TestApp::Util.randstr_b64() }
141
140
  assert_equal 1000, arr.sort.uniq.length
142
141
  arr.each do |s|
143
- assert_match /\A[-\w]+\z/, s
142
+ assert_match(/\A[-\w]+\z/, s)
144
143
  assert_equal 27, s.length
145
144
  end
146
145
  end
@@ -1,8 +1,8 @@
1
1
  # -*- coding: utf-8 -*-
2
2
 
3
3
  ###
4
- ### $Release: 1.0.0 $
5
- ### $Copyright: copyright(c) 2015 kuwata-lab.com all rights reserved $
4
+ ### $Release: 1.1.0 $
5
+ ### $Copyright: copyright(c) 2015-2021 kuwata-lab.com all rights reserved $
6
6
  ### $License: MIT License $
7
7
  ###
8
8
 
@@ -31,7 +31,7 @@ describe Rack::TestApp::Wrapper do
31
31
  #
32
32
  wrapper = Rack::TestApp::Wrapper.new(app)
33
33
  assert_equal app, wrapper.instance_variable_get('@app')
34
- assert_equal nil, wrapper.instance_variable_get('@env')
34
+ assert_nil wrapper.instance_variable_get('@env')
35
35
  end
36
36
 
37
37
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rack-test_app
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
- - makoto kuwata
7
+ - kwatch
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-11-21 00:00:00.000000000 Z
11
+ date: 2021-08-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rack
@@ -24,34 +24,6 @@ dependencies:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
- - !ruby/object:Gem::Dependency
28
- name: bundler
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - "~>"
32
- - !ruby/object:Gem::Version
33
- version: '1.10'
34
- type: :development
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - "~>"
39
- - !ruby/object:Gem::Version
40
- version: '1.10'
41
- - !ruby/object:Gem::Dependency
42
- name: rake
43
- requirement: !ruby/object:Gem::Requirement
44
- requirements:
45
- - - "~>"
46
- - !ruby/object:Gem::Version
47
- version: '10.0'
48
- type: :development
49
- prerelease: false
50
- version_requirements: !ruby/object:Gem::Requirement
51
- requirements:
52
- - - "~>"
53
- - !ruby/object:Gem::Version
54
- version: '10.0'
55
27
  - !ruby/object:Gem::Dependency
56
28
  name: minitest
57
29
  requirement: !ruby/object:Gem::Requirement
@@ -70,14 +42,14 @@ description: |
70
42
  Rack::TestApp is another testing helper library for Rack application.
71
43
  IMO it is more intuitive than Rack::Test.
72
44
  email:
73
- - kwa@kuwata-lab.com
45
+ - kwatch@gmail.com
74
46
  executables: []
75
47
  extensions: []
76
48
  extra_rdoc_files: []
77
49
  files:
78
50
  - MIT-LICENSE.txt
79
51
  - README.md
80
- - Rakefile
52
+ - Rakefile.rb
81
53
  - lib/rack/test_app.rb
82
54
  - rack-test_app.gemspec
83
55
  - test/rack/test_app/MultipartBuilder_test.rb
@@ -109,7 +81,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
109
81
  version: '0'
110
82
  requirements: []
111
83
  rubyforge_project:
112
- rubygems_version: 2.4.5.1
84
+ rubygems_version: 2.5.2.3
113
85
  signing_key:
114
86
  specification_version: 4
115
87
  summary: more intuitive testing helper library for Rack app