rspec-block_is_expected 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (41) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +13 -0
  3. data/.rspec +3 -0
  4. data/.rubocop.yml +35 -0
  5. data/.travis.yml +61 -0
  6. data/Appraisals +32 -0
  7. data/CODE_OF_CONDUCT.md +74 -0
  8. data/Gemfile +20 -0
  9. data/LICENSE +22 -0
  10. data/README.md +157 -0
  11. data/Rakefile +28 -0
  12. data/bin/console +14 -0
  13. data/bin/setup +8 -0
  14. data/gemfiles/jruby_1.7.26.gemfile +16 -0
  15. data/gemfiles/jruby_9.1.9.0.gemfile +15 -0
  16. data/gemfiles/jruby_9.1.9.0.gemfile.lock +70 -0
  17. data/gemfiles/jruby_9.2.0.0.gemfile +15 -0
  18. data/gemfiles/jruby_9.2.0.0.gemfile.lock +70 -0
  19. data/gemfiles/jruby_head.gemfile +15 -0
  20. data/gemfiles/jruby_head.gemfile.lock +70 -0
  21. data/gemfiles/ruby_1.8.7_p371.gemfile +16 -0
  22. data/gemfiles/ruby_1.9.3_p551.gemfile +16 -0
  23. data/gemfiles/ruby_2.0.0_p648.gemfile +16 -0
  24. data/gemfiles/ruby_2.0.0_p648.gemfile.lock +50 -0
  25. data/gemfiles/ruby_2.1.10.gemfile +15 -0
  26. data/gemfiles/ruby_2.1.10.gemfile.lock +66 -0
  27. data/gemfiles/ruby_2.2.10.gemfile +16 -0
  28. data/gemfiles/ruby_2.2.10.gemfile.lock +66 -0
  29. data/gemfiles/ruby_2.3.7.gemfile +16 -0
  30. data/gemfiles/ruby_2.3.7.gemfile.lock +66 -0
  31. data/gemfiles/ruby_2.4.4.gemfile +16 -0
  32. data/gemfiles/ruby_2.4.4.gemfile.lock +66 -0
  33. data/gemfiles/ruby_2.5.1.gemfile +16 -0
  34. data/gemfiles/ruby_2.5.1.gemfile.lock +66 -0
  35. data/gemfiles/ruby_head.gemfile +16 -0
  36. data/gemfiles/ruby_head.gemfile.lock +66 -0
  37. data/lib/rspec/block_is_expected.rb +10 -0
  38. data/lib/rspec/block_is_expected/rspec.rb +8 -0
  39. data/lib/rspec/block_is_expected/version.rb +5 -0
  40. data/rspec-block_is_expected.gemspec +32 -0
  41. metadata +174 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: fe189e9ec375dbb1aead1f385e216367faa2d022e2d708a207c3e0e55b3c234f
