vcr
WebMock
Our great sponsors
vcr | WebMock | |
---|---|---|
20 | 9 | |
5,747 | 3,908 | |
0.4% | - | |
6.4 | 8.1 | |
27 days ago | about 1 month ago | |
Ruby | Ruby | |
Hippocratic License 2.1 | MIT License |
Stars - the number of stars that a project has on GitHub. Growth - month over month growth in stars.
Activity is a relative number indicating how actively a project is being developed. Recent commits have higher weight than older ones.
For example, an activity of 9.0 indicates that a project is amongst the top 10% of the most actively developed projects that we are tracking.
vcr
-
Creating integration tests for a backend legacy codebase
Basically, it's a record/replay tool, similar to VCR for Ruby, but on steroids and powered by AI (khm GPT khm).
-
I isolated the entire codebase from external data sources and made a generator of automated tests
I don't think it's right to say "pythagora generates integration tests". It's more of a "replay manual tests as fixtured unit tests," which makes it similar to (but more powerful than) VCR for Ruby HTTP. What I've always wanted for these kinds of "request recorders" is a way to re-validate the test fixtures over time.
-
Write SDK “base” in Rust, wrap in other languages?
For example, they might expect to be able to mock calls to your API with something like VCR or Responses.
-
How to unit test your database interactions with Docker
I also started from the same starting point but then discovered and started using VCR for creating http stubs - https://github.com/vcr/vcr. It allowed me to write against more realistic and complex test scenarios but didn't support databases.
-
When to mock and what to mock in a Web API?
If you had bit more complex workflows or less time - you could start using a VCR library to mock out API interactions and then continue with your dockerised DBs.
-
Ask HN: When an API is down, what do you usually do?
I generally will use vcr[0] or something similar to record requests and then I write tests and code against that.
3rd parties go down, it happens. In general a system that is dependent on a third party should have some non exceptional behavior when that happens.
So if I’m not setup with vcr, and 3rd party is down- I would on the behavior for what happens when it’s down.
-
Are there any testing frameworks to intercept HTTP and Database calls?
With external APIs, you can also make use of a gem like VCR. I prefer mocks (plus unit tests around the actual deserialization of the response) to VCR in most cases, but the end result is about the same.
-
Configure VCR with RSpec
A way to avoid this is using the VCR gem.
-
Testing Dependencies: Fake It While You Make It
We'll use a tool called vcr to capture real HTTP requests and responses, storing and using them from then on. VCR's language and terminology leans heavily into its real-world analogue. If you don't know what a VCR is, it's a box we used to hook up to TVs to watch movies before DVD players. If you don't know what a DVD player is, it's a box we used to hook up to TVs to watch movies before streaming.
-
New grad job as Quality Engineer and seeing only negativity about it
[1] https://github.com/vcr/vcr
WebMock
-
CableReady broadcasts are not working in system tests
If you want to check out an alternative to VCR, have a look at webmock.
-
TDD is super important and useful!
Well, that's why your test says: "When the API responds like this I do that". People hate on ruby but webmock makes it very nice to mock/stub that, or for python there's responses. For the database you can use a local database with factories to easily create the data you need for each test and clear it between tests.
-
It is becoming difficult for me to be productive in Python
Man if you think python has great mocking/testing support, you check out some ruby tests! Honestly some of the best testing libraries that pioneered approaches that are becoming more common elsewhere, such as the expectations syntax. And now that I'm coding more in python I find myself missing libaries like webmock, letting you stub web reqests in a way that's agnostic of the HTTP/web libary, chef's kiss.
- Are there any testing frameworks to intercept HTTP and Database calls?
-
Configure VCR with RSpec
In order to keep our test suite faster and consistent, we need to mock our http requests. A simple and good way to achieve this is using the Webmock gem which allow easily mock the http responses for your requests.
-
Testing Dependencies: Fake It While You Make It
We can avoid managing HTTP communication with our dependency. Instead, we'll stub out how we expect it to respond. In this case, we'll use webmock to stub out a response at the HTTP layer.
-
A Ruby gem to create production grade Kubernetes clusters in Hetzner Cloud in a couple of minutes or less
The other option is to mock the web requests to Hetzner - this: https://github.com/bblimke/webmock or similar may help.
-
When VCR seems to heavy try cURL & WebMock
There are fine istructions in WebMock README. I want to share it here for reference:
-
Testing external APIs with Rspec and WebMock
You can find the setup instructions and examples on how to use WebMock, in their github documentation. WebMock will prevent any external HTTP requests from your application so make sure you add this gem under the test group of your Gemfile.
What are some alternatives?
Parallel Tests - Ruby: 2 CPUs = 2x Testing Speed for RSpec, Test::Unit and Cucumber
DuckRails - Development tool to mock API endpoints quickly and easily (docker image available)
Knapsack - Knapsack splits tests evenly across parallel CI nodes to run fast CI build and save you time.
R Spec - A minimalist RSpec clone with all the essentials. [Moved to: https://github.com/cyril/r_spec-clone.rb]
Spring - Rails application preloader
ActiveMocker - Generate mocks from ActiveRecord models for unit tests that run fast because they don’t need to load Rails or a database.
timecop - A gem providing "time travel", "time freezing", and "time acceleration" capabilities, making it simple to test time-dependent code. It provides a unified method to mock Time.now, Date.today, and DateTime.now in a single call.
Fix - Specing framework.
Ruby-JMeter - A Ruby based DSL for building JMeter test plans
Request Interceptor - Sinatra based foreign API simulation for your testsuite
httparty - :tada: Makes http fun again!
TestXml - Small library to test your xml with Test::Unit or RSpec