
Security News
CISA’s 2025 SBOM Guidance Adds Hashes, Licenses, Tool Metadata, and Context
CISA’s 2025 draft SBOM guidance adds new fields like hashes, licenses, and tool metadata to make software inventories more actionable.
Makes Test::Unit::TestCase
'context-able' and thus (subjectively - hopefully)
much easier to read and write. If you have ever seen RSpec than it's the very
same context do ... end re-invented for Test::Unit.
Inspired by gem 'context' that does the same for the good 'old' test-unit 1.2.3 bundled with Ruby 1.8.x standard libraries.
Add it to your application's Gemfile (along with test-unit) e.g. :
group :test do
gem 'test-unit'
gem 'test-unit-context'
end
Or install it yourself, if you're not using Bundler :
$ gem install test-unit-context
class ChuckNorrisTest < Test::Unit::TestCase
setup do
@subject = ChuckNorris.new
end
test "can be divided by zero"
assert_equal @subject * 2, @subject / 0
end
context 'frozen' do
setup { @subject.freeze }
test "won't answer" do
assert_raise NoMemoryError do
@subject.frozen?
end
end
test "sqrt works"
assert_nothing_raised do
Math.sqrt -2
end
end
end
shared 'elementary math facts' do
test "square root is rational"
assert_kind_of Rational, Math.sqrt(@subject)
end
test "greater than infinity"
assert @infinity < @subject
end
private
setup
def create_infinity
@infinity = 1 / 0.0
end
end
uses 'elementary math facts'
context 'cloned' do
setup do
@subject = @subject.clone
end
test 'is Arnold Schwarzenegger' do
assert_instance_of Terminator, @subject
assert_nil @subject.is_a?(ChuckNorris)
end
like 'elementary math facts'
end
end
require 'test/unit/context/spec'
describe ChuckNorris, '#fart' do
setup do
@subject = ChuckNorris.new
@subject.fart
end
it "creates a parallel universe" do
assert Object.const_defined?(:Universe)
assert_equal @subject, Universe.instance
assert_empty ObjectSpace.each_object(Universe).to_a
end
end
# NOTE: do not try running this at home!
Copyright (c) 2016 Karol Bucek. See LICENSE (http://www.apache.org/licenses/LICENSE-2.0) for details.
FAQs
Unknown package
We found that test-unit-context 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
CISA’s 2025 draft SBOM guidance adds new fields like hashes, licenses, and tool metadata to make software inventories more actionable.
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.