rails_event_store
rails_event_store copied to clipboard
Write BoundedContext docs
There's no docs currently describing the purpose and philosophy of BoundedContext gem. Questions which can be covered:
- why it generates directory on the top level of a Rails app (unusual)
- explain the directory structure (http://guides.rubygems.org/patterns/#consistent-naming can be helpful)
- does it work with
bin/speccommand - etc.
Related: #186
Running generator rails g bounded_context:bounded_context PlatformCore
generates files
platform_core/lib/platform_core.rb
platform_core/test/test_helper.rb
After adding some code
# platform_core/lib/platform_core.rb
module PlatformCore
CONSTANT = 42 # constant to reference from rails integration tests
end
# platform_core/test/test_helper.rb
require_relative '../lib/platform_core'
fail "Not running with rails test"
# test/integration/signup_stories_test.rb
test "bounded context is accessible" do
assert defined?(PlatformCore::CONSTANT)
end
and running
rails test
Reveals few consequences of current design choices:
- no failure from
platform_core/test/test_helper.rb- BC test does not participate in rails test tasks - integration test failing
Failure:
SigninStoriesTest#test_bounded_context_is_accessible
Not sure if @paneq had a point in #186
On a separate note, running rails console and
Running via Spring preloader in process 25272
Loading development environment (Rails 5.1.5)
irb(main):001:0> PlatformCore::CONSTANT
=> 42
irb(main):002:0>
Which means that code is loaded by console
integration test failing
do you use code preloading in test env?
does that work:
# test/integration/signup_stories_test.rb
test "bounded context is accessible" do
PlatformCore::CONSTANT
assert defined?(PlatformCore::CONSTANT)
end
?
@paneq , yes, this workaround works, but rails models have better class visibility then BC, as models don't need such workarounds.
I'll cross-post question. Are bounded context independent/isolated from environment?
"I distinguish between infrastructure isolation (they can share EventStore, DBs, app server, gems) and conceptual, business isolation." @paneq , well, here we have small differences, as I would prefer at least minimal friction for those, who trying to brake boundaries.
yes, this workaround works
what workaround? Are we talking about:
test "bounded context is accessible" do
PlatformCore::CONSTANT
assert defined?(PlatformCore::CONSTANT)
end
? That's not a workaruond. That's Rails lazy autoloading in work. I depends on what you have as config.eager_load = false in config/environments/test.rb. PlatformCore is lazily loaded only when you ask in your code for it. Example:
irb(main):002:0> defined?(Product)
=> nil
irb(main):003:0> Product
=> Product(id: integer,
irb(main):004:0> defined?(Product)
=> "constant"
but rails models have better class visibility then BC
I don't understand what that means.
P.S. This issue is about Write BoundedContext docs