Fix::Expect
Provides the
expectsyntax.
Contact
- Home page: https://github.com/fixrb/fix-expect
- Bugs/issues: https://github.com/fixrb/fix-expect/issues
- Support: https://stackoverflow.com/questions/tagged/fixrb
Rubies
Installation
Fix::Expect is cryptographically signed.
To be sure the gem you install hasn't been tampered with, add my public key (if you haven't already) as a trusted certificate:
$ gem cert --add <(curl -Ls https://raw.github.com/fixrb/fix-expect/master/certs/gem-fixrb-public_cert.pem)
$ gem install fix-expect -P HighSecurity
The HighSecurity trust profile will verify all gems. All of Fix::Expect's dependencies are signed.
Or add this line to your application's Gemfile:
gem 'fix-expect'
And then execute:
$ bundle
Usage
Fix::Expect lets you express expected outcomes on an object:
expect(value.abs).to Equal: 42 # => MUST Equal: 42
Both expect and expect_block methods are mapped to Spectus's absolute requirement/prohibition to express expectations:
Fix.describe 6 * 7 do
it { expect_block { subject.class }.to Equal: Fixnum }
it { expect(subject.class).to Equal: Fixnum }
end
# ..
#
# Ran 2 tests in 0.000524 seconds
# 100% compliant - 0 infos, 0 failures, 0 errors
Using those methods, the default inherited subject can be overridden by the given expected object/block:
Fix.describe -6 * 7 do
on :abs do
# test against the described front object:
it { MUST_NOT Equal: 1 }
# another test against -1 object:
it { expect(-1).to Equal: 1 }
end
end
# ..
#
# Ran 2 tests in 0.000565 seconds
# 100% compliant - 0 infos, 0 failures, 0 errors
However, the tree of challenges remains the same.
For convenience, the is_expected method is also provided:
Fix.describe -6 * 7 do
on :abs do
# test against the described front object:
it { is_expected.to Equal: 42 }
end
end
# .
#
# Ran 1 tests in 0.000193 seconds
# 100% compliant - 0 infos, 0 failures, 0 errors
Security
As a basic form of security Fix::Expect provides a set of SHA512 checksums for
every Gem release. These checksums can be found in the checksum/ directory.
Although these checksums do not prevent malicious users from tampering with a
built Gem they can be used for basic integrity verification purposes.
The checksum of a file can be checked using the sha512sum expect. For
example:
$ sha512sum pkg/fix-expect-0.1.0.gem
26198b7812a5ac118a5f2a1b63927871b3378efb071b37abb7e1ba87c1aac9f3a6b45eeae87d9dc647b194c15171b13f15e46503a9a1440b1233faf924381ff5 pkg/fix-expect-0.1.0.gem
Versioning
Fix::Expect follows Semantic Versioning 2.0.
Contributing
- Fork it
- 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
License
See LICENSE.md file.