patbenatar / rbexy

A Ruby template language and component framework inspired by JSX and React
MIT License
35 stars 5 forks source link

Rails spec helpers #37

Open patbenatar opened 3 years ago

patbenatar commented 3 years ago

Currently using rspec-rails controller specs with anonymous controllers in order to get a view context. eg:

# Make this a controller spec for easy access to an ActionView context
RSpec.describe AtomicComponent::Base, type: :controller do
  controller(ActionController::Base) {}
  let(:view_context) { controller.view_context }

  # ...
end

Would be nice to get this context more easily. Maybe we add a type: :component for rspec?

Also a helper to add to context. Currently doing:

before { view_context.rbexy_context.last[:form] = double(...) }