15. These poor decisions are sometime justified as:
"This is the Rails way!"
"Those are the Rails
conventions!"
"This is what a Rails developer
expect to see!"
19. Engines can drop in functionality in your Rails monolithic app
Devise
Kaminari
20. But they can do more that that
"Rails::Engine allows you to wrap a specific Rails application or subset of
functionality and share it with other applications or within a larger
packaged application. Since Rails 3.0, every Rails::Application is just an
engine, which allows for simple feature and application sharing."
Rails API
21. we will create very specific engine only used in this app
22. Domain Model
This is a domain model taken from Evan's book DDD
It is a simplified version of a real live problem
25. rspec
F
Failures:
1) As a staff member I want to ship a cargo
Given I am on the cargo shipping page
When I fill in a customer
And I fill in a origin and destination
Then I want to see an itinerary
Failure/Error: visit '/ship_cargo'
ActionController::RoutingError:
No route matches [GET] "/ship_cargo"
# ./spec/features/ship_cargo_spec.rb:10:in `block (2 levels) in <top (required)="">'
Finished in 0.00523 seconds
1 example, 1 failure
</top>
27. You can create a nested folder
structure
If you want to be more formal about the separation of
responsibilities between the engines
The engine name will match ubiquitous language you share with
stakeholders
engines/
├── application_layer
├── domain_layer
│ ├── billing
│ ├── customer
│ └── shipping
└── presentation_layer
└── cargo_shipping
32. Run the test again!
F
Failures:
1) As a staff member I want to ship a cargo
Given I am on the cargo shipping page
When I fill in a customer
And I fill in a origin and destination
Then I want to see an itinerary
Failure/Error: visit '/ship_cargo'
ActionController::RoutingError:
No route matches [GET] "/ship_cargo"
# ./spec/features/ship_cargo_spec.rb:10:in `block (2 levels) in <top (required)="">'
Finished in 0.00523 seconds
1 example, 1 failure
</top>
36. rspec
F
Failures:
1) As a staff member I want to ship a cargo
Given I am on the cargo shipping page
When I fill in a customer
And I fill in a origin and destination
Then I want to see an itinerary
Failure/Error: visit '/ship_cargo'
NameError:
uninitialized constant CargoShipping::ShipCargoController::Customers
# ./engines/presentation_layer/cargo_shipping/app/controllers/cargo_shipping/ship_cargo_controller.r
# ./spec/features/ship_cargo_spec.rb:10:in `block (2 levels) in <top (required)="">'
Finished in 0.04333 seconds
1 example, 1 failure
</top>