grape-app 0.10.0 → 0.10.1

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
  SHA256:
3
- metadata.gz: a02f28a09a9bf9ac9f5222de88c553958c3984017e2b589dd0ad2f1850503513
4
- data.tar.gz: 869efcb8480678cff8924d6001cf3342cf0ae9558577a7d856ed572e8d3e2eef
3
+ metadata.gz: 74079cb85645ce520a781a57a58de041ea2fd7d99d6a8fbbb2f8666a98cd1c2e
4
+ data.tar.gz: 1cf09f82decf2ca06f82857d6865eeb1e0e0271a4abaf701bba1aa3018097c5b
5
5
  SHA512:
6
- metadata.gz: b989f27b49f52f4247518dc5bb485de10d08149ca7da7eb912a53b8e6875bc68d82f8798bbd4d7e086e934b73523fbb384ff1359bc193153fe8f9baf59fa6180
7
- data.tar.gz: 01d7a80d34def80bf67e85b55ebd47b274c16b0acb384bd86ea41fca9b5fa99da305966d700824a1113e900e4cc11b03907f28c13e0751baf23ecfec17fca8bb
6
+ metadata.gz: 77ae37fd42d9e2fd696801599fccc387bcd39c081f53d2fd4995c59b166cff43041b4ca0fa35cd7187e37775cd0441f15cab3212adb355306ef3ff59da12feca
7
+ data.tar.gz: 544d948b260b034f26bdc7dc11e2b7961186ed6f0ce3fabacbc16fe890f3b85ecab4a32ea578fc578009053a1f43570987b2adff2e972cbb968b7c24704b99e6
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- grape-app (0.10.0)
4
+ grape-app (0.10.1)
5
5
  activesupport
6
6
  grape (>= 1.2)
7
7
  grape-entity
@@ -14,24 +14,24 @@ PATH
14
14
  GEM
15
15
  remote: https://rubygems.org/
16
16
  specs:
17
- activejob (7.0.1)
18
- activesupport (= 7.0.1)
17
+ activejob (7.0.3)
18
+ activesupport (= 7.0.3)
19
19
  globalid (>= 0.3.6)
20
- activemodel (7.0.1)
21
- activesupport (= 7.0.1)
22
- activerecord (7.0.1)
23
- activemodel (= 7.0.1)
24
- activesupport (= 7.0.1)
25
- activesupport (7.0.1)
20
+ activemodel (7.0.3)
21
+ activesupport (= 7.0.3)
22
+ activerecord (7.0.3)
23
+ activemodel (= 7.0.3)
24
+ activesupport (= 7.0.3)
25
+ activesupport (7.0.3)
26
26
  concurrent-ruby (~> 1.0, >= 1.0.2)
27
27
  i18n (>= 1.6, < 2)
28
28
  minitest (>= 5.1)
29
29
  tzinfo (~> 2.0)
30
30
  ast (2.4.2)
31
31
  builder (3.2.4)
32
- concurrent-ruby (1.1.9)
32
+ concurrent-ruby (1.1.10)
33
33
  diff-lcs (1.5.0)
34
- dry-configurable (0.14.0)
34
+ dry-configurable (0.15.0)
35
35
  concurrent-ruby (~> 1.0)
36
36
  dry-core (~> 0.6)
37
37
  dry-container (0.9.0)
@@ -61,19 +61,19 @@ GEM
61
61
  grape-entity (0.10.1)
62
62
  activesupport (>= 3.0.0)
63
63
  multi_json (>= 1.3.2)
64
- i18n (1.9.1)
64
+ i18n (1.10.0)
65
65
  concurrent-ruby (~> 1.0)
66
66
  minitest (5.15.0)
67
67
  multi_json (1.15.0)
68
68
  mustermann (1.1.1)
69
69
  ruby2_keywords (~> 0.0.1)
70
- mustermann-grape (1.0.1)
70
+ mustermann-grape (1.0.2)
71
71
  mustermann (>= 1.0.0)
72
72
  openssl (3.0.0)
73
- parallel (1.21.0)
74
- parser (3.1.0.0)
73
+ parallel (1.22.1)
74
+ parser (3.1.2.0)
75
75
  ast (~> 2.4.1)
76
- rack (2.2.3)
76
+ rack (2.2.3.1)
77
77
  rack-accept (0.4.5)
78
78
  rack (>= 0.4)
79
79
  rack-cors (1.1.1)
