micro_api 0.1.0 → 0.1.1

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.
@@ -0,0 +1 @@
1
+ af150e73d4f28d93e9df1d9c9e72060cf01ddb21b1a086cf0de80436ed87277b198852034529aab19dd99fc83d79f069e9fdb2fb6696208781d469a6f3c7c9ca
@@ -0,0 +1,34 @@
1
+ require 'rails_helper'
2
+ require 'rails/generators'
3
+ require 'generators/micro_api/install/install_generator'
4
+
5
+ RSpec.describe MicroApi::InstallGenerator, type: :generator do
6
+ before :all do
7
+ remove_config
8
+ end
9
+
10
+ after :all do
11
+ remove_config
12
+ end
13
+
14
+ it 'installs config file properly' do
15
+ described_class.start
16
+ system "cd spec/dummy/ && bin/rails generate micro_api:install"
17
+ expect(File.file?(config_file)).to be true
18
+ expect(File.file?(staging_env_file)).to be true
19
+ end
20
+
21
+ it 'installs config file properly routing', type: :routing do
22
+ expect(get("#{MicroApi.routes_path}/version")).to route_to(
23
+ controller: 'micro_api/static',
24
+ action: 'version',
25
+ format: :json
26
+ )
27
+
28
+ expect(get("#{MicroApi.routes_path}/healthz")).to route_to(
29
+ controller: 'micro_api/static',
30
+ action: 'healthz',
31
+ format: :json
32
+ )
33
+ end
34
+ end
data/spec/rails_helper.rb CHANGED
@@ -57,4 +57,5 @@ RSpec.configure do |config|
57
57
  # config.filter_gems_from_backtrace("gem name")
58
58
 
59
59
  config.include RequestSpecHelper, type: :request
60
+ config.include FileSpecHelper, type: :generator
60
61
  end
@@ -0,0 +1,20 @@
1
+ require 'rails_helper'
2
+
3
+ RSpec.describe "Statics" do
4
+ describe "GET /healthz" do
5
+ before { @route = get("#{MicroApi.routes_path}/healthz") }
6
+
7
+ it "routes /micro_api/version to the static controller", type: :routing do
8
+ expect(@route).to route_to(
9
+ controller: 'micro_api/static',
10
+ action: 'healthz',
11
+ format: :json
12
+ )
13
+ end
14
+ it "returns http success", type: :request do
15
+ expect(response).to have_http_status(:success)
16
+ expect(response.header['Content-Type']).to include 'application/json'
17
+ expect(json).to have_key('status')
18
+ end
19
+ end
20
+ end
@@ -1,25 +1,14 @@
1
1
  require 'rails_helper'
2
2
 
3
3
  RSpec.describe "Statics", type: :request do
4
- describe "GET /healthz" do
5
- it "returns http success" do
6
- get "/micro_api/healthz"
7
- expect(response).to have_http_status(:success)
8
- expect(response.header['Content-Type']).to include 'application/json'
9
- expect(json).not_to be_empty
10
- expect(json).to have_key('status')
11
- end
12
- end
13
-
14
- describe "GET /version" do
15
- it "returns http success" do
16
- get "/micro_api/version"
17
- expect(response).to have_http_status(:success)
18
- expect(response.header['Content-Type']).to include 'application/json'
19
- expect(json).not_to be_empty
20
- expect(json).to have_key('env')
21
- expect(json).to have_key('cenv')
22
- expect(json).to have_key('itag')
4
+ describe "GET /" do
5
+ context 'when the route does not exist' do
6
+ it "returns http success" do
7
+ get "#{MicroApi.routes_path}/"
8
+ expect(response).to have_http_status(:not_found)
9
+ expect(response.header['Content-Type']).to include 'application/json'
10
+ expect(json).not_to be_empty
11
+ end
23
12
  end
24
13
  end
25
14
  end
@@ -0,0 +1,21 @@
1
+ require 'rails_helper'
2
+
3
+ RSpec.describe "Statics" do
4
+ describe "GET /version" do
5
+ before { @route = get("#{MicroApi.routes_path}/version") }
6
+
7
+ it "returns http success", type: :request do
8
+ expect(response).to have_http_status(:success)
9
+ expect(response.header['Content-Type']).to include 'application/json'
10
+ expect(json.keys).to contain_exactly('ac', 'cenv', 'env', 'itag')
11
+ end
12
+
13
+ it "routes /micro_api/version to the static controller", type: :routing do
14
+ expect(@route).to route_to(
15
+ controller: 'micro_api/static',
16
+ action: 'version',
17
+ format: :json
18
+ )
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,16 @@
1
+ require 'fileutils'
2
+
3
+ module FileSpecHelper
4
+ def config_file
5
+ "#{Rails.root}/config/initializers/micro_api.rb"
6
+ end
7
+
8
+ def staging_env_file
9
+ "#{Rails.root}/config/environments/staging.rb"
10
+ end
11
+
12
+ def remove_config
13
+ FileUtils.remove_file config_file if File.file?(config_file)
14
+ FileUtils.remove_file staging_env_file if File.file?(staging_env_file)
15
+ end
16
+ end
@@ -2,6 +2,6 @@ module RequestSpecHelper
2
2
  def json
