Walkman v0.2.6 Walkman View Source
Walkman helps you isolate your tests from the outside world.
Getting started
# test/test_helper.exs
Walkman.start_link()
# config/config.exs
config :my_app, my_module: MyModule
Change references to MyModule
in your application to Application.get_env(:my_app, :my_module)
# config/test.exs
config :my_app, my_module: MyModuleWrapper
# test/support/my_module_wrapper.ex
defmodule MyModuleWrapper do
use Walkman.Wrapper, MyModule
end
# test/my_module_test.exs
test "MyModule" do
Walkman.use_tape "MyModule1" do
assert :ok = calls_my_module()
end
end
Recording tapes
The first time you run the tests, Walkman will record test fixtures. You should commit these to your git repository. To re-record your fixtures, delete them and run the tests again (or put Walkman.set_mode(:replay)
in test/test_helper.ex
).
Link to this section Summary
Link to this section Functions
Link to this function
set_mode(mode)
View Source
set_mode(mode)
View Source
set_mode(mode :: :normal | :integration) :: :ok
set_mode(mode :: :normal | :integration) :: :ok
Set Walkman's mode. The default is :normal
.
Walkman has two modes:
:normal
- if a tape is found, then the tape is replayed. If there is no tape, then a new one is made. This is the closest to how Ruby's VCR works.:integration
- calls are passed through to the implementation but no new tapes are made. Useful for running integration tests on the CI.
Link to this macro
use_tape(test_id, test_options \\ [], list) View Source (macro)
Load a tape for use in a test.
test "MyModule" do
Walkman.use_tape "MyModule" do
assert {:ok, _} = MyModule.my_function
end
end