@@ -83,43 +83,43 @@ GEM
83
83
  rack (>= 1.0, < 3)
84
84
  rainbow (3.1.1)
85
85
  rake (13.0.6)
86
- regexp_parser (2.2.0)
86
+ regexp_parser (2.5.0)
87
87
  rexml (3.2.5)
88
- rspec (3.10.0)
89
- rspec-core (~> 3.10.0)
90
- rspec-expectations (~> 3.10.0)
91
- rspec-mocks (~> 3.10.0)
92
- rspec-core (3.10.2)
93
- rspec-support (~> 3.10.0)
94
- rspec-expectations (3.10.2)
88
+ rspec (3.11.0)
89
+ rspec-core (~> 3.11.0)
90
+ rspec-expectations (~> 3.11.0)
91
+ rspec-mocks (~> 3.11.0)
92
+ rspec-core (3.11.0)
93
+ rspec-support (~> 3.11.0)
94
+ rspec-expectations (3.11.0)
95
95
  diff-lcs (>= 1.2.0, < 2.0)
96
- rspec-support (~> 3.10.0)
97
- rspec-mocks (3.10.3)
96
+ rspec-support (~> 3.11.0)
97
+ rspec-mocks (3.11.1)
98
98
  diff-lcs (>= 1.2.0, < 2.0)
99
- rspec-support (~> 3.10.0)
100
- rspec-support (3.10.3)
101
- rubocop (1.25.1)
99
+ rspec-support (~> 3.11.0)
100
+ rspec-support (3.11.0)
101
+ rubocop (1.30.1)
102
102
  parallel (~> 1.10)
103
103
  parser (>= 3.1.0.0)
104
104
  rainbow (>= 2.2.2, < 4.0)
105
105
  regexp_parser (>= 1.8, < 3.0)
106
- rexml
107
- rubocop-ast (>= 1.15.1, < 2.0)
106
+ rexml (>= 3.2.5, < 4.0)
107
+ rubocop-ast (>= 1.18.0, < 2.0)
108
108
  ruby-progressbar (~> 1.7)
109
109
  unicode-display_width (>= 1.4.0, < 3.0)
110
- rubocop-ast (1.15.1)
111
- parser (>= 3.0.1.1)
110
+ rubocop-ast (1.18.0)
111
+ parser (>= 3.1.1.0)
112
112
  rubocop-bsm (0.6.0)
113
113
  rubocop (~> 1.0)
114
114
  rubocop-performance
115
115
  rubocop-rake
116
116
  rubocop-rspec
117
- rubocop-performance (1.13.2)
117
+ rubocop-performance (1.14.1)
118
118
  rubocop (>= 1.7.0, < 2.0)
119
119
  rubocop-ast (>= 0.4.0)
120
120
  rubocop-rake (0.6.0)
121
121
  rubocop (~> 1.0)
122
- rubocop-rspec (2.8.0)
122
+ rubocop-rspec (2.11.1)
123
123
  rubocop (~> 1.19)
124
124
  ruby-progressbar (1.11.0)
125
125
  ruby2_keywords (0.0.5)
@@ -145,4 +145,4 @@ DEPENDENCIES
145
145
  sqlite3
146
146
 
147
147
  BUNDLED WITH
148
- 2.3.4
148
+ 2.3.9
data/grape-app.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'grape-app'
3
- s.version = '0.10.0'
3
+ s.version = '0.10.1'
4
4
  s.authors = ['Black Square Media Ltd']
5
5
  s.email = ['info@blacksquaremedia.com']
6
6
  s.summary = %(Standalone Grape API apps)
@@ -9,7 +9,6 @@ Gem::Specification.new do |s|
9
9
  s.license = 'MIT'
10
10
 
11
11
  s.files = `git ls-files -z`.split("\x0").reject {|f| f.match(%r{^spec/}) }
12
- s.test_files = `git ls-files -z -- spec/*`.split("\x0")
13
12
  s.executables = ['grape-app']
14
13
  s.require_paths = ['lib']
15
14
  s.required_ruby_version = '>= 2.7'
@@ -23,11 +23,10 @@ namespace :db do
23
23
 
24
24
  desc 'Create a new migration using NAME'
25
25
  task migration: :environment do
26
- abort 'No NAME specified. Example usage: `rake db:migration NAME=create_widgets`' unless ENV['NAME']
26
+ name = ENV.fetch('NAME', nil)
27
+ abort 'No NAME specified. Example usage: `rake db:migration NAME=create_widgets`' unless name
27
28
 
