dry-web 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +8 -0
- data/Gemfile +1 -10
- data/README.md +0 -3
- data/{rodakase.gemspec → dry-web.gemspec} +3 -10
- data/lib/dry-web.rb +0 -4
- data/lib/dry/web/version.rb +1 -1
- data/spec/spec_helper.rb +7 -16
- data/spec/unit/container_spec.rb +52 -0
- metadata +11 -200
- data/lib/dry/web/application.rb +0 -34
- data/lib/dry/web/transaction.rb +0 -19
- data/lib/roda/plugins/flow.rb +0 -71
- data/skeletons/simple/.ruby-version +0 -1
- data/skeletons/simple/Gemfile +0 -11
- data/skeletons/simple/README.md +0 -21
- data/skeletons/simple/Rakefile +0 -4
- data/skeletons/simple/bin/console +0 -6
- data/skeletons/simple/config.ru +0 -3
- data/skeletons/simple/config/application.yml +0 -4
- data/skeletons/simple/core/boot.rb +0 -12
- data/skeletons/simple/core/simple/application.rb +0 -16
- data/skeletons/simple/core/simple/container.rb +0 -11
- data/skeletons/simple/core/simple/import.rb +0 -9
- data/skeletons/simple/lib/entities/user.rb +0 -3
- data/skeletons/simple/log/.gitkeep +0 -0
- data/skeletons/simple/spec/routes/heartbeat_spec.rb +0 -9
- data/skeletons/simple/spec/spec_helper.rb +0 -12
- data/skeletons/simple/spec/unit/user_spec.rb +0 -17
- data/skeletons/simple/spec/web_helper.rb +0 -20
- data/skeletons/simple/web/routes/root.rb +0 -3
- data/spec/dummy/apps/main/core/boot.rb +0 -15
- data/spec/dummy/apps/main/core/main/application.rb +0 -17
- data/spec/dummy/apps/main/core/main/container.rb +0 -16
- data/spec/dummy/apps/main/core/main/import.rb +0 -9
- data/spec/dummy/apps/main/core/main/requests.rb +0 -21
- data/spec/dummy/apps/main/core/main/view.rb +0 -21
- data/spec/dummy/apps/main/lib/main/entities/user.rb +0 -5
- data/spec/dummy/apps/main/lib/main/persistence/repositories/users.rb +0 -16
- data/spec/dummy/apps/main/lib/main/transactions/register_user.rb +0 -19
- data/spec/dummy/apps/main/lib/main/views/users/index.rb +0 -17
- data/spec/dummy/apps/main/log/.gitkeep +0 -0
- data/spec/dummy/apps/main/requests/users.rb +0 -5
- data/spec/dummy/apps/main/web/routes/users.rb +0 -19
- data/spec/dummy/apps/main/web/templates/layouts/app.html.slim +0 -6
- data/spec/dummy/apps/main/web/templates/users/index.html.slim +0 -3
- data/spec/dummy/apps/main/web/templates/users/index/_list.html.slim +0 -3
- data/spec/dummy/apps/main/web/templates/users/index/_list_item.html.slim +0 -1
- data/spec/dummy/bin/console +0 -6
- data/spec/dummy/config.ru +0 -3
- data/spec/dummy/config/application.yml +0 -4
- data/spec/dummy/core/boot.rb +0 -8
- data/spec/dummy/core/dummy/application.rb +0 -7
- data/spec/dummy/core/dummy/container.rb +0 -14
- data/spec/dummy/core/dummy/import.rb +0 -9
- data/spec/dummy/log/.gitkeep +0 -0
- data/spec/dummy/shared/persistence.rb +0 -12
- data/spec/dummy/shared/persistence/db.rb +0 -9
- data/spec/fixtures/test/core/boot/bar.rb +0 -11
- data/spec/fixtures/test/lib/test/dep.rb +0 -4
- data/spec/fixtures/test/lib/test/foo.rb +0 -5
- data/spec/fixtures/test/lib/test/models.rb +0 -4
- data/spec/fixtures/test/lib/test/models/book.rb +0 -6
- data/spec/fixtures/test/lib/test/models/user.rb +0 -6
- data/spec/integration/application_spec.rb +0 -21
- data/spec/request/users_spec.rb +0 -35
- data/spec/support/helpers.rb +0 -15
@@ -1,19 +0,0 @@
|
|
1
|
-
require 'main/import'
|
2
|
-
require 'main/entities/user'
|
3
|
-
require 'kleisli'
|
4
|
-
|
5
|
-
module Main
|
6
|
-
module Transactions
|
7
|
-
class RegisterUser
|
8
|
-
include Main::Import('persistence.db')
|
9
|
-
|
10
|
-
def call(params)
|
11
|
-
if params['name']
|
12
|
-
Right(db[:users] << Main::Entities::User.new(*params.values_at('id', 'name')))
|
13
|
-
else
|
14
|
-
Left(validation: 'name is missing')
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
@@ -1,17 +0,0 @@
|
|
1
|
-
require 'main/view'
|
2
|
-
|
3
|
-
module Main
|
4
|
-
module Views
|
5
|
-
module Users
|
6
|
-
class Index < Main::View
|
7
|
-
configure do |config|
|
8
|
-
config.template = 'users/index'
|
9
|
-
end
|
10
|
-
|
11
|
-
def locals(options)
|
12
|
-
{ users: [{ name: 'Jane' }, { name: 'Joe' }] }
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
File without changes
|
@@ -1,19 +0,0 @@
|
|
1
|
-
class Main::Application < Dry::Web::Application
|
2
|
-
route('users') do |r|
|
3
|
-
r.get(to: 'main.views.users.index')
|
4
|
-
|
5
|
-
r.resolve('main.requests.users.create') do |t|
|
6
|
-
r.post do
|
7
|
-
t.(r[:user]) do |m|
|
8
|
-
m.success do
|
9
|
-
response.status = 201
|
10
|
-
end
|
11
|
-
|
12
|
-
m.failure do |err|
|
13
|
-
r.redirect '/users'
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
@@ -1 +0,0 @@
|
|
1
|
-
li == user[:name]
|
data/spec/dummy/bin/console
DELETED
data/spec/dummy/config.ru
DELETED
data/spec/dummy/core/boot.rb
DELETED
@@ -1,14 +0,0 @@
|
|
1
|
-
require 'dry/web/container'
|
2
|
-
|
3
|
-
module Dummy
|
4
|
-
class Container < Dry::Web::Container
|
5
|
-
# we need to override default here because we run tests from within the
|
6
|
-
# project root and our app is in spec/dummy
|
7
|
-
configure do |config|
|
8
|
-
config.root = Pathname(__FILE__).dirname.join('../..')
|
9
|
-
config.auto_register = 'lib'
|
10
|
-
end
|
11
|
-
|
12
|
-
load_paths!('lib')
|
13
|
-
end
|
14
|
-
end
|
data/spec/dummy/log/.gitkeep
DELETED
File without changes
|
@@ -1,21 +0,0 @@
|
|
1
|
-
require 'main/import'
|
2
|
-
|
3
|
-
RSpec.describe 'Dry Web Application' do
|
4
|
-
it 'sets env' do
|
5
|
-
expect(Main::Application.config.container.config.env).to be(:test)
|
6
|
-
end
|
7
|
-
|
8
|
-
it 'loads container' do
|
9
|
-
expect(Main::Application[:logger]).to be_instance_of(Logger)
|
10
|
-
end
|
11
|
-
|
12
|
-
it 'sets up namespaced dependencies' do
|
13
|
-
expect(Main::Application['main.persistence.repositories.users']).to be_instance_of(Main::Persistence::Repositories::Users)
|
14
|
-
end
|
15
|
-
|
16
|
-
it 'sets up auto-injection mechanism' do
|
17
|
-
klass = Class.new { include Main::Import(:logger) }
|
18
|
-
|
19
|
-
expect(klass.new.logger).to be_instance_of(Logger)
|
20
|
-
end
|
21
|
-
end
|
data/spec/request/users_spec.rb
DELETED
@@ -1,35 +0,0 @@
|
|
1
|
-
require 'main/entities/user'
|
2
|
-
|
3
|
-
RSpec.describe '/users', type: :request do
|
4
|
-
describe 'GET /users' do
|
5
|
-
it 'renders hello template' do
|
6
|
-
get '/users'
|
7
|
-
|
8
|
-
expect(last_response).to be_ok
|
9
|
-
|
10
|
-
expect(last_response.body).to eql(
|
11
|
-
'<!DOCTYPE html><html><head><title>Woohaa</title></head><body><h1>Users</h1><div class="users"><ul><li>Jane</li><li>Joe</li></ul></div></body></html>'
|
12
|
-
)
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
describe 'POST /users' do
|
17
|
-
it 'creates a user' do
|
18
|
-
user = { id: '1', name: 'Jane' }
|
19
|
-
|
20
|
-
post '/users', user: user
|
21
|
-
|
22
|
-
expect(last_response).to be_created
|
23
|
-
|
24
|
-
expect(container['main.persistence.repositories.users'].all).to eql([Main::Entities::User.new('1', 'Jane')])
|
25
|
-
end
|
26
|
-
|
27
|
-
it 'redirects when name is missing' do
|
28
|
-
user = { id: '1' }
|
29
|
-
|
30
|
-
post '/users', user: user
|
31
|
-
|
32
|
-
expect(last_response).to be_redirect
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|