4
+ data.tar.gz: 9b49603f4101f1b5543dc511a8d07ebcd3828a75135e02b21f0eb71cf9fc6d20
5
+ SHA512:
6
+ metadata.gz: 827380bda808ac6e4a4396b83bc8a671fd3fc485e429b3eb4dfb84de1321705ed0a9004eec92a1ba873f1b4f4819733e80c52b290036afa500d2da1e82f318e6
7
+ data.tar.gz: f98709f7bac689c3ab9c2368e9bbda0da18adc8d1a17b115666e649aa4f62022b7e97bcf00d63318c982520e620f3080f20c974c067100a10464d1491b7e3e3d
data/.gitignore ADDED
@@ -0,0 +1,13 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /*.gem
5
+ /_yardoc/
6
+ /coverage/
7
+ /doc/
8
+ /pkg/
9
+ /spec/reports/
10
+ /tmp/
11
+
12
+ # rspec failure tracking
13
+ .rspec_status
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.rubocop.yml ADDED
@@ -0,0 +1,35 @@
1
+ AllCops:
2
+ DisplayCopNames: true # Display the name of the failing cops
3
+ Exclude:
4
+ - 'gemfiles/vendor/**/*'
5
+ - 'vendor/**/*'
6
+
7
+ Metrics/BlockLength:
8
+ ExcludedMethods:
9
+ - context
10
+ - describe
11
+ - it
12
+ - shared_context
13
+ - shared_examples
14
+ - shared_examples_for
15
+ - namespace
16
+ - draw
17
+
18
+ Metrics/LineLength:
19
+ Enabled: false
20
+
21
+ Style/HashSyntax:
22
+ EnforcedStyle: hash_rockets
23
+
24
+ Style/Lambda:
25
+ Enabled: false
26
+
27
+ Style/PercentLiteralDelimiters:
28
+ Enabled: false
29
+
30
+ Style/SymbolArray:
31
+ Enabled: false
32
+
33
+ # Enable when drop support for Ruby < 2
34
+ Style/ExpandPathArguments:
35
+ Enabled: false
data/.travis.yml ADDED
@@ -0,0 +1,61 @@
1
+ env:
2
+ global:
3
+ - JRUBY_OPTS="-Xcli.debug=true --debug"
4
+ - CC_TEST_REPORTER_ID=13484ad644dba9dd92ac41ef387f76b3c24d73a668ed4d044c933ec14943257d
5
+
6
+ before_script:
7
+ - curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
8
+ - chmod +x ./cc-test-reporter
9
+ - ./cc-test-reporter before-build
10
+
11
+ script:
12
+ - bundle exec rspec
13
+
14
+ after_script:
15
+ - ./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT
16
+
17
+ before_install:
18
+ - gem update --system
19
+ - gem install bundler
20
+
21
+ install:
22
+ - bundle install
23
+
24
+ bundler_args: --no-deployment --jobs 3 --retry 3
25
+
26
+ cache: bundler
27
+
28
+ language: ruby
29
+ sudo: false
30
+ matrix:
31
+ allow_failures:
32
+ - rvm: jruby-head
33
+ - rvm: ruby-head
34
+ fast_finish: true
35
+ include:
36
+ - rvm: 1.8.7-p371
37
+ gemfile: gemfiles/ruby_1.8.7_p371.gemfile
38
+ - rvm: 1.9.3-p551
39
+ gemfile: gemfiles/ruby_1.9.3_p551.gemfile
40
+ - rvm: 2.0.0-p648
41
+ gemfile: gemfiles/ruby_2.0.0_p648.gemfile
42
+ - rvm: 2.1.10
43
+ gemfile: gemfiles/ruby_2.1.10.gemfile
44
+ - rvm: 2.2.10
45
+ gemfile: gemfiles/ruby_2.2.10.gemfile
46
+ - rvm: 2.3.7
47
+ gemfile: gemfiles/ruby_2.3.7.gemfile
48
+ - rvm: 2.4.4
49
+ gemfile: gemfiles/ruby_2.4.4.gemfile
50
+ - rvm: 2.5.1
51
+ gemfile: gemfiles/ruby_2.5.1.gemfile
52
+ - rvm: ruby-head
53
+ gemfile: gemfiles/ruby_head.gemfile
54
+ - rvm: jruby-1.7.26
55
+ gemfile: gemfiles/jruby_1.7.26.gemfile
56
+ - rvm: jruby-9.1.9.0
57
+ gemfile: gemfiles/jruby_9.1.9.0.gemfile
58
+ - rvm: jruby-9.2.0.0
59
+ gemfile: gemfiles/jruby_9.2.0.0.gemfile
60
+ - rvm: jruby-head
61
+ gemfile: gemfiles/jruby_head.gemfile
data/Appraisals ADDED
@@ -0,0 +1,32 @@
1
+ appraise 'jruby-1.7.26' do
2
+ end
3
+
4
+ appraise 'ruby-1.8.7-p371' do
5
+ end
6
+
7
+ appraise 'ruby-1.9.3-p551' do
8
+ end
9
+
10
+ appraise 'ruby-2.0.0-p648' do
11
+ end
12
+
13
+ appraise 'ruby-2.1.10' do
14
+ end
15
+
16
+ appraise 'ruby-2.2.10' do
17
+ end
18
+
19
+ appraise 'jruby-9.1.9.0' do
20
+ end
21
+
22
+ appraise 'ruby-2.3.7' do
23
+ end
24
+
25
+ appraise 'ruby-2.4.4' do
26
+ end
27
+
28
+ appraise 'ruby-2.5.1' do
29
+ end
30
+
31
+ appraise 'jruby-9.2.0.0' do
32
+ end
@@ -0,0 +1,74 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, gender identity and expression, level of experience,
9
+ nationality, personal appearance, race, religion, or sexual identity and
10
+ orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at peter.boling@gmail.com. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at [http://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: http://contributor-covenant.org
74
+ [version]: http://contributor-covenant.org/version/1/4/
data/Gemfile ADDED
@@ -0,0 +1,20 @@
1
+ source 'https://rubygems.org'
2
+
3
+ git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
4
+
5
+ group :test do
6
+ ruby_version = Gem::Version.new(RUBY_VERSION)
7
+ if ruby_version >= Gem::Version.new('2.1')
8
+ gem 'rubocop', '~> 0.59.0'
9
+ gem 'rubocop-rspec', '~> 1.24.0'
10
+ end
11
+ if ruby_version >= Gem::Version.new('2.0')
12
+ gem 'byebug', '~> 10', platform: :mri, require: false
13
+ gem 'pry', '~> 0', platform: :mri, require: false
14
+ gem 'pry-byebug', '~> 3', platform: :mri, require: false
15
+ end
16
+ gem 'simplecov', '~> 0', require: false
17
+ end
18
+
19
+ # Specify your gem's dependencies in rspec-block_is_expected.gemspec
20
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2018 Peter H. Boling of RailsBling.com
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,157 @@
1
+ # Rspec::BlockIsExpected
2
+
3
+ This gem does one very simple thing very well. It allows you to use `block_is_expected` similarly to how you would use `is_expected` if a block was wrapping the subject. Supports the same versions of Ruby that RSpec does, 1.8.7 - current ruby-head, as well as the JRuby equivalents.
4
+
5
+ ```ruby
6
+ subject { Integer(nil) }
7
+ it('raises') { block_is_expected.to raise_error(TypeError) }
8
+ ```
9
+
10
+ | Project | AnonymousActiveRecord |
11
+ |------------------------ | ----------------------- |
12
+ | gem name | [rspec-block_is_expected](https://rubygems.org/gems/rspec-block_is_expected) |
13
+ | license | [![License: MIT](https://img.shields.io/badge/License-MIT-green.svg)](https://opensource.org/licenses/MIT) |
14
+ | download rank | [![Downloads Today](https://img.shields.io/gem/rd/rspec-block_is_expected.svg)](https://github.com/pboling/rspec-block_is_expected) |
15
+ | version | [![Version](https://img.shields.io/gem/v/rspec-block_is_expected.svg)](https://rubygems.org/gems/rspec-block_is_expected) |
16
+ | dependencies | [![Depfu](https://badges.depfu.com/badges/272ce0df3bc6df5cbea9354e2c3b65af/count.svg)](https://depfu.com/github/pboling/rspec-block_is_expected?project_id=5614) |
17
+ | continuous integration | [![Build Status](https://travis-ci.org/pboling/rspec-block_is_expected.svg?branch=master)](https://travis-ci.org/pboling/rspec-block_is_expected) |
18
+ | test coverage | [![Test Coverage](https://api.codeclimate.com/v1/badges/ca0a12604ecc19f5e76d/test_coverage)](https://codeclimate.com/github/pboling/rspec-block_is_expected/test_coverage) |
19
+ | maintainability | [![Maintainability](https://api.codeclimate.com/v1/badges/ca0a12604ecc19f5e76d/maintainability)](https://codeclimate.com/github/pboling/rspec-block_is_expected/maintainability) |
20
+ | 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) |
21
+ | homepage | [on Github.com][homepage], [on Railsbling.com][blogpage] |
22
+ | documentation | [on RDoc.info][documentation] |
23
+ | Spread ~♡ⓛⓞⓥⓔ♡~ | [🌍 🌎 🌏][peterboling], [🍚][refugees], [➕][gplus], [👼][angellist], [🐛][topcoder], [:shipit:][coderwall], [![Tweet Peter](https://img.shields.io/twitter/follow/galtzo.svg?style=social&label=Follow)][twitter] |
24
+
25
+ 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/).
26
+
27
+ ## Installation
28
+
29
+ Add this line to your application's Gemfile:
30
+
31
+ ```ruby
32
+ gem 'rspec-block_is_expected', group: :test
33
+ ```
34
+
35
+ And then execute:
36
+
37
+ $ bundle
38
+
39
+ Or install it yourself as:
40
+
41
+ $ gem install rspec-block_is_expected
42
+
43
+ ## Configuration
44
+
45
+ There is no configuration needed if you your test suite loads the bundle group (e.g. `test`) that you added the gem to.
46
+
47
+ Otherwise, you may load it manually near the top of your `spec_helper.rb`, and it will self configure.
48
+ ```ruby
49
+ require 'rspec/block_is_expected'
50
+ ```
51
+
52
+ ## Usage
53
+
54
+ The spec suite for this gem has some examples of usage, lightly edited here.
55
+
56
+ ```ruby
57
+ RSpec.describe 'TestyMcTest' do
58
+ context 'errors raised' do
59
+ subject { Integer(nil) }
60
+ it('can be tested') do
61
+ # Where you used to have:
62
+ # expect { subject }.to raise_error(TypeError)
63
+ block_is_expected.to raise_error(TypeError)
64
+ end
65
+ end
66
+ context 'execution' do
67
+ let(:mutex) { Mutex.new }
68
+ subject { mutex.lock }
69
+ it('can change state') do
70
+ expect(mutex.locked?).to eq(false)
71
+ # Where you used to have:
72
+ # expect { subject }.to_not raise_error
73
+ block_is_expected.to_not raise_error
74
+ expect(mutex.locked?).to eq(true)
75
+ end
76
+ end
77
+ context 'changed state' do
78
+ let(:mutex) { Mutex.new }
79
+ subject { mutex.lock }
80
+ it('can be tested') do
81
+ # Where you used to have:
82
+ # expect { subject }.to change { mutex.locked? }.from(false).to(true)
83
+ block_is_expected.to change { mutex.locked? }.from(false).to(true)
84
+ end
85
+ end
86
+ end
87
+ ```
88
+
89
+ ## Development
90
+
91
+ 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.
92
+
93
+ 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).
94
+
95
+ ## Authors
96
+
97
+ [Peter H. Boling][peterboling] of [Rails Bling][railsbling] is the author.
98
+
99
+ ## Contributors
100
+
101
+ See the [Network View](https://github.com/pboling/rspec-block_is_expected/network) and the [CHANGELOG](https://github.com/pboling/rspec-block_is_expected/blob/master/CHANGELOG.md)
102
+
103
+ ## Contributing
104
+
105
+ 1. Fork it
106
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
107
+ 3. Commit your changes (`git commit -am 'Added some feature'`)
108
+ 4. Push to the branch (`git push origin my-new-feature`)
109
+ 5. Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
110
+ 6. Create new Pull Request
111
+
112
+ Bug reports and pull requests are welcome on GitHub at https://github.com/pboling/anonymous_active_record. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
113
+
114
+ ## Code of Conduct
115
+
116
+ Everyone interacting in the AnonymousActiveRecord project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/pboling/anonymous_active_record/blob/master/CODE_OF_CONDUCT.md).
117
+
118
+ ## Versioning
119
+
120
+ This library aims to adhere to [Semantic Versioning 2.0.0][semver].
121
+ Violations of this scheme should be reported as bugs. Specifically,
122
+ if a minor or patch version is released that breaks backward
123
+ compatibility, a new version should be immediately released that
124
+ restores compatibility. Breaking changes to the public API will
125
+ only be introduced with new major versions.
126
+
127
+ As a result of this policy, you can (and should) specify a
128
+ dependency on this gem using the [Pessimistic Version Constraint][pvc] with two digits of precision.
129
+
130
+ For example in a `Gemfile`:
131
+
132
+ gem 'rspec-block_is_expected', '~> 1.0', group: :test
133
+
134
+ or in a `gemspec`
135
+
136
+ spec.add_development_dependency 'rspec-block_is_expected', '~> 1.0'
137
+
138
+ ## Legal
139
+
140
+ * MIT License - See [LICENSE][license] file in this project [![License: MIT](https://img.shields.io/badge/License-MIT-green.svg)](https://opensource.org/licenses/MIT)
141
+
142
+ * Copyright (c) 2018 [Peter H. Boling][peterboling] of [Rails Bling][railsbling]
143
+
144
+ [semver]: http://semver.org/
145
+ [pvc]: http://guides.rubygems.org/patterns/#pessimistic-version-constraint
146
+ [documentation]: http://rdoc.info/github/pboling/rspec-block_is_expected/frames
147
+ [homepage]: https://github.com/pboling/rspec-block_is_expected
148
+ [blogpage]: http://www.railsbling.com/tags/rspec-block_is_expected/
149
+ [license]: LICENSE
150
+ [railsbling]: http://www.railsbling.com
151
+ [peterboling]: https://about.me/peter.boling
152
+ [refugees]: https://www.crowdrise.com/helprefugeeswithhopefortomorrowliberia/fundraiser/peterboling
153
+ [gplus]: https://plus.google.com/+PeterBoling/posts
154
+ [topcoder]: https://www.topcoder.com/members/pboling/
155
+ [angellist]: https://angel.co/peter-boling
156
+ [coderwall]: http://coderwall.com/pboling
157
+ [twitter]: http://twitter.com/galtzo
data/Rakefile ADDED
@@ -0,0 +1,28 @@
1
+ require 'bundler/gem_tasks'
2
+ begin
3
+ require 'wwtd/tasks'
4
+ rescue LoadError
5
+ puts 'failed to load wwtd'
6
+ end
7
+
8
+ begin
9
+ require 'rspec/core/rake_task'
10
+ RSpec::Core::RakeTask.new(:spec)
11
+ rescue LoadError
12
+ # puts "failed to load wwtd or rspec, probably because bundled --without-development"
13
+ task :spec do
14
+ warn 'rspec is disabled'
15
+ end
16
+ end
17
+ task :test => :spec
18
+
19
+ begin
20
+ require 'rubocop/rake_task'
21
+ RuboCop::RakeTask.new
22
+ rescue LoadError
23
+ task :rubocop do
24
+ warn 'RuboCop is disabled'
25
+ end
26
+ end
27
+
28
+ task :default => [:test, :rubocop]