pain_in_the_rspec 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +9 -0
- data/.rspec +2 -0
- data/.travis.yml +9 -0
- data/CODE_OF_CONDUCT.md +13 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +64 -0
- data/Rakefile +7 -0
- data/bin/console +14 -0
- data/bin/setup +5 -0
- data/lib/pain_in_the_rspec.rb +3 -0
- data/lib/pain_in_the_rspec/formatter.rb +51 -0
- data/lib/pain_in_the_rspec/pundit.rb +57 -0
- data/lib/pain_in_the_rspec/version.rb +3 -0
- data/pain_in_the_rspec.gemspec +27 -0
- metadata +129 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: e9a6e289ebf6e3d97d06fde8174e8c607a5ba012
|
4
|
+
data.tar.gz: 91ea52a8ca4110f616539662b41597e0624806da
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 4db58b0931069093bffc97caba9df2c8e82a5d0b8c2bce6202c30b7a767f772f45af572bb1d73f818431a02a3c094793c54d29e4a0df890f8acbecf022e18906
|
7
|
+
data.tar.gz: ebdb717d9a76e357498e6c9086196ecc8fd678c1f98759eeef1c74be136ff94e24d699c745354e424c7d9fa6fa04692252a77af926fe1e4b9b31f01543f1a165
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
# Contributor Code of Conduct
|
2
|
+
|
3
|
+
As contributors and maintainers of this project, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.
|
4
|
+
|
5
|
+
We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, age, or religion.
|
6
|
+
|
7
|
+
Examples of unacceptable behavior by participants include the use of sexual language or imagery, derogatory comments or personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct.
|
8
|
+
|
9
|
+
Project maintainers 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. Project maintainers who do not follow the Code of Conduct may be removed from the project team.
|
10
|
+
|
11
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers.
|
12
|
+
|
13
|
+
This Code of Conduct is adapted from the [Contributor Covenant](http:contributor-covenant.org), version 1.0.0, available at [http://contributor-covenant.org/version/1/0/0/](http://contributor-covenant.org/version/1/0/0/)
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2015 Gabe Berke-Williams
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,64 @@
|
|
1
|
+
# A Real Pain in the RSpec
|
2
|
+
|
3
|
+
Run your RSpec tests and print out punny spec descriptions.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem "pain_in_the_rspec"
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install pain_in_the_rspec
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
Run your specs like this:
|
24
|
+
|
25
|
+
$ rspec --format PainInTheRspec::Formatter spec/
|
26
|
+
|
27
|
+
To always run your specs with PainInTheRspec, add the following line to your
|
28
|
+
`.rspec` file:
|
29
|
+
|
30
|
+
--format PainInTheRspec::Formatter
|
31
|
+
|
32
|
+
## Pitfalls
|
33
|
+
|
34
|
+
The formatter uses a web API to get rhymes. It will therefore make a web request
|
35
|
+
for each example in your suite.
|
36
|
+
|
37
|
+
If you're using WebMock, you'll need to allow external network requests:
|
38
|
+
|
39
|
+
```ruby
|
40
|
+
# Allow all network requests:
|
41
|
+
WebMock.allow_net_connect!
|
42
|
+
# Or, to only allow the website that this gem uses:
|
43
|
+
WebMock.disable_net_connect!(allow: "rhymebrain.com")
|
44
|
+
# Or, if you're already allowing example.com:
|
45
|
+
WebMock.disable_net_connect!(allow: ["example.com", "rhymebrain.com"])
|
46
|
+
```
|
47
|
+
|
48
|
+
## Development
|
49
|
+
|
50
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run
|
51
|
+
`bin/console` for an interactive prompt that will allow you to experiment.
|
52
|
+
|
53
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To
|
54
|
+
release a new version, update the version number in `version.rb`, and then run
|
55
|
+
`bundle exec rake release` to create a git tag for the version, push git commits
|
56
|
+
and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
57
|
+
|
58
|
+
## Contributing
|
59
|
+
|
60
|
+
1. Fork it ( https://github.com/[my-github-username]/pain_in_the_rspec/fork )
|
61
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
62
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
63
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
64
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "pain_in_the_rspec"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start
|
data/bin/setup
ADDED
@@ -0,0 +1,51 @@
|
|
1
|
+
require "rspec/core"
|
2
|
+
require "pain_in_the_rspec"
|
3
|
+
|
4
|
+
module PainInTheRspec
|
5
|
+
class Formatter < RSpec::Core::Formatters::DocumentationFormatter
|
6
|
+
RSpec::Core::Formatters.register self, :example_passed, :example_pending,
|
7
|
+
:example_failed
|
8
|
+
|
9
|
+
def example_failed(failure)
|
10
|
+
output.puts failure_output(
|
11
|
+
failure.example,
|
12
|
+
failure.example.execution_result.exception
|
13
|
+
)
|
14
|
+
end
|
15
|
+
|
16
|
+
def example_passed(passed)
|
17
|
+
output.puts passed_output(passed.example)
|
18
|
+
end
|
19
|
+
|
20
|
+
private
|
21
|
+
|
22
|
+
def passed_output(example)
|
23
|
+
wrap(pun_description(example), :success)
|
24
|
+
end
|
25
|
+
|
26
|
+
def pending_output(example, message)
|
27
|
+
wrap(
|
28
|
+
"#{pun_description(example)} (PENDING: #{message})",
|
29
|
+
:pending
|
30
|
+
)
|
31
|
+
end
|
32
|
+
|
33
|
+
def failure_output(example, _exception)
|
34
|
+
message = pun_description(example)
|
35
|
+
|
36
|
+
wrap(
|
37
|
+
"#{message} (FAILED - #{next_failure_index})",
|
38
|
+
:failure
|
39
|
+
)
|
40
|
+
end
|
41
|
+
|
42
|
+
def pun_description(example)
|
43
|
+
current_indentation +
|
44
|
+
Pundit.new(example.description.strip).pun
|
45
|
+
end
|
46
|
+
|
47
|
+
def wrap(message, status)
|
48
|
+
RSpec::Core::Formatters::ConsoleCodes.wrap(message, status)
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
@@ -0,0 +1,57 @@
|
|
1
|
+
require "girls_just_want_to_have_puns"
|
2
|
+
|
3
|
+
module PainInTheRspec
|
4
|
+
class Pundit
|
5
|
+
BANNED_WORDS = %w(should can and)
|
6
|
+
|
7
|
+
def initialize(original)
|
8
|
+
@original = original
|
9
|
+
end
|
10
|
+
|
11
|
+
def pun
|
12
|
+
if found_pun?
|
13
|
+
[found_pun.new_phrase, rest_of_phrase].join(" ").strip
|
14
|
+
else
|
15
|
+
"[pun of #{original}]"
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
private
|
20
|
+
|
21
|
+
attr_reader :original
|
22
|
+
|
23
|
+
def found_pun?
|
24
|
+
!found_pun.nil?
|
25
|
+
end
|
26
|
+
|
27
|
+
def found_pun
|
28
|
+
@found_pun ||= GirlsJustWantToHavePuns.pun(pun_word) ||
|
29
|
+
GirlsJustWantToHavePuns.pun(singular_pun_word) ||
|
30
|
+
GirlsJustWantToHavePuns.pun(other_singular_pun_word)
|
31
|
+
end
|
32
|
+
|
33
|
+
def pun_word
|
34
|
+
filtered.first
|
35
|
+
end
|
36
|
+
|
37
|
+
def singular_pun_word
|
38
|
+
pun_word.sub(/s$/, "")
|
39
|
+
end
|
40
|
+
|
41
|
+
def other_singular_pun_word
|
42
|
+
pun_word.sub(/es$/, "")
|
43
|
+
end
|
44
|
+
|
45
|
+
def filtered
|
46
|
+
original.split(" ") - BANNED_WORDS
|
47
|
+
end
|
48
|
+
|
49
|
+
def rest_of_phrase
|
50
|
+
if filtered.size > 0
|
51
|
+
filtered[1..-1].join(" ")
|
52
|
+
else
|
53
|
+
""
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'pain_in_the_rspec/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "pain_in_the_rspec"
|
8
|
+
spec.version = PainInTheRspec::VERSION
|
9
|
+
spec.authors = ["Gabe Berke-Williams"]
|
10
|
+
spec.email = ["gabebw@gabebw.com"]
|
11
|
+
|
12
|
+
spec.summary = %q{Print out punny spec descriptions}
|
13
|
+
spec.homepage = "https://github.com/gabebw/pain_in_the_rspec"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
17
|
+
spec.bindir = "exe"
|
18
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_dependency "rspec-core", "~> 3.0"
|
22
|
+
spec.add_dependency "girls_just_want_to_have_puns"
|
23
|
+
|
24
|
+
spec.add_development_dependency "bundler", "~> 1.9"
|
25
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
26
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
27
|
+
end
|
metadata
ADDED
@@ -0,0 +1,129 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: pain_in_the_rspec
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Gabe Berke-Williams
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-05-11 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rspec-core
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '3.0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '3.0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: girls_just_want_to_have_puns
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: bundler
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '1.9'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '1.9'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rake
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '10.0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '10.0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rspec
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '3.0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '3.0'
|
83
|
+
description:
|
84
|
+
email:
|
85
|
+
- gabebw@gabebw.com
|
86
|
+
executables: []
|
87
|
+
extensions: []
|
88
|
+
extra_rdoc_files: []
|
89
|
+
files:
|
90
|
+
- ".gitignore"
|
91
|
+
- ".rspec"
|
92
|
+
- ".travis.yml"
|
93
|
+
- CODE_OF_CONDUCT.md
|
94
|
+
- Gemfile
|
95
|
+
- LICENSE.txt
|
96
|
+
- README.md
|
97
|
+
- Rakefile
|
98
|
+
- bin/console
|
99
|
+
- bin/setup
|
100
|
+
- lib/pain_in_the_rspec.rb
|
101
|
+
- lib/pain_in_the_rspec/formatter.rb
|
102
|
+
- lib/pain_in_the_rspec/pundit.rb
|
103
|
+
- lib/pain_in_the_rspec/version.rb
|
104
|
+
- pain_in_the_rspec.gemspec
|
105
|
+
homepage: https://github.com/gabebw/pain_in_the_rspec
|
106
|
+
licenses:
|
107
|
+
- MIT
|
108
|
+
metadata: {}
|
109
|
+
post_install_message:
|
110
|
+
rdoc_options: []
|
111
|
+
require_paths:
|
112
|
+
- lib
|
113
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ">="
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
119
|
+
requirements:
|
120
|
+
- - ">="
|
121
|
+
- !ruby/object:Gem::Version
|
122
|
+
version: '0'
|
123
|
+
requirements: []
|
124
|
+
rubyforge_project:
|
125
|
+
rubygems_version: 2.4.5
|
126
|
+
signing_key:
|
127
|
+
specification_version: 4
|
128
|
+
summary: Print out punny spec descriptions
|
129
|
+
test_files: []
|