
Security News
Follow-up and Clarification on Recent Malicious Ruby Gems Campaign
A clarification on our recent research investigating 60 malicious Ruby gems.
A quick way of mocking an external web service you want to consume. Inspired by moco, mock-server and sinatra.
Integration, especially based on HTTP, e.g. web service, REST etc, is widlly used in most web development. When you write a feature that need to connect to an external web service You wonder how to test that. One option is to stub methods in Net::HTTP and equivalents, but by doing that you are tying yourself to an implementation detail. The ideal thing is to have a server running locally, Then serve different request for different response.
One thing I want to highlight is, rather than set up a global server which respond to all coming request, With mockery
, you can set up different server for different testcase
, spec
or scenario
.
(haven't published to rubygems)
gem install mockery
or add gem 'mockery'
in your Gemfile
# in rspec helper
require 'mockery'
RSpec.configure do |config|
config.include Mockery::Methods
end
# in spec
describe ApiCilent do
subject { ApiCilent.new }
it "should return hello" do
server = mock_server do
get '/greeting' do
status 200
body 'hello'
end
end
server.run do
expect(subject.greeting).to eq('hello')
end
end
end
#in env.rb
require 'mockery'
World(Mockery::Methods)
# in steps
server = mock_server do
get '/greeting' do
status 200
body 'hello'
end
end
server.run do
# steps that send request to the local mock sever
end
MIT.
FAQs
Unknown package
We found that mocking-server demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
A clarification on our recent research investigating 60 malicious Ruby gems.
Security News
ESLint now supports parallel linting with a new --concurrency flag, delivering major speed gains and closing a 10-year-old feature request.
Research
/Security News
A malicious Go module posing as an SSH brute forcer exfiltrates stolen credentials to a Telegram bot controlled by a Russian-speaking threat actor.