rspec-hanami 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 +11 -0
- data/.travis.yml +4 -0
- data/CODE_OF_CONDUCT.md +49 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +63 -0
- data/Rakefile +10 -0
- data/lib/rspec/hanami.rb +7 -0
- data/lib/rspec/hanami/matchers.rb +11 -0
- data/lib/rspec/hanami/matchers/have_http_status.rb +72 -0
- data/lib/rspec/hanami/version.rb +5 -0
- data/rspec-hanami.gemspec +28 -0
- metadata +127 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: bf5af4a13928500eeb05766325ec71498e894293
|
4
|
+
data.tar.gz: 1c8a50b5f315674be91a1e197d0ef5beec599df9
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 475c52b5823b42c36831f750cb1d22230049027416f525c268e55f97347d13ed6c63eb91bd0357f092dd0a237a4fdb14281860961cf888c7bc1afde8930b6f36
|
7
|
+
data.tar.gz: dcfc1d27771f5937d6f063d5d8852ade45b6863a2312f3b71f7c386458c00db618dce2f80235590a9461a2c62b7b37dc178ec7b845e6c724e4eac8eac7ef95ee
|
data/.gitignore
ADDED
data/.travis.yml
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
# Contributor Code of Conduct
|
2
|
+
|
3
|
+
As contributors and maintainers of this project, and in the interest of
|
4
|
+
fostering an open and welcoming community, we pledge to respect all people who
|
5
|
+
contribute through reporting issues, posting feature requests, updating
|
6
|
+
documentation, submitting pull requests or patches, and other activities.
|
7
|
+
|
8
|
+
We are committed to making participation in this project a harassment-free
|
9
|
+
experience for everyone, regardless of level of experience, gender, gender
|
10
|
+
identity and expression, sexual orientation, disability, personal appearance,
|
11
|
+
body size, race, ethnicity, age, religion, or nationality.
|
12
|
+
|
13
|
+
Examples of unacceptable behavior by participants include:
|
14
|
+
|
15
|
+
* The use of sexualized language or imagery
|
16
|
+
* Personal attacks
|
17
|
+
* Trolling or insulting/derogatory comments
|
18
|
+
* Public or private harassment
|
19
|
+
* Publishing other's private information, such as physical or electronic
|
20
|
+
addresses, without explicit permission
|
21
|
+
* Other unethical or unprofessional conduct
|
22
|
+
|
23
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
24
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
25
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
26
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
27
|
+
threatening, offensive, or harmful.
|
28
|
+
|
29
|
+
By adopting this Code of Conduct, project maintainers commit themselves to
|
30
|
+
fairly and consistently applying these principles to every aspect of managing
|
31
|
+
this project. Project maintainers who do not follow or enforce the Code of
|
32
|
+
Conduct may be permanently removed from the project team.
|
33
|
+
|
34
|
+
This code of conduct applies both within project spaces and in public spaces
|
35
|
+
when an individual is representing the project or its community.
|
36
|
+
|
37
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
38
|
+
reported by contacting a project maintainer at antondavydov.o@gmail.com. All
|
39
|
+
complaints will be reviewed and investigated and will result in a response that
|
40
|
+
is deemed necessary and appropriate to the circumstances. Maintainers are
|
41
|
+
obligated to maintain confidentiality with regard to the reporter of an
|
42
|
+
incident.
|
43
|
+
|
44
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage],
|
45
|
+
version 1.3.0, available at
|
46
|
+
[http://contributor-covenant.org/version/1/3/0/][version]
|
47
|
+
|
48
|
+
[homepage]: http://contributor-covenant.org
|
49
|
+
[version]: http://contributor-covenant.org/version/1/3/0/
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2016 Anton Davydov
|
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,63 @@
|
|
1
|
+
# RSpec::Hanami
|
2
|
+
**rspec-rails** is a testing framework for [hanami](http://hanamirb.org)
|
3
|
+
|
4
|
+
## Installation
|
5
|
+
Add this line to your application's Gemfile:
|
6
|
+
|
7
|
+
```ruby
|
8
|
+
group :test do
|
9
|
+
gem 'rspec-hanami'
|
10
|
+
end
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install rspec-hanami
|
20
|
+
|
21
|
+
## Supported matchers
|
22
|
+
### Controller Specs
|
23
|
+
#### `have_http_status`
|
24
|
+
Passes if `response` has a matching HTTP status code.
|
25
|
+
|
26
|
+
The following symbolic status codes are allowed:
|
27
|
+
- `:error`
|
28
|
+
- `:missing`
|
29
|
+
- `:redirect`
|
30
|
+
- `:success`
|
31
|
+
- `Rack::Utils::SYMBOL_TO_STATUS_CODE`
|
32
|
+
|
33
|
+
``` ruby
|
34
|
+
response = action.call(params)
|
35
|
+
expect(response).to have_http_status(404)
|
36
|
+
expect(response).to have_http_status(:created)
|
37
|
+
expect(response).to have_http_status(:success)
|
38
|
+
expect(response).to have_http_status(:error)
|
39
|
+
expect(response).to have_http_status(:missing)
|
40
|
+
expect(response).to have_http_status(:redirect)
|
41
|
+
```
|
42
|
+
|
43
|
+
## TODO
|
44
|
+
|
45
|
+
- [ ] `expect(action).to be_success`
|
46
|
+
- [ ] `expect(response).to render_template("index")`
|
47
|
+
- [ ] `expect(response).to redirect_to(widgets_path)`
|
48
|
+
|
49
|
+
## Also see
|
50
|
+
|
51
|
+
* [https://github.com/rspec/rspec](https://github.com/rspec/rspec)
|
52
|
+
* [https://github.com/rspec/rspec-core](https://github.com/rspec/rspec-core)
|
53
|
+
* [https://github.com/rspec/rspec-expectations](https://github.com/rspec/rspec-expectations)
|
54
|
+
* [https://github.com/rspec/rspec-mocks](https://github.com/rspec/rspec-mocks)
|
55
|
+
|
56
|
+
## Feature Requests & Bugs
|
57
|
+
|
58
|
+
See <http://github.com/davydovanton/rspec-hanami/issues>
|
59
|
+
|
60
|
+
## License
|
61
|
+
|
62
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
63
|
+
|
data/Rakefile
ADDED
data/lib/rspec/hanami.rb
ADDED
@@ -0,0 +1,72 @@
|
|
1
|
+
module RSpec
|
2
|
+
module Hanami
|
3
|
+
module Matchers
|
4
|
+
extend ::RSpec::Matchers::DSL
|
5
|
+
|
6
|
+
# @api public
|
7
|
+
# Passes if `response` has a matching HTTP status code.
|
8
|
+
#
|
9
|
+
# The following symbolic status codes are allowed:
|
10
|
+
# - `:error`
|
11
|
+
# - `:missing`
|
12
|
+
# - `:redirect`
|
13
|
+
# - `:success`
|
14
|
+
#
|
15
|
+
# @example Accepts numeric and symbol statuses
|
16
|
+
# response = action.call(params)
|
17
|
+
# expect(response).to have_http_status(404)
|
18
|
+
# expect(response).to have_http_status(:created)
|
19
|
+
# expect(response).to have_http_status(:success)
|
20
|
+
# expect(response).to have_http_status(:error)
|
21
|
+
# expect(response).to have_http_status(:missing)
|
22
|
+
# expect(response).to have_http_status(:redirect)
|
23
|
+
#
|
24
|
+
matcher :have_http_status do |status|
|
25
|
+
attr_reader :actual
|
26
|
+
attr_reader :object
|
27
|
+
|
28
|
+
description { "have response #{status}" }
|
29
|
+
match do |object|
|
30
|
+
@object = object
|
31
|
+
@actual = object.first
|
32
|
+
MatchStatus.new.call(actual, status)
|
33
|
+
end
|
34
|
+
|
35
|
+
failure_message { |actual| "expect #{object} to have status #{status}" }
|
36
|
+
diffable
|
37
|
+
end
|
38
|
+
|
39
|
+
class MatchStatus
|
40
|
+
def call(actual, expected)
|
41
|
+
case expected
|
42
|
+
when Numeric
|
43
|
+
actual == expected
|
44
|
+
when Symbol
|
45
|
+
chec_symbol_status(actual, expected)
|
46
|
+
else
|
47
|
+
false
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
private
|
52
|
+
|
53
|
+
TYPE_CODES = {
|
54
|
+
error: /(4|5)../,
|
55
|
+
success: /2../,
|
56
|
+
missing: /404/,
|
57
|
+
redirect: /3../,
|
58
|
+
}.freeze
|
59
|
+
|
60
|
+
def chec_symbol_status(actual, expected)
|
61
|
+
status = TYPE_CODES[expected]
|
62
|
+
|
63
|
+
if status
|
64
|
+
!!actual.to_s.match(status)
|
65
|
+
else
|
66
|
+
actual == Rack::Utils::SYMBOL_TO_STATUS_CODE[expected]
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'rspec/hanami/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "rspec-hanami"
|
8
|
+
spec.version = RSpec::Hanami::VERSION
|
9
|
+
spec.authors = ["Anton Davydov"]
|
10
|
+
spec.email = ["antondavydov.o@gmail.com"]
|
11
|
+
|
12
|
+
spec.summary = %q{RSpec Matchers for Hanami}
|
13
|
+
spec.description = %q{RSpec Matchers for Hanami}
|
14
|
+
spec.homepage = "https://github.com/davydovanton/rspec-hanami"
|
15
|
+
spec.license = "MIT"
|
16
|
+
|
17
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
18
|
+
spec.bindir = "exe"
|
19
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
20
|
+
spec.require_paths = ["lib"]
|
21
|
+
|
22
|
+
spec.add_dependency "rspec"
|
23
|
+
spec.add_dependency "hanami"
|
24
|
+
|
25
|
+
spec.add_development_dependency "bundler", "~> 1.11"
|
26
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
27
|
+
spec.add_development_dependency "minitest", "~> 5.0"
|
28
|
+
end
|
metadata
ADDED
@@ -0,0 +1,127 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: rspec-hanami
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Anton Davydov
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-05-25 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rspec
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: hanami
|
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.11'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '1.11'
|
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: minitest
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '5.0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '5.0'
|
83
|
+
description: RSpec Matchers for Hanami
|
84
|
+
email:
|
85
|
+
- antondavydov.o@gmail.com
|
86
|
+
executables: []
|
87
|
+
extensions: []
|
88
|
+
extra_rdoc_files: []
|
89
|
+
files:
|
90
|
+
- ".gitignore"
|
91
|
+
- ".travis.yml"
|
92
|
+
- CODE_OF_CONDUCT.md
|
93
|
+
- Gemfile
|
94
|
+
- LICENSE.txt
|
95
|
+
- README.md
|
96
|
+
- Rakefile
|
97
|
+
- lib/rspec/hanami.rb
|
98
|
+
- lib/rspec/hanami/matchers.rb
|
99
|
+
- lib/rspec/hanami/matchers/have_http_status.rb
|
100
|
+
- lib/rspec/hanami/version.rb
|
101
|
+
- rspec-hanami.gemspec
|
102
|
+
homepage: https://github.com/davydovanton/rspec-hanami
|
103
|
+
licenses:
|
104
|
+
- MIT
|
105
|
+
metadata: {}
|
106
|
+
post_install_message:
|
107
|
+
rdoc_options: []
|
108
|
+
require_paths:
|
109
|
+
- lib
|
110
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
111
|
+
requirements:
|
112
|
+
- - ">="
|
113
|
+
- !ruby/object:Gem::Version
|
114
|
+
version: '0'
|
115
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
116
|
+
requirements:
|
117
|
+
- - ">="
|
118
|
+
- !ruby/object:Gem::Version
|
119
|
+
version: '0'
|
120
|
+
requirements: []
|
121
|
+
rubyforge_project:
|
122
|
+
rubygems_version: 2.5.1
|
123
|
+
signing_key:
|
124
|
+
specification_version: 4
|
125
|
+
summary: RSpec Matchers for Hanami
|
126
|
+
test_files: []
|
127
|
+
has_rdoc:
|