Module: Plushie::Test::RSpec
- Defined in:
- lib/plushie/test/rspec.rb
Overview
RSpec integration for Plushie app testing.
Include this module in an RSpec example group to get the full Plushie test DSL (click, find!, assert_text, model, etc.) with automatic session setup and teardown via before/after hooks.
Mirrors the lifecycle provided by Case for Minitest, so tests are interchangeable between frameworks.
Defined Under Namespace
Modules: ClassMethods
Class Method Summary collapse
-
.included(base)
Hook called when the module is included into an RSpec example group.
Class Method Details
.included(base)
This method returns an undefined value.
Hook called when the module is included into an RSpec example group. Wires up Helpers, ClassMethods, and before/after lifecycle hooks.
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/plushie/test/rspec.rb', line 43 def self.included(base) base.include Helpers base.extend ClassMethods base.before(:each) do app_class = self.class.plushie_app_class raise "No app declared. Add `plushie_app MyApp` to your describe block." unless app_class pool = Plushie::Test.pool session_id = pool.register @_plushie_session = Session.new(app_class, pool: pool, session_id: session_id) Thread.current[:_plushie_test_session] = @_plushie_session end base.after(:each) do @_plushie_session&.stop Thread.current[:_plushie_test_session] = nil end end |