rspec-rails
gem:spec/spec_helper.rb
and spec/rails_helper.rb
, as they contain some default configurations which you may want to uncomment. At the very least, make sure you uncomment these lines:spec/support
before starting your test suite. This allows you to import test helpers and configurations from other gems without polluting your main RSpec configuration.spec/support
.create
, build
, build_stubbed
and attributes_for
in your tests without prefixing them with FactoryBot
:Rack::Test
browser for non-JS tests, and Chrome for JS tests. This enables you to do the following:Rack::Test
, which is faster. The second test will be run through a headless Chrome instance with JS capabilities.spree/testing_support
path. We suggest including the ones you need in your RSpec configuration to save some time when writing tests.spree/testing_support
are mostly meant for internal use (i.e., for testing the Solidus codebase itself), and wouldn't be very useful in another test suite.stub_authorization!
method bypasses the authentication and authorization systems completely by stubbing the current user and allowing you to perform any action on any resource:custom_authorization!
method, on the other hand, allows you to define a custom authorization block. You'll still need to authenticate the current user, if you use it:click_icon
helper to find and click on a specific FontAwesome icon:within_row
helper can be used to scope the Capybara context to a specific row within an index table in the backend:column_text
helper can be used to retrieve the text from a specific column in a table row:select2_search
helper to search and select a specific option from a Select2 input (this would be equivalent to typing the option's text in the search field, then selecting the result):have_meta
helper to expect the current page to have a specific meta tag:OrderWalkthrough
helper is for.OrderWaltkhrough
helper is extremely opinionated: it assumes you haven't modified the order state machine in significant ways, and that your checkout flow resembles the standard, multi-page checkout flow from the starter frontend.OrderWalkthrough.up_to
call will create a new order and it will simulate what a user would do if they went to the checkout flow and only completed the address
state. The order will have line items and an address on it, and it will be in the delivery
state, ready for shipping method selection.stub_spree_preferences
helper anywhere in your code. The helper accepts a hash of preferences, in which case the preferences will be stubbed on the global configuration:Spree::Core::Engine.routes.url_helpers
, but you can include the URL helpers if you want to save a few characters:spree.
shortcut:perform_subscribers
helper. Subscribers will still be active as usual in your system and request specs, so that you make sure your application works well in integration.order_finalized
event is fired. As a result, your subscriber test is now fully isolated!