3
3
  @json ||= JSON.parse(response.body)
4
4
  rescue
5
- @json ||= nil
5
+ @json ||= {}
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: micro_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - ''
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-03-19 00:00:00.000000000 Z
11
+ date: 2023-03-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec-rails
@@ -58,14 +58,14 @@ dependencies:
58
58
  requirements:
59
59
  - - ">="
60
60
  - !ruby/object:Gem::Version
61
- version: 7.0.4.3
61
+ version: 6.0.0
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - ">="
67
67
  - !ruby/object:Gem::Version
68
- version: 7.0.4.3
68
+ version: 6.0.0
69
69
  description: Rails engine plugin that would like to help the startup of rails applications
70
70
  oriented to microservices or, in general, to the cloud.
71
71
  email:
@@ -81,6 +81,10 @@ files:
81
81
  - app/controllers/micro_api/static_controller.rb
82
82
  - app/models/micro_api/application_record.rb
83
83
  - config/routes.rb
84
+ - lib/generators/micro_api/install/USAGE
85
+ - lib/generators/micro_api/install/install_generator.rb
86
+ - lib/generators/micro_api/install/templates/micro_api.rb
87
+ - lib/generators/micro_api/install/templates/staging.rb
84
88
  - lib/micro_api.rb
85
89
  - lib/micro_api/engine.rb
86
90
  - lib/micro_api/version.rb
@@ -103,9 +107,15 @@ files:
103
107
  - spec/dummy/config/locales/en.yml
104
108
  - spec/dummy/config/puma.rb
105
109
  - spec/dummy/config/routes.rb
110
+ - spec/dummy/log/development.log
111
+ - spec/dummy/tmp/development_secret.txt
112
+ - spec/generator/micro_api/installs_generator_spec.rb
106
113
  - spec/rails_helper.rb
114
+ - spec/requests/micro_api/static_healthz_spec.rb
107
115
  - spec/requests/micro_api/static_spec.rb
116
+ - spec/requests/micro_api/static_version_spec.rb
108
117
  - spec/spec_helper.rb
118
+ - spec/support/file_spec_helper.rb
109
119
  - spec/support/request_spec_helper.rb
110
120
  homepage: https://github.com/lelered/micro_api
111
121
  licenses:
@@ -115,7 +125,7 @@ metadata:
115
125
  homepage_uri: https://github.com/lelered/micro_api
116
126
  source_code_uri: https://github.com/lelered/micro_api
117
127
  changelog_uri: https://github.com/lelered/micro_api/blob/main/CHANGELOG.md
118
- post_install_message:
128
+ post_install_message:
119
129
  rdoc_options: []
120
130
  require_paths:
121
131
  - lib
@@ -130,8 +140,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
130
140
  - !ruby/object:Gem::Version
131
141
  version: '0'
132
142
  requirements: []
133
- rubygems_version: 3.4.6
134
- signing_key:
143
+ rubygems_version: 3.4.9
144
+ signing_key:
135
145
  specification_version: 4
136
146
  summary: Engine plugin for Ruby on Rails applications
137
147
  test_files:
@@ -153,7 +163,13 @@ test_files:
153
163
  - spec/dummy/config/puma.rb
154
164
  - spec/dummy/config/routes.rb
155
165
  - spec/dummy/config.ru
166
+ - spec/dummy/log/development.log
167
+ - spec/dummy/tmp/development_secret.txt
168
+ - spec/generator/micro_api/installs_generator_spec.rb
156
169
  - spec/rails_helper.rb
170
+ - spec/requests/micro_api/static_healthz_spec.rb
157
171
  - spec/requests/micro_api/static_spec.rb
172
+ - spec/requests/micro_api/static_version_spec.rb
158
173
  - spec/spec_helper.rb
174
+ - spec/support/file_spec_helper.rb
159
175
  - spec/support/request_spec_helper.rb