rspec-block_is_expected-1.0.6/0000755000004100000410000000000014642371136016335 5ustar www-datawww-datarspec-block_is_expected-1.0.6/rspec-block_is_expected.gemspec0000644000004100000410000001070014642371136024460 0ustar www-datawww-data######################################################### # This file has been automatically generated by gem2tgz # ######################################################### # -*- encoding: utf-8 -*- # stub: rspec-block_is_expected 1.0.6 ruby lib Gem::Specification.new do |s| s.name = "rspec-block_is_expected".freeze s.version = "1.0.6" s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version= s.metadata = { "bug_tracker_uri" => "https://github.com/pboling/rspec-block_is_expected/issues", "changelog_uri" => "https://github.com/pboling/rspec-block_is_expected/blob/v1.0.6/CHANGELOG.md", "documentation_uri" => "https://www.rubydoc.info/gems/rspec-block_is_expected/1.0.6", "funding_uri" => "https://liberapay.com/pboling", "homepage_uri" => "https://github.com/pboling/rspec-block_is_expected", "rubygems_mfa_required" => "true", "source_code_uri" => "https://github.com/pboling/rspec-block_is_expected/tree/v1.0.6", "wiki_uri" => "https://github.com/pboling/rspec-block_is_expected/wiki" } if s.respond_to? :metadata= s.require_paths = ["lib".freeze] s.authors = ["Peter Boling".freeze] s.bindir = "exe".freeze s.cert_chain = ["-----BEGIN CERTIFICATE-----\nMIIEgDCCAuigAwIBAgIBATANBgkqhkiG9w0BAQsFADBDMRUwEwYDVQQDDAxwZXRl\nci5ib2xpbmcxFTATBgoJkiaJk/IsZAEZFgVnbWFpbDETMBEGCgmSJomT8ixkARkW\nA2NvbTAeFw0yMzA5MjAxNzMwMjhaFw0yNDA5MTkxNzMwMjhaMEMxFTATBgNVBAMM\nDHBldGVyLmJvbGluZzEVMBMGCgmSJomT8ixkARkWBWdtYWlsMRMwEQYKCZImiZPy\nLGQBGRYDY29tMIIBojANBgkqhkiG9w0BAQEFAAOCAY8AMIIBigKCAYEA+a9UvHo3\n84k96WgU5Kk5HB+cLZs/modjorsTfqY67MJF5nNvAoqcKTUBW4uG+Zpfnm3jaDO5\nGxhJEIZWfndYzycHT2KMVQ1uTP82ba8ZaKrPlPIafkbui3mdds47qsmqHiblKERg\nU532lkwfqHDlJwE7OBZQ59EwWWLynlT/yAUHpOBbqIuHKUxdpmBI+sIjrZcD1e05\nWmjkO6fwIdC5oM757aoPxIgXD587VOViH11Vkm2doskj4T8yONtwVHlcrrhJ9Bzd\n/zdp6vEn7GZQrABvpOlqwWxQ72ZnFhJe/RJZf6CXOPOh69Ai0QKYl2a1sYuCJKS3\nnsBnxXJINEEznjR7rZjNUmYD+CZqfjzgPqedRxTlASe7iA4w7xZOqMDzcuhNwcUQ\ntMEH6BTktxKP3jXZPXRfHCf6s+HRVb6vezAonTBVyydf5Xp5VwWkd6cwm+2BzHl5\n7kc/3lLxKMcsyEUprAsk8LdHohwZdC267l+RS++AP6Cz6x+nB3oGob19AgMBAAGj\nfzB9MAkGA1UdEwQCMAAwCwYDVR0PBAQDAgSwMB0GA1UdDgQWBBQCSSas60GqqMjt\nxR7LoY1gucEvtzAhBgNVHREEGjAYgRZwZXRlci5ib2xpbmdAZ21haWwuY29tMCEG\nA1UdEgQaMBiBFnBldGVyLmJvbGluZ0BnbWFpbC5jb20wDQYJKoZIhvcNAQELBQAD\nggGBAMl9ifcw5p+PdvB7dCPoNKoVdp/2LbC9ztETHuYL2gUMJB6UoS3o9c/piSuR\nV3ZMQaijmNu6ms1bWAtJ66LjmYrVflJtf9yp31Kierr9LpisMSUx2qbMOHGa8d2Z\nvCUWPF8E9Cg0mP3GAyZ6qql8jDh/anUKeksPXqJvNxNPDu2DVYsa/IWdl96whzS4\nBl7SwB1E7agps40UcshCSKaVDOU0M+XN6SrnJMElnBic+KSAkBkVFbzS0BE4ODZM\nBgE6nYzQ05qhuvbE+oGdACTlemNtDDWCh0uw+7x0q2PocGIDU5zsPn/WNTkCXPmB\nCHGvqDNWq4M7ncTKAaS2XExgyb7uPdq9fKiOW8nmH+zCiGzJXzBWwZlKf7L4Ht9E\na3f0e5C+zvee9Z5Ng9ciyfav9/fcXgYt5MjoBv27THr5XfBhgOCIHSYW2tqJmWKi\nKuxrfYrN+9HvMdm+nZ6TypmKftHY3Gj+/uu+g8Icm/zrvTWAEE0mcJOkfrIoNPJb\npF8dMA==\n-----END CERTIFICATE-----\n".freeze] s.date = "2024-06-23" s.description = "subject { Integer(nil) }; it('raises') { block_is_expected.to raise_error(TypeError) }".freeze s.email = ["peter.boling@gmail.com".freeze] s.files = ["CHANGELOG.md".freeze, "CODE_OF_CONDUCT.md".freeze, "CONTRIBUTING.md".freeze, "LICENSE.txt".freeze, "README.md".freeze, "SECURITY.md".freeze, "lib/rspec/block_is_expected.rb".freeze, "lib/rspec/block_is_expected/matchers/not.rb".freeze, "lib/rspec/block_is_expected/rspec.rb".freeze, "lib/rspec/block_is_expected/shared_examples/block_does_not_raise_examples.rb".freeze, "lib/rspec/block_is_expected/shared_examples/block_raises_error_examples.rb".freeze, "lib/rspec/block_is_expected/version.rb".freeze, "rubocop.yml".freeze] s.homepage = "https://github.com/pboling/rspec-block_is_expected".freeze s.licenses = ["MIT".freeze] s.required_ruby_version = Gem::Requirement.new(">= 1.8.7".freeze) s.rubygems_version = "3.3.15".freeze s.summary = "Simplify testing of blocks in RSpec via block_is_expected".freeze if s.respond_to? :specification_version then s.specification_version = 4 end if s.respond_to? :add_runtime_dependency then s.add_development_dependency(%q.freeze, ["~> 2.2"]) s.add_development_dependency(%q.freeze, [">= 10.5"]) s.add_development_dependency(%q.freeze, [">= 3"]) s.add_development_dependency(%q.freeze, ["~> 0.1", ">= 0.1.16"]) else s.add_dependency(%q.freeze, ["~> 2.2"]) s.add_dependency(%q.freeze, [">= 10.5"]) s.add_dependency(%q.freeze, [">= 3"]) s.add_dependency(%q.freeze, ["~> 0.1", ">= 0.1.16"]) end end rspec-block_is_expected-1.0.6/CONTRIBUTING.md0000644000004100000410000000533414642371136020573 0ustar www-datawww-data## Contributing Bug reports and pull requests are welcome on GitHub at [https://github.com/pboling/rspec-block_is_expected][🚎src-main] . This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct][🤝conduct]. To submit a patch, please fork the project and create a patch with tests. Once you're happy with it send a pull request and post a message to the [gitter chat][🏘chat]. ## Release To release a new version: 1. Run `bin/setup && bin/rake` as a tests, coverage, & linting sanity check 2. Update the version number in `version.rb` 3. Run `bin/setup && bin/rake` again as a secondary check, and to update `Gemfile.lock` 4. Run `git commit -am "🔖 Prepare release v"` to commit the changes 5. Run `git push` to trigger the final CI pipeline before release, & merge PRs a. NOTE: Remember to [check the build][🧪build]! 6. Run `git checkout main` 7. Run `git pull origin main` to ensure you will release the latest trunk code. 8. Set `SOURCE_DATE_EPOCH` so `rake build` and `rake release` use same timestamp, and generate same checksums a. Run `export SOURCE_DATE_EPOCH=$EPOCHSECONDS && echo $SOURCE_DATE_EPOCH` b. If the echo above has no output, then it didn't work. c. Note that you'll need the `zsh/datetime` module, if running `zsh`. 9. Run `bundle exec rake build` 10. Run [`bin/checksums`][🔒️rubygems-checksums-pr] to create SHA-256 and SHA-512 checksums a. Checksums will be committed automatically by the script, but not pushed 11. Run `bundle exec rake release` which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org][💎rubygems] NOTE: You will need to have a public key in `certs/`, and list your cert in the `gemspec`, in order to sign the new release. See: [RubyGems Security Guide][🔒️rubygems-security-guide] ## Contributors [![Contributors][🖐contributors-img]][🖐contributors] Made with [contributors-img][🖐contrib-rocks]. [🧪build]: https://github.com/pboling/rspec-block_is_expected/actions [🏘chat]: https://matrix.to/#/%23pboling_rspec-block_is_expected:gitter.im [🤝conduct]: https://github.com/pboling/rspec-block_is_expected/blob/main/CODE_OF_CONDUCT.md [🖐contrib-rocks]: https://contrib.rocks [🖐contributors]: https://github.com/pboling/rspec-block_is_expected/graphs/contributors [🖐contributors-img]: https://contrib.rocks/image?repo=pboling/rspec-block_is_expected [💎rubygems]: https://rubygems.org [🔒️rubygems-security-guide]: https://guides.rubygems.org/security/#building-gems [🔒️rubygems-checksums-pr]: https://github.com/rubygems/guides/pull/325 [🚎src-main]: https://github.com/pboling/rspec-block_is_expected rspec-block_is_expected-1.0.6/SECURITY.md0000755000004100000410000000053514642371136020134 0ustar www-datawww-data# Security Policy ## Supported Versions | Version | Supported | |----------|-----------| | 1.latest | ✅ | ## Reporting a Vulnerability Peter Boling is the primary maintainer of this gem. Please find a way to [contact him directly](https://railsbling.com/contact) to report the issue. Include as much relevant information as possible. rspec-block_is_expected-1.0.6/lib/0000755000004100000410000000000014642371136017103 5ustar www-datawww-datarspec-block_is_expected-1.0.6/lib/rspec/0000755000004100000410000000000014642371136020217 5ustar www-datawww-datarspec-block_is_expected-1.0.6/lib/rspec/block_is_expected/0000755000004100000410000000000014642371136023665 5ustar www-datawww-datarspec-block_is_expected-1.0.6/lib/rspec/block_is_expected/shared_examples/0000755000004100000410000000000014642371136027031 5ustar www-datawww-data././@LongLink0000644000000000000000000000015100000000000011600 Lustar rootrootrspec-block_is_expected-1.0.6/lib/rspec/block_is_expected/shared_examples/block_raises_error_examples.rbrspec-block_is_expected-1.0.6/lib/rspec/block_is_expected/shared_examples/block_raises_error_example0000644000004100000410000000027114642371136034340 0ustar www-datawww-dataRSpec.shared_examples_for("block_is_expected to raise error") do |*error_args| it "raises error #{error_args.inspect}" do block_is_expected.to(raise_error(*error_args)) end end ././@LongLink0000644000000000000000000000015300000000000011602 Lustar rootrootrspec-block_is_expected-1.0.6/lib/rspec/block_is_expected/shared_examples/block_does_not_raise_examples.rbrspec-block_is_expected-1.0.6/lib/rspec/block_is_expected/shared_examples/block_does_not_raise_examp0000644000004100000410000000022214642371136034311 0ustar www-datawww-dataRSpec.shared_examples_for("block_is_expected to not raise") do it "does not raise error" do block_is_expected.not_to(raise_error) end end rspec-block_is_expected-1.0.6/lib/rspec/block_is_expected/rspec.rb0000644000004100000410000000044214642371136025326 0ustar www-datawww-datarequire "rspec/core" require "rspec/block_is_expected/matchers/not" RSpec.configure do |c| c.include(Rspec::BlockIsExpected) end require "rspec/block_is_expected/shared_examples/block_does_not_raise_examples" require "rspec/block_is_expected/shared_examples/block_raises_error_examples" rspec-block_is_expected-1.0.6/lib/rspec/block_is_expected/matchers/0000755000004100000410000000000014642371136025473 5ustar www-datawww-datarspec-block_is_expected-1.0.6/lib/rspec/block_is_expected/matchers/not.rb0000644000004100000410000000037014642371136026620 0ustar www-datawww-dataRSpec::Matchers.define_negated_matcher(:not_change, :change) RSpec::Matchers.define_negated_matcher(:not_include, :include) RSpec::Matchers.define_negated_matcher(:not_eq, :eq) RSpec::Matchers.define_negated_matcher(:not_raise_error, :raise_error) rspec-block_is_expected-1.0.6/lib/rspec/block_is_expected/version.rb0000644000004100000410000000011514642371136025674 0ustar www-datawww-datamodule Rspec module BlockIsExpected VERSION = "1.0.6".freeze end end rspec-block_is_expected-1.0.6/lib/rspec/block_is_expected.rb0000644000004100000410000000033414642371136024212 0ustar www-datawww-datarequire "rspec/block_is_expected/version" require "rspec/block_is_expected/rspec" module Rspec # Namespace of this library module BlockIsExpected def block_is_expected expect { subject } end end end rspec-block_is_expected-1.0.6/LICENSE.txt0000644000004100000410000000212414642371136020157 0ustar www-datawww-dataCopyright © 2018, 2020, 2023 - 2024 Peter H. Boling of RailsBling.com MIT License Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. rspec-block_is_expected-1.0.6/checksums.yaml.gz.sig0000444000004100000410000000060014642371136022400 0ustar www-datawww-dataٟ2gaT`y`RڪpׇyE:%Ms S 3 pqre h#p+H-ZQ(?UNtX/Z *>٤'g^Q=F_$}ݪwG( S{T)B iEVkD*%5q=3|9Ƿw(Az $´h#P3] QWmq(G YNHczZDrJ±4*!p4̝>>Flgʅx%P6af6zt53$Tr:~,t0RN,7uTt+$%Y7< ]m zs֤rspec-block_is_expected-1.0.6/rubocop.yml0000644000004100000410000000007714642371136020535 0ustar www-datawww-dataRSpec: Language: Expectations: - block_is_expected rspec-block_is_expected-1.0.6/CODE_OF_CONDUCT.md0000644000004100000410000001214414642371136021136 0ustar www-datawww-data# Contributor Covenant Code of Conduct ## Our Pledge We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation. We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community. ## Our Standards Examples of behavior that contributes to a positive environment for our community include: * Demonstrating empathy and kindness toward other people * Being respectful of differing opinions, viewpoints, and experiences * Giving and gracefully accepting constructive feedback * Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience * Focusing on what is best not just for us as individuals, but for the overall community Examples of unacceptable behavior include: * The use of sexualized language or imagery, and sexual attention or advances of any kind * Trolling, insulting or derogatory comments, and personal or political attacks * Public or private harassment * Publishing others' private information, such as a physical or email address, without their explicit permission * Other conduct which could reasonably be considered inappropriate in a professional setting ## Enforcement Responsibilities Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful. Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for moderation decisions when appropriate. ## Scope This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. ## Enforcement Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at peter.boling@gmail.com. All complaints will be reviewed and investigated promptly and fairly. All community leaders are obligated to respect the privacy and security of the reporter of any incident. ## Enforcement Guidelines Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct: ### 1. Correction **Community Impact**: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community. **Consequence**: A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested. ### 2. Warning **Community Impact**: A violation through a single incident or series of actions. **Consequence**: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban. ### 3. Temporary Ban **Community Impact**: A serious violation of community standards, including sustained inappropriate behavior. **Consequence**: A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban. ### 4. Permanent Ban **Community Impact**: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals. **Consequence**: A permanent ban from any sort of public interaction within the community. ## Attribution This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.0, available at https://www.contributor-covenant.org/version/2/0/code_of_conduct.html. Community Impact Guidelines were inspired by [Mozilla's code of conduct enforcement ladder](https://github.com/mozilla/diversity). [homepage]: https://www.contributor-covenant.org For answers to common questions about this code of conduct, see the FAQ at https://www.contributor-covenant.org/faq. Translations are available at https://www.contributor-covenant.org/translations. rspec-block_is_expected-1.0.6/data.tar.gz.sig0000444000004100000410000000060014642371136021150 0ustar www-datawww-data]Tx"JV}[ ܎̚f!E‘M#FgkyfQӪc=pfRȋӡh"777 2SgCK6:3"{KЄɛA3 ƱF׹VrX捦0Ukz쮿Ǟc pCeFp8gZ^ʂ#@AծQ121RӒB#NZ$W+`sv;t}a-nWZ@m,rspec-block_is_expected-1.0.6/metadata.gz.sig0000444000004100000410000000060014642371136021232 0ustar www-datawww-data-Pƾ8flxz+{J&UG7Z5?\hb5 uĵO, ҡ_iA!C?ݮ ;;h^hTPXoDJwsM!;rGޘ4nB,+gn r"q*^Go.XM˓-T>m IFYRu8`|B3xLO2y3G%")gClj5_NW6@ ޟH~@YcAdZJ~yNB,kچCse";oLWd5Wͧ56'@S&=PS0l|܅rspec-block_is_expected-1.0.6/README.md0000644000004100000410000003635114642371136017624 0ustar www-datawww-data# Rspec::BlockIsExpected
[![CI Build][🚎dl-cwfi]][🚎dl-cwf] [![Test Coverage][🔑cc-covi]][🔑cc-cov] [![Maintainability][🔑cc-mnti]][🔑cc-mnt] [![Depfu][🔑depfui]][🔑depfu] [🚎dl-cwf]: https://github.com/pboling/rspec-block_is_expected/actions/workflows/current.yml [🚎dl-cwfi]: https://github.com/pboling/rspec-block_is_expected/actions/workflows/current.yml/badge.svg [comment]: <> ( 🔑 KEYED LINKS ) [🔑cc-mnt]: https://codeclimate.com/github/pboling/rspec-block_is_expected/maintainability [🔑cc-mnti]: https://api.codeclimate.com/v1/badges/ca0a12604ecc19f5e76d/maintainability [🔑cc-cov]: https://codeclimate.com/github/pboling/rspec-block_is_expected/test_coverage [🔑cc-covi]: https://api.codeclimate.com/v1/badges/ca0a12604ecc19f5e76d/test_coverage [🔑depfu]: https://depfu.com/github/pboling/rspec-block_is_expected?project_id=5865 [🔑depfui]: https://badges.depfu.com/badges/79867e590f063376f40b031a1447c215/count.svg ----- [![Liberapay Patrons][⛳liberapay-img]][⛳liberapay] [![Sponsor Me on Github][🖇sponsor-img]][🖇sponsor] Buy me coffee donation button Patreon donate button
[⛳liberapay-img]: https://img.shields.io/liberapay/patrons/pboling.svg?logo=liberapay [⛳liberapay]: https://liberapay.com/pboling/donate [🖇sponsor-img]: https://img.shields.io/badge/Sponsor_Me!-pboling.svg?style=social&logo=github [🖇sponsor]: https://github.com/sponsors/pboling This gem does ~~five~~, _three sir_, five things. 1. Provides `block_is_expected` to set expectations on the result of running the `subject` as a block. 2. Provides, via shared example groups, shortcut RSpec macros for setting an expectation on errors being raised (or not). ```ruby it_behaves_like "block_is_expected to not raise" it_behaves_like "block_is_expected to raise error", RuntimeError ``` 3. Provides RSpec negated matchers that can be used with `block_is_expected`: ```ruby not_change not_raise_error ``` And two others that are so generally useful I end up defining them on every project: ```ruby not_include not_eq ``` ## Just show me the money First, configure in your rspec helper, or similar: ```ruby require "rspec/block_is_expected" ``` Then, 1. Custom expectation on result of subject as block ```ruby subject { Integer("1") } it("raises") { block_is_expected.to(not_raise_error) } ``` 2. Subject will not raise an exception ```ruby subject { Integer("1") } it_behaves_like "block_is_expected to not raise" ``` 3. Subject will raise an exception ```ruby subject { Integer(nil) } it_behaves_like "block_is_expected to raise error", TypeError ``` | Project | `bundle add rspec-block_is_expected --group test` | |--------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | name, license, docs, standards | [![RubyGems.org][⛳️name-img]][⛳️gem] [![License: MIT][🖇src-license-img]][🖇src-license] [![RubyDoc.info][🚎yard-img]][🚎yard] [![SemVer 2.0.0][🧮semver-img]][🧮semver] [![Keep-A-Changelog 1.0.0][📗keep-changelog-img]][📗keep-changelog] | | version & activity | [![Gem Version][⛳️version-img]][⛳️gem] [![Total Downloads][🖇DL-total-img]][⛳️gem] [![Download Rank][🏘DL-rank-img]][⛳️gem] | | dependencies | [![Depfu][🔑depfui]][🔑depfu] | | continuous integration | [![CI Build][🚎dl-cwfi]][🚎dl-cwf] [![Heads][🖐hwfi]][🖐hwf] [![Style][🧮swfi]][🧮swf] | | test coverage | [![Test Coverage][🔑cc-covi]][🔑cc-cov] | | maintainability | [![Maintainability](https://api.codeclimate.com/v1/badges/ca0a12604ecc19f5e76d/maintainability)](https://codeclimate.com/github/pboling/rspec-block_is_expected/maintainability) | | code triage | [![Open Source Helpers](https://www.codetriage.com/pboling/rspec-block_is_expected/badges/users.svg)](https://www.codetriage.com/pboling/rspec-block_is_expected) | | homepage | [on Github.com][homepage], [on Railsbling.com][blogpage] | | documentation | [on RDoc.info][documentation] | | `...` 💖 | [![Liberapay Goal Progress][⛳liberapay-img]][⛳liberapay], [🧊][🧊berg], [🛖][🛖hut], [🧪][🧪lab], [🌏][aboutme], [👼][angellist], [⚗️][devto], [![Tweet @galtzo][followme]][twitter] | [⛳️gem]: https://rubygems.org/gems/rspec-block_is_expected [⛳️name-img]: https://img.shields.io/badge/name-rspec--block__is__expected-brightgreen.svg?style=flat [🖇src-license]: https://opensource.org/licenses/MIT [🖇src-license-img]: https://img.shields.io/badge/License-MIT-green.svg [🚎yard]: https://www.rubydoc.info/gems/rspec-block_is_expected [🚎yard-img]: https://img.shields.io/badge/documentation-rubydoc-brightgreen.svg?style=flat [🧮semver]: http://semver.org/ [🧮semver-img]: https://img.shields.io/badge/semver-2.0.0-FFDD67.svg?style=flat [📗keep-changelog]: https://keepachangelog.com/en/1.0.0/ [📗keep-changelog-img]: https://img.shields.io/badge/keep--a--changelog-1.0.0-FFDD67.svg?style=flat [⛳️version-img]: http://img.shields.io/gem/v/rspec-block_is_expected.svg [🖇DL-total-img]: https://img.shields.io/gem/dt/rspec-block_is_expected.svg [🏘DL-rank-img]: https://img.shields.io/gem/rt/rspec-block_is_expected.svg [🖐hwf]: https://github.com/pboling/rspec-block_is_expected/actions/workflows/heads.yml [🖐hwfi]: https://github.com/pboling/rspec-block_is_expected/actions/workflows/heads.yml/badge.svg [🧮swf]: https://github.com/pboling/rspec-block_is_expected/actions/workflows/style.yml [🧮swfi]: https://github.com/pboling/rspec-block_is_expected/actions/workflows/style.yml/badge.svg If you only _ever_ want to test subjects wrapped in blocks, and are comfortable with **losing** the standard `is_expected` behavior, see an alternative to this gem [here](https://github.com/christopheraue/ruby-rspec-is_expected_block/). ## Ruby Compatibility Supports the same versions of Ruby that RSpec does, 1.8.7 - current ruby-head, as well as the JRuby equivalents. ## Installation Add this line to your application's Gemfile: ```ruby gem "rspec-block_is_expected", :group => :test ``` And then execute: $ bundle Or install it yourself as: $ gem install rspec-block_is_expected ## Configuration There is no configuration needed if you your test suite loads the bundle group (e.g. `test`) that you added the gem to. Otherwise, you may load it manually near the top of your `spec_helper.rb`, and it will self configure. ```ruby require "rspec/block_is_expected" ``` ### RSpec Matchers `block_is_expected` can be used to chain expectations related to the block, but `to_not` doesn't work with multiple expectations. So negated matchers are required. A basic set of them are included with this gem, and can be loaded with: ```ruby require "rspec/block_is_expected/matchers/not" ``` This gives you the following matchers: ```ruby RSpec::Matchers.define_negated_matcher(:not_change, :change) RSpec::Matchers.define_negated_matcher(:not_include, :include) RSpec::Matchers.define_negated_matcher(:not_eq, :eq) RSpec::Matchers.define_negated_matcher(:not_raise_error, :raise_error) ``` #### Example You have a module like this: ```ruby module MyTasks def my_rakelib Rake.add_rakelib("bananas") end module_function :my_rakelib end ``` You have a spec like this: ```ruby require "rake" RSpec.describe(MyTasks) do describe "my_rakelib" do subject(:my_rakelib) { described_class.my_rakelib } it "updates rakelib" do block_is_expected.to(not_raise_error & change { Rake.application.options.rakelib }.from(["rakelib"]).to(%w[rakelib bananas])) end end end ``` ### Integration with RuboCop You'll likely get the following linting error from `rubocop-rspec` if you use `block_is_expected.to ...`: ``` RSpec/NoExpectationExample: No expectation found in this example. ``` To fix it properly you need to register `block_is_expected` as an "expectation". In your `.rubocop.yml` ```yml inherit_gem: rspec-block_is_expected: rubocop.yml ``` ## Usage The spec suite for this gem has some examples of usage, lightly edited here. ```ruby RSpec.describe("TestyMcTest") do context "errors raised" do subject { Integer(nil) } it("can be tested") do # Where you used to have: # expect { subject }.to raise_error(TypeError) block_is_expected.to(raise_error(TypeError)) end end context "execution" do let(:mutex) { Mutex.new } subject { mutex.lock } it("can change state") do expect(mutex.locked?).to(eq(false)) # Where you used to have: # expect { subject }.to_not raise_error block_is_expected.to_not(raise_error) expect(mutex.locked?).to(eq(true)) end end context "changed state" do let(:mutex) { Mutex.new } subject { mutex.lock } it("can be tested") do # Where you used to have: # expect { subject }.to change { mutex.locked? }.from(false).to(true) block_is_expected.to(change { mutex.locked? }.from(false).to(true)) end end end ``` ## Switch to `main` branch We recently migrated from `master` to `main` as the default branch. If this affected your local checkout: ```shell git branch -m master main git fetch origin git branch -u origin/main main git remote set-head origin -a ``` ## Development After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment. To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org). ## Authors * [Peter H. Boling][peterboling] of [Rails Bling][railsbling] is the author. ## Contributing See [CONTRIBUTING.md][contributing]. [contributing]: https://gitlab.com/pboling/rspec-block_is_expected/-/blob/main/CONTRIBUTING.md ## Contributing See [CONTRIBUTING.md][contributing]. [contributing]: https://gitlab.com/pboling/rspec-stubbed_env/-/blob/main/CONTRIBUTING.md ### Running Specs The basic compatibility matrix: ```sh appraisal install appraisal rake test ``` Sometimes also: ```sh BUNDLE_GEMFILE=gemfiles/vanilla.gemfile appraisal update ``` NOTE: This results in bad paths to the gemspec. `gemspec path: "../../"` needs to be replaced with `gemspec :path => "../"` in each Appraisal gemfile. Except, is unlikely to be possible to install all of the supported Rubies & Railsies in a single container... See the various github action workflows for more inspiration on running certain oldies. ## Code of Conduct Everyone interacting in the AnonymousActiveRecord project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct][conduct]. ## Versioning This library aims to adhere to [Semantic Versioning 2.0.0][semver]. Violations of this scheme should be reported as bugs. Specifically, if a minor or patch version is released that breaks backward compatibility, a new version should be immediately released that restores compatibility. Breaking changes to the public API will only be introduced with new major versions. As a result of this policy, you can (and should) specify a dependency on this gem using the [Pessimistic Version Constraint][pvc] with two digits of precision. For example in a `Gemfile`: ```ruby gem "rspec-block_is_expected", "~> 1.0", :group => [:development, :test] ``` or in a `gemspec` ```ruby spec.add_development_dependency("rspec-block_is_expected", "~> 1.0") ``` ## Legal * Copyright © 2018, 2020, 2023 - 2024 [Peter H. Boling][peterboling] of [Rails Bling][railsbling] [![License: MIT](https://img.shields.io/badge/License-MIT-green.svg)](https://opensource.org/licenses/MIT) [aboutme]: https://about.me/peter.boling [angellist]: https://angel.co/peter-boling [blogpage]: http://www.railsbling.com/tags/rspec-block_is_expected/ [conduct]: CODE_OF_CONDUCT.md [contributing]: CONTRIBUTING.md [devto]: https://dev.to/galtzo [documentation]: http://rdoc.info/github/pboling/rspec-block_is_expected/frames [followme]: https://img.shields.io/twitter/follow/galtzo.svg?style=social&label=Follow [homepage]: https://github.com/pboling/rspec-block_is_expected [license]: LICENSE.txt [peterboling]: https://about.me/peter.boling [pvc]: http://guides.rubygems.org/patterns/#pessimistic-version-constraint [railsbling]: http://www.railsbling.com [semver]: http://semver.org/ [twitter]: http://twitter.com/galtzo [🧊berg]: https://codeberg.org/pboling [🛖hut]: https://sr.ht/~galtzo/ [🧪lab]: https://gitlab.com/pboling [⛳liberapay]: https://liberapay.com/pboling/donate [⛳liberapay-img]: https://img.shields.io/liberapay/goal/pboling.svg?logo=liberapay rspec-block_is_expected-1.0.6/CHANGELOG.md0000644000004100000410000000437714642371136020161 0ustar www-datawww-data# Changelog All notable changes to this project since v1.0.3 will be documented in this file. The format is based on [Keep a Changelog v1](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning v2](https://semver.org/spec/v2.0.0.html). ## [Unreleased] ### Added ### Changed ### Fixed ### Removed ## [1.0.6] 2024-06-23 ([tag][1.0.6t]) ### Added - Security policy (SECURITY.md) - Random ordering of test suite - shared examples: - `block_is_expected to not raise` - `block_is_expected to raise error` - Appraisals for testing on every Ruby supported by GHA (2.0 - 3.3) - Signed release ## [1.0.5] - 2023-04-01 ([tag][1.0.5t]) ### Added - Structured gemfiles - Rubocop with standard, gradual, & more - Releases are now signed - Releases now have checksums ### Changed - TravisCI => GitHub Actions - CODE_OF_CONDUCT.md upgraded to v2.0 - Moved from master to main default branch ### Fixed - README Badges (CI status) ## [1.0.4] - 2023-03-23 ([tag][1.0.4t]) ### Added - Required ruby version in gemspec >= 1.8.7 - not bumping major version, because this was already the de-facto minimum ### Changed - Moved rubocop config to root ### Fixed - documentation of rubocop config - Copyright years ## [1.0.3] - 2023-03-23 ([tag][1.0.3t]) ### Added - negated matchers - rubocop config ## [1.0.2] - 2018-10-03 ## [1.0.1] - 2018-10-01 ## 1.0.0 - 2018-10-01 ### Added - Initial Release [Unreleased]: https://github.com/pboling/rspec-block_is_expected/compare/v1.0.6...HEAD [1.0.6]: https://github.com/pboling/rspec-block_is_expected/compare/v1.0.5...v1.0.6 [1.0.6t]: https://github.com/pboling/rspec-block_is_expected/tags/v1.0.6 [1.0.5]: https://github.com/pboling/rspec-block_is_expected/compare/v1.0.4...v1.0.5 [1.0.5t]: https://github.com/pboling/rspec-block_is_expected/tags/v1.0.5 [1.0.4]: https://github.com/pboling/rspec-block_is_expected/compare/v1.0.3...v1.0.4 [1.0.4t]: https://github.com/pboling/rspec-block_is_expected/tags/v1.0.4 [1.0.3]: https://github.com/pboling/rspec-block_is_expected/compare/v1.0.2...v1.0.3 [1.0.3t]: https://github.com/pboling/rspec-block_is_expected/tags/v1.0.3 [1.0.2]: https://github.com/pboling/rspec-block_is_expected/compare/v1.0.1...v1.0.2 [1.0.1]: https://github.com/pboling/rspec-block_is_expected/compare/v1.0.0...v1.0.1