Security News
Research
Data Theft Repackaged: A Case Study in Malicious Wrapper Packages on npm
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
An expectation library that adds "must" and "must_not" which can have matchers called on them. Comes with a default set of matchers, and additional matchers can be easily added. Works with RSpec, MiniTest, and Test::Unit. Requires Ruby 1.9 or greater.
Add this line to your application's Gemfile and run the bundle
command.
gem 'musts', group: :test
Inside of a test or spec, call must
or must_not
on any object followed by a matcher. Some matchers have aliases.
5.must.equal 5
5.must_not.eq 4
5.must.be_greater_than 4
5.must.be_lt 6
[].must.be :empty? # calls the method to see if it's true
record.must.be :valid?
5.must.be :between?, 6, 7
# raises Musts::Failure: expected 5 to be between 6 and 7
-> { 5.bad_call }.must.raise_exception(NoMethodError)
See the source code for a complete list of matchers and their behavior.
Matchers are very easy to add. If a block is passed, it will be executed in the context of the subject.
Musts.matcher(:be_empty) { empty? }
[].must.be_empty?
[1].must.be_empty? # fail: expected [1] to be empty
Alternatively, you can pass a class to fully customize the behavior.
class BetweenMatcher
# Subject is always passed, any extra arguments will be added after
def initialize(subject, min, max)
@subject = subject
@min = min
@max = max
end
def match?
@subject.between? @min, @max
end
def failure_message
"expected #{@subject.inspect} to be between #{@min.inspect} and #{@max.inspect}."
end
def negative_failure_message
"expected #{@subject.inspect} to not be between #{@min.inspect} and #{@max.inspect}."
end
end
Musts.matcher(:be_between, BetweenMatcher)
5.must.be_between(5, 7)
For RSpec, add this line to your spec_helper.rb
if you want to disable other matchers.
config.expect_with Musts
For MiniTest::Spec, add this line to your test_helper.rb
if you want to disable existing matchers.
ENV["MT_NO_EXPECTATIONS"] = "true"
git checkout -b my-new-feature
)rspec .
git commit -am 'Add some feature'
)git push origin my-new-feature
)FAQs
Unknown package
We found that musts 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
Research
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Research
Security News
Attackers used a malicious npm package typosquatting a popular ESLint plugin to steal sensitive data, execute commands, and exploit developer systems.
Security News
The Ultralytics' PyPI Package was compromised four times in one weekend through GitHub Actions cache poisoning and failure to rotate previously compromised API tokens.