28
29
  migrations_path = ActiveRecord::Migrator.migrations_paths.first
29
-
30
- name = ENV['NAME']
31
30
  path = File.join(migrations_path, "#{Time.now.utc.strftime('%Y%m%d%H%M%S')}_#{name}.rb")
32
31
 
33
32
  ar_version = [ActiveRecord::VERSION::MAJOR, ActiveRecord::VERSION::MINOR].join('.')
data/lib/grape/app.rb CHANGED
@@ -62,7 +62,7 @@ class Grape::App < Grape::API
62
62
 
63
63
  # @return [ActiveSupport::StringInquirer] env name
64
64
  def env
65
- @env ||= ActiveSupport::StringInquirer.new(ENV['GRAPE_ENV'] || ENV['RACK_ENV'] || 'development')
65
+ @env ||= ActiveSupport::StringInquirer.new(ENV.fetch('GRAPE_ENV') { ENV.fetch('RACK_ENV', 'development') })
66
66
  end
67
67
 
68
68
  # @return [Zeitwerk::Loader] loader
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: grape-app
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.10.0
4
+ version: 0.10.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Black Square Media Ltd
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-02-07 00:00:00.000000000 Z
11
+ date: 2022-06-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -285,19 +285,6 @@ files:
285
285
  - lib/grape/app/templates/db/seeds.rb
286
286
  - lib/grape/app/templates/spec/spec_helper.rb
287
287
  - lib/grape_app.rb
288
- - spec/grape/app/helpers/caching_spec.rb
289
- - spec/grape/app/helpers/params_spec.rb
290
- - spec/grape/app/middleware/connection_management_spec.rb
291
- - spec/grape/app_spec.rb
292
- - spec/scenario/Gemfile
293
- - spec/scenario/app/api.rb
294
- - spec/scenario/app/api/posts.rb
295
- - spec/scenario/app/api/v1.rb
296
- - spec/scenario/config/database.yml
297
- - spec/scenario/config/environments/test.rb
298
- - spec/scenario/config/locales/en.yml
299
- - spec/scenario/lib/my_lib.rb
300
- - spec/spec_helper.rb
301
288
  homepage: https://github.com/bsm/grape-app
302
289
  licenses:
303
290
  - MIT
@@ -318,21 +305,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
318
305
  - !ruby/object:Gem::Version
319
306
  version: '0'
320
307
  requirements: []
321
- rubygems_version: 3.3.3
308
+ rubygems_version: 3.3.7
322
309
  signing_key:
323
310
  specification_version: 4
324
311
  summary: Standalone Grape API apps
