vcr alternatives and similar shards
Based on the "Testing" category.
Alternatively, view vcr alternatives based on common mentions on social networks and blogs.
-
spec2.cr
Enhanced `spec` testing library for [Crystal](http://crystal-lang.org/). -
LuckyFlow
Automated browser tests for web applications. Similar to Ruby's Capybara. -
power_assert.cr
PowerAssert provides the more powerful assertion to you. -
timecop.cr
Mock with `Time.now` with the power of time travel, time freeze and time scale. -
microtest
Smaller test framework, because it has power asserts as the only assertion. -
mock
Doubles (stubs and mocks) library for Crystal, inspired by the API of rspec-mocks -
spec2-mocks
This library connects spec2.cr and mocks.cr, effectively enabling 'have_received' expectation for spec2. -
webdriver_pump
Page Object Model library for Crystal. A port (kind of) of Ruby's WatirPump -
hashr
Hashr is a tiny library makes test on JSON response easier, and can also be used as a models object.
Clean code begins in your IDE with SonarLint
Do you think we are missing an alternative of vcr or a related project?
Popular Comparisons
README
vcr
VCR for Crystal!
Record your test suite's HTTP interactions and replay them during future test runs for fast, deterministic, accurate tests.
Example reduction in test time with over 2k RESTful requests:
Without VCR
Finished in 10:22 minutes
18 examples, 0 failures, 0 errors, 0 pending
With VCR
Finished in 13.05 seconds
18 examples, 0 failures, 0 errors, 0 pending
Notes:
The idea of this port is to keep it simple and allow multiple requests to be recorded within a single "cassette" block. The ability to record changed requests to the same endpoint is also important and unavailable in other vcr ports. I have also tried to keep the syntax and methods as close to the Ruby VCR to help.
Other VCR like ports:
Installation
Add this to your application's shard.yml
:
development_dependencies:
vcr:
github: spoved/vcr.cr
Usage
require "vcr"
require "http/client"
load_cassette("cassette-one") do
response = HTTP::Client.get("https://jsonplaceholder.typicode.com/todos/1")
end
You can also record multiple requests within a single block:
load_cassette("cassette-two") do
r1 = HTTP::Client.get("https://jsonplaceholder.typicode.com/todos/1")
r2 = HTTP::Client.get("https://jsonplaceholder.typicode.com/todos/2")
end
To easily reset the cassette and record, simply add the :record
argument:
load_cassette("cassette-two", :record) do
r1 = HTTP::Client.get("https://jsonplaceholder.typicode.com/todos/1")
r2 = HTTP::Client.get("https://jsonplaceholder.typicode.com/todos/2")
end
To record difference in the same response add the :in_order
argument. This Will
record and play back the VCR in order the requests occurred (recording new ones if missing).
VCR.use_cassette("cassette-one", :record, :in_order) do
r1 = HTTP::Client.get("https://jsonplaceholder.typicode.com/todos")
HTTP::Client.delete("https://jsonplaceholder.typicode.com/todos/1")
r2 = HTTP::Client.get("https://jsonplaceholder.typicode.com/todos")
end
Customize the location of where the cassettes are stored. The default is spec/fixtures/vcr
.
VCR.configure do
settings.cassette_library_dir = "/some/path/cassettes"
end
Sensitive data can be filtered out via the filter_sensitive_data
setting (thanks mmacia!):
VCR.configure do |settings|
settings.filter_sensitive_data["api_key"] = "<API_KEY>"
end
Spec usage
Add a hook to load a cassette before the whole suite or use before_each
inside your context
Spec.before_suite { load_cassette("my-spec-cassette", :record) }
Contributing
- Fork it (https://github.com/spoved/vcr.cr/fork)
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create a new Pull Request
Contributors
- kalinon Holden Omans - creator, maintainer