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/supportbefore starting your test suite. This allows you to import test helpers and configurations from other gems without polluting your main RSpec configuration.
attributes_forin your tests without prefixing them with
Rack::Testbrowser 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_supportpath. We suggest including the ones you need in your RSpec configuration to save some time when writing tests.
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_iconhelper to find and click on a specific FontAwesome icon:
within_rowhelper can be used to scope the Capybara context to a specific row within an index table in the backend:
column_texthelper can be used to retrieve the text from a specific column in a table row:
select2_searchhelper 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_metahelper to expect the current page to have a specific meta tag:
OrderWalkthroughhelper is for.
OrderWalkthrough.up_tocall 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
addressstate. The order will have line items and an address on it, and it will be in the
deliverystate, ready for shipping method selection.
stub_spree_preferenceshelper 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:
perform_subscribershelper. 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_finalizedevent is fired. As a result, your subscriber test is now fully isolated!