@@ -13,9 +13,13 @@ defmodule Wallaby.Feature do
1313 ```
1414 config :wallaby, otp_app: :your_app
1515 ```
16+ When used, it accepts the following options:
17+ * `:sandbox` - whether or not to use the sandbox in the tests. Defaults to `true`.
1618 """
1719
18- defmacro __using__ ( _ ) do
20+ defmacro __using__ ( opts \\ [ ] ) do
21+ use_sandbox? = Keyword . get ( opts , :sandbox , true )
22+
1923 quote do
2024 ExUnit.Case . register_attribute ( __MODULE__ , :sessions )
2125
@@ -24,7 +28,8 @@ defmodule Wallaby.Feature do
2428
2529 setup context do
2630 if context [ :test_type ] == :feature do
27- metadata = unquote ( __MODULE__ ) . Utils . maybe_checkout_repos ( context [ :async ] )
31+ metadata =
32+ unquote ( __MODULE__ ) . Utils . maybe_checkout_repos ( unquote ( use_sandbox? ) , context [ :async ] )
2833
2934 start_session_opts =
3035 [ metadata: metadata ]
@@ -171,13 +176,15 @@ defmodule Wallaby.Feature do
171176 def put_create_session_fn ( opts , func ) , do: Keyword . put ( opts , :create_session_fn , func )
172177
173178 if @ includes_ecto do
174- def maybe_checkout_repos ( async? ) do
179+ def maybe_checkout_repos ( true , async? ) do
175180 otp_app ( )
176181 |> ecto_repos ( )
177182 |> Enum . map ( & checkout_ecto_repos ( & 1 , async? ) )
178183 |> metadata_for_ecto_repos ( )
179184 end
180185
186+ def maybe_checkout_repos ( _ , _ ) , do: ""
187+
181188 defp otp_app ( ) , do: Application . get_env ( :wallaby , :otp_app )
182189
183190 defp ecto_repos ( nil ) , do: [ ]
0 commit comments