325
- test_files:
326
- - spec/grape/app/helpers/caching_spec.rb
327
- - spec/grape/app/helpers/params_spec.rb
328
- - spec/grape/app/middleware/connection_management_spec.rb
329
- - spec/grape/app_spec.rb
330
- - spec/scenario/Gemfile
331
- - spec/scenario/app/api.rb
332
- - spec/scenario/app/api/posts.rb
333
- - spec/scenario/app/api/v1.rb
334
- - spec/scenario/config/database.yml
335
- - spec/scenario/config/environments/test.rb
336
- - spec/scenario/config/locales/en.yml
337
- - spec/scenario/lib/my_lib.rb
338
- - spec/spec_helper.rb
312
+ test_files: []
@@ -1,105 +0,0 @@
1
- require 'spec_helper'
2
-
3
- RSpec.describe Grape::App::Helpers::Caching do
4
- include Rack::Test::Methods
5
-
6
- let :app do
7
- helper = described_class
8
- Class.new(Grape::API) do
9
- format :json
10
-
11
- helpers helper
12
-
13
- get '/articles' do
14
- scope = Article.order(:id)
15
- opts = params[:public] ? { public: params[:public] } : {}
16
- fresh_when(scope, **opts)
17
- scope.to_a
18
- end
19
-
20
- get '/articles/never_updated' do
21
- article = Article.first
22
- article.updated_at = nil
23
-
24
- fresh_when(article, last_modified_field: :created_at)
25
- end
26
-
27
- get '/articles/:id' do
28
- article = Article.first
29
- article if stale?(article, stale_if_error: 5, extras: { a: 1, b: 2 })
30
- end
31
- end
32
- end
33
- let(:created_at) { Time.at(1515151500).utc }
34
-
35
- before do
36
- Article.create! title: 'Welcome', created_at: created_at, updated_at: created_at + 10
37
- Article.create! title: 'Bye', created_at: created_at, updated_at: created_at + 20
38
- end
39
-
40
- it 'handles fresh-when' do
41
- get '/articles'
42
- expect(last_response.status).to eq(200)
43
- expect(last_response.headers).to include(
44
- 'Content-Type' => 'application/json',
45
- 'ETag' => 'a5f6c4b024510c9835d8d70cbd3ed00c',
46
- 'Last-Modified' => 'Fri, 05 Jan 2018 11:25:20 GMT',
47
- )
48
- expect(JSON.parse(last_response.body).size).to eq(2)
49
-
50
- get '/articles', {}, 'HTTP_IF_NONE_MATCH' => last_response.headers['ETag']
51
- expect(last_response.status).to eq(304)
52
- get '/articles', {}, 'HTTP_IF_MODIFIED_SINCE' => 'Fri, 05 Jan 2018 11:25:20 GMT'
53
- expect(last_response.status).to eq(304)
54
- get '/articles', {}, 'HTTP_IF_NONE_MATCH' => last_response.headers['ETag'], 'HTTP_IF_MODIFIED_SINCE' => 'Fri, 05 Jan 2018 11:25:21 GMT'
55
- expect(last_response.status).to eq(304)
56
-
57
- get '/articles', {}, 'HTTP_IF_MODIFIED_SINCE' => 'Fri, 05 Jan 2018 11:25:19 GMT'
58
- expect(last_response.status).to eq(200)
59
- get '/articles', {}, 'HTTP_IF_MODIFIED_SINCE' => 'Fri, 05 Jan 2018 11:25:19 GMT', 'HTTP_IF_NONE_MATCH' => last_response.headers['ETag']
60
- expect(last_response.status).to eq(200)
61
- get '/articles', {}, 'HTTP_IF_MODIFIED_SINCE' => 'Fri, 05 Jan 2018 11:25:20 GMT', 'HTTP_IF_NONE_MATCH' => 'other'
62
- expect(last_response.status).to eq(200)
63
- end
64
-
65
- it 'handles fresh_when for records that were never updated' do
66
- get '/articles/never_updated'
67
- expect(last_response.status).to eq(200)
68
- expect(last_response.headers).to include(
69
- 'Last-Modified' => 'Fri, 05 Jan 2018 11:25:00 GMT',
70
- )
71
- end
72
-
73
- it 'supports cache-control' do
74
- get '/articles?public=true'
75
- expect(last_response.status).to eq(200)
76
- expect(last_response.headers).to include(
77
- 'Cache-Control' => 'public',
78
- )
79
- end
80
-
81
- it 'handles stale? (with cache-control)' do
82
- get '/articles/1'
83
- expect(last_response.status).to eq(200)
84
- expect(last_response.headers).to include(
85
- 'Cache-Control' => 'private, stale-if-error=5, a=1, b=2',
86
- 'Content-Type' => 'application/json',
87
- 'ETag' => '0154407bafc97186a494a05e0652ff61',
88
- 'Last-Modified' => 'Fri, 05 Jan 2018 11:25:10 GMT',
89
- )
90
- expect(JSON.parse(last_response.body)).to eq(
91
- 'id' => 1,
92
- 'title' => 'Welcome',
93
- 'updated_at' => '2018-01-05T11:25:10.000Z',
94
- 'created_at' => '2018-01-05T11:25:00.000Z',
95
- )
96
-
97
- get '/articles/1', {}, 'HTTP_IF_NONE_MATCH' => last_response.headers['ETag']
98
- expect(last_response.status).to eq(304)
99
- expect(last_response.headers).to include(
100
- 'Cache-Control' => 'private, stale-if-error=5, a=1, b=2',
101
- 'ETag' => '0154407bafc97186a494a05e0652ff61',
102
- 'Last-Modified' => 'Fri, 05 Jan 2018 11:25:10 GMT',
103
- )
104
- end
105
- end
@@ -1,34 +0,0 @@
1
- require 'spec_helper'
2
-
3
- RSpec.describe Grape::App::Helpers::Params do
4
- include Rack::Test::Methods
5
-
6
- let :app do
7
- helper = described_class
8
- Class.new(Grape::API) do
9
- format :json
10
-
11
- helpers helper
12
-
13
- params do
14
- optional :title
15
- end
16
- post '/articles' do
17
- attrs = { id: 9, updated_at: Time.at(1515151515).utc }
18
- attrs.update(declared_params)
19
- Article.new(attrs)
20
- end
21
- end
22
- end
23
-
24
- it 'limits params' do
25
- post '/articles', title: 'Today', id: 1234, updated_at: Time.now
26
- expect(last_response.status).to eq(201)
27
- expect(JSON.parse(last_response.body)).to eq(
28
- 'created_at' => nil,
29
- 'id' => 9,
30
- 'title' => 'Today',
31
- 'updated_at' => '2018-01-05T11:25:15.000Z',
32
- )
33
- end
34
- end
@@ -1,22 +0,0 @@
1
- require 'spec_helper'
2
-
3
- RSpec.describe Grape::App::Middleware::ConnectionManagement do
4
- include Rack::Test::Methods
5
-
6
- let :app do
7
- failing = ->(_) { raise(ActiveRecord::StatementInvalid) }
8
- middleware = described_class
9
- Rack::Builder.new do
10
- use middleware
11
- run failing
12
- end
13
- end
14
-
15
- it 'clears active connections' do
16
- ActiveRecord::Base.connection
17
- expect(ActiveRecord::Base.connection_handler).to be_active_connections
18
-
19
- expect { get '/' }.to raise_error(ActiveRecord::StatementInvalid)
20
- expect(ActiveRecord::Base.connection_handler).not_to be_active_connections
21
- end
22
- end
@@ -1,102 +0,0 @@
1
- require 'spec_helper'
2
-
3
- RSpec.describe Grape::App do
4
- include Rack::Test::Methods
5
-
6
- subject { described_class }
7
-
8
- before { subject.init! File.expand_path('../scenario', __dir__) }
9
-
10
- def app
11
- subject.middleware
12
- end
13
-
14
- it 'has an env' do
15
- expect(subject.env).to be_instance_of(ActiveSupport::StringInquirer)
16
- expect(subject.env).to eq('test')
17
- end
18
-
19
- it 'has an root' do
20
- expect(subject.root).to be_instance_of(Pathname)
21
- end
22
-
23
- it 'is an API instance' do
24
- expect(subject).to be < Grape::API
25
- end
26
-
27
- it 'inits with default time zone' do
28
- expect(Time.zone.name).to eq('UTC')
29
- expect(Thread.new { Time.zone }.value.name).to eq('UTC')
30
- end
31
-
32
- it 'configures i18n' do
33
- expect(I18n.load_path).to include(subject.root.join('config', 'locales', 'en.yml').to_s)
34
- expect(I18n.default_locale).to eq(:en)
35
- expect(I18n.exception_handler).to be_a(I18n::ExceptionHandler)
36
- end
37
-
38
- it 'configures ActiveSupport' do
39
- expect(ActiveSupport.to_time_preserves_timezone).to be(true)
40
- expect(ActiveSupport.utc_to_local_returns_utc_offset_times).to be(true)
41
- expect(ActiveSupport::Digest.hash_digest_class).to be(OpenSSL::Digest::SHA256)
42
- expect(ActiveSupport::MessageEncryptor.use_authenticated_message_encryption).to be(true)
43
- if ActiveSupport::VERSION::MAJOR >= 7
44
- expect(ActiveSupport::KeyGenerator.hash_digest_class).to be(OpenSSL::Digest::SHA256)
45
- expect(ActiveSupport::IsolatedExecutionState.isolation_level).to be(:thread)
46
- expect(Digest::UUID.use_rfc4122_namespaced_uuids).to be(true)
47
- end
48
- end
49
-
50
- it 'configures ActiveRecord' do
51
- if ActiveRecord::VERSION::MAJOR >= 7
52
- expect(ActiveRecord.default_timezone).to be(:utc)
53
- expect(ActiveRecord.legacy_connection_handling).to be(false)
54
- expect(ActiveRecord.verify_foreign_keys_for_fixtures).to be(true)
55
- expect(ActiveRecord::Base.partial_inserts).to be(false)
56
- expect(ActiveRecord::Base.automatic_scope_inversing).to be(true)
57
- end
58
- expect(ActiveRecord::Base.belongs_to_required_by_default).to be(true)
59
- expect(ActiveRecord::Base.cache_versioning).to be(true)
60
- expect(ActiveRecord::Base.collection_cache_versioning).to be(true)
61
- expect(ActiveRecord::Base.has_many_inversing).to be(true)
62
- end
63
-
64
- it 'configures ActiveJob' do
65
- expect(ActiveJob::Base.retry_jitter).to eq(0.15)
66
- end
67
-
68
- it 'reads env specific initializers' do
69
- expect(subject.config).to include(
70
- :test_specific,
71
- :raise_on_missing_translations,
72
- :cors,
73
- :middleware,
74
- )
75
- end
76
-
77
- it 'prepares middleware' do
78
- expect(subject.middleware).to be_instance_of(Rack::Builder)
79
- expect(subject.middleware.send(:instance_variable_get, :@use).size).to eq(3)
80
- expect(subject.middleware.send(:instance_variable_get, :@run)).to be(subject)
81
- end
82
-
83
- it 'applies middleware' do
84
- header 'Origin', 'test.host'
85
- get '/v1/ok'
86
- expect(last_response).to be_ok
87
- expect(last_response.body).to eq(%({"status":"OK"}))
88
- expect(last_response.headers).to include(
89
- 'Access-Control-Allow-Origin' => '*',
90
- 'X-MyApp' => 'true',
91
- )
92
-
93
- header 'Origin', 'test.host'
94
- get '/v1/failing'
95
- expect(last_response).to be_bad_request
96
- expect(last_response.body).to eq(%({"error":"bad request"}))
97
- expect(last_response.headers).to include(
98
- 'Access-Control-Allow-Origin' => '*',
99
- 'X-MyApp' => 'true',
100
- )
101
- end
102
- end
@@ -1,4 +0,0 @@
1
- source 'https://rubygems.org'
2
-
3
- gem 'activerecord', require: 'active_record'
4
- gem 'grape-app', path: '../../'
@@ -1,5 +0,0 @@
1
- class API::Posts < Grape::API
2
- get '/posts' do
3
- []
4
- end
5
- end
@@ -1,18 +0,0 @@
1
- class API::V1 < Grape::API
2
- version 'v1'
3
- format :json
4
-
5
- rescue_from MyLib::BadRequest do |e|
6
- error!({ error: e }, 400)
7
- end
8
-
9
- get '/ok' do
10
- { status: 'OK' }
11
- end
12
-
13
- get '/failing' do
14
- raise MyLib::BadRequest, 'bad request'
15
- end
16
-
17
- mount API::Posts
18
- end
@@ -1,7 +0,0 @@
1
- module API
2
- end
3
-
4
- # Mount root API to app
5
- Grape::App.instance_eval do
6
- mount API::V1
7
- end
@@ -1,3 +0,0 @@
1
- test:
2
- adapter: "sqlite3"
3
- database: ":memory:"
@@ -1,16 +0,0 @@
1
- require 'my_lib'
2
-
3
- Grape::App.configure do |c|
4
- c.eager_load = true
5
- c.test_specific = true
6
- c.raise_on_missing_translations = true
7
- c.cors do
8
- allow do
9
- origins '*'
10
- resource '*', headers: :any, methods: %i[get post options]
11
- end
12
- end
13
- c.middleware do
14
- use MyLib::Middleware
15
- end
16
- end
@@ -1,2 +0,0 @@
1
- en:
2
- hi: hello
@@ -1,16 +0,0 @@
1
- class MyLib
2
- class BadRequest < StandardError
3
- end
4
-
5
- class Middleware
6
- def initialize(app)
7
- @app = app
8
- end
9
-
10
- def call(env)
11
- status, headers, body = @app.call(env)
12
- headers['X-MyApp'] = 'true'
13
- [status, headers, body]
14
- end
15
- end
16
- end
data/spec/spec_helper.rb DELETED
@@ -1,17 +0,0 @@
1
- ENV['RACK_ENV'] ||= 'test'
2
- require 'grape-app'
3
- require 'rack/test'
4
- require 'active_record'
5
- require 'active_job'
6
-
7
- ActiveRecord::Base.configurations = { 'test' => { 'adapter' => 'sqlite3', 'database' => ':memory:' } }
8
- ActiveRecord::Base.establish_connection :test
9
- ActiveRecord::Base.connection.instance_eval do
10
- create_table :articles do |t|
11
- t.string :title
12
- t.timestamps
13
- end
14
- end
15
-
16
- class Article < ActiveRecord::Base
17
- end