lighthouse-matchers 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +15 -0
- data/CODE_OF_CONDUCT.md +76 -0
- data/CONTRIBUTING.md +153 -0
- data/Gemfile.lock +1 -1
- data/README.md +1 -1
- data/lib/lighthouse/matchers.rb +2 -2
- data/lib/lighthouse/matchers/rspec.rb +1 -2
- data/lib/lighthouse/matchers/version.rb +1 -1
- metadata +4 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fa3cc9c2c57e0dae4e2ebb61d281a094354514473b4ff20ed8e6abf67e9991e9
|
4
|
+
data.tar.gz: 42c1681ad2022e0dc875f715128e14acf3e1fbeffd4755165979796a69da1840
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: be9ce6e8dae7d79907120bc5b0a9f52aec74efb33c10cade08320996f82817ec9e51b118b4335e5d8cb3a1e307df83dfbc236980cb7d59a4bf8fd718310d8ad9
|
7
|
+
data.tar.gz: af2742c37727f20e3813e72d178c3d19acb0e660063476060b3b290243c71c38d6b7ccf9b579bc3344bc8a0e6b3ed4b4d7dd5eddcd9dd5a6fd009424138fe22b
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
# Changelog
|
2
|
+
All notable changes to this project will be documented in this file.
|
3
|
+
|
4
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
5
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
6
|
+
|
7
|
+
## [Unreleased]
|
8
|
+
|
9
|
+
## [1.0.0] - 2019-05-24
|
10
|
+
### Added
|
11
|
+
- Initial version release with minimal viable matcher
|
12
|
+
|
13
|
+
## [1.0.1] - 2019-05-24
|
14
|
+
### Changed
|
15
|
+
- Apply bug fixes based on integration with a Ruby on Rails project
|
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,76 @@
|
|
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, sex characteristics, gender identity and expression,
|
9
|
+
level of experience, education, socio-economic status, nationality, personal
|
10
|
+
appearance, race, religion, or sexual identity and 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 open-source@ackama.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 https://www.contributor-covenant.org/version/1/4/code-of-conduct.html
|
72
|
+
|
73
|
+
[homepage]: https://www.contributor-covenant.org
|
74
|
+
|
75
|
+
For answers to common questions about this code of conduct, see
|
76
|
+
https://www.contributor-covenant.org/faq
|
data/CONTRIBUTING.md
ADDED
@@ -0,0 +1,153 @@
|
|
1
|
+
# Contributing
|
2
|
+
|
3
|
+
Although we are always happy to make improvements, we also
|
4
|
+
welcome changes and improvements from the community!
|
5
|
+
|
6
|
+
Have a fix for a problem you've been running into or an idea for a new feature
|
7
|
+
you think would be useful? Here's what you need to do:
|
8
|
+
|
9
|
+
1. [Read and understand the Code of Conduct](#code-of-conduct).
|
10
|
+
1. Fork this repo and clone your fork to somewhere on your machine.
|
11
|
+
1. [Ensure that you have a working environment](#setting-up-your-environment).
|
12
|
+
1. Read up on the [architecture of the gem](#architecture), [how to run
|
13
|
+
tests](#running-tests), and [the code style we use in this
|
14
|
+
project](#code-style).
|
15
|
+
1. Cut a new branch and write a failing test for the feature or bugfix you plan
|
16
|
+
on implementing.
|
17
|
+
1. [Make sure your branch is well managed as you go
|
18
|
+
along](#managing-your-branch).
|
19
|
+
API](#documentation).
|
20
|
+
1. [Refrain from updating the changelog.](#changelog)
|
21
|
+
1. Push to your fork and submit a pull request.
|
22
|
+
1. [Ensure that the test suite passes on Travis and make any necessary changes
|
23
|
+
to your branch to bring it to green.](#continuous-integration)
|
24
|
+
|
25
|
+
Although we maintain this gem in our free time, we try to respond to
|
26
|
+
contributions in a timely manner. Once we look at your pull request, we may give
|
27
|
+
you feedback. For instance, we may suggest some changes to make to your code to
|
28
|
+
fit within the project style or discuss alternate ways of addressing the issue
|
29
|
+
in question. Assuming we're happy with everything, we'll then bring your changes
|
30
|
+
into master. Now you're a contributor!
|
31
|
+
|
32
|
+
---
|
33
|
+
|
34
|
+
## Code of Conduct
|
35
|
+
|
36
|
+
If this is your first time contributing, please read the [Code of Conduct]. We
|
37
|
+
want to create a space in which everyone is allowed to contribute, and we
|
38
|
+
enforce the policies outline in this document.
|
39
|
+
|
40
|
+
[Code of Conduct]: https://github.com/ackama/lighthouse-matchers/blob/master/CODE_OF_CONDUCT.md
|
41
|
+
|
42
|
+
## Setting up your environment
|
43
|
+
|
44
|
+
The setup script will install all dependencies necessary for working on the
|
45
|
+
project:
|
46
|
+
|
47
|
+
```bash
|
48
|
+
bin/setup
|
49
|
+
```
|
50
|
+
|
51
|
+
## Architecture
|
52
|
+
|
53
|
+
This project follows the typical structure for a gem: code is located in `lib`
|
54
|
+
and tests are in `spec`.
|
55
|
+
|
56
|
+
There are other files in the project, of course, but these are likely the ones
|
57
|
+
you'll be most interested in.
|
58
|
+
|
59
|
+
### Tests
|
60
|
+
|
61
|
+
In addition, tests are broken up into two categories:
|
62
|
+
|
63
|
+
* Unit tests — low-level tests for individual matchers (you're probably
|
64
|
+
interested in these). These tests typically stub out actual requests to the Lighthouse CLI.
|
65
|
+
* Integration tests — high-level tests to ensure that the gem works against the CLI tool. These tests are not updated frequently but are important to make sure that changes to the CLI interface do not cause this library to break.
|
66
|
+
|
67
|
+
Our approach to testing tends to iterate over time. The best approach for writing tests is to copy an existing test in the same file as where you want to add a new test. We may suggest changes to bring the tests in line with
|
68
|
+
our current approach.
|
69
|
+
|
70
|
+
## Code style
|
71
|
+
|
72
|
+
We follow a derivative of the [unofficial Ruby style guide] created by the
|
73
|
+
Rubocop developers. You can view our Rubocop configuration [here], but here are
|
74
|
+
some key differences:
|
75
|
+
|
76
|
+
* We allow longer blocks in spec files. This is because `RSpec.describe` blocks can
|
77
|
+
quite easily go over the default Rubocop limit.
|
78
|
+
* We have increased the maximum line length to 100 characters.
|
79
|
+
|
80
|
+
[unofficial Ruby style guide]: https://github.com/rubocop-hq/ruby-style-guide
|
81
|
+
[here]: .rubocop.yml
|
82
|
+
|
83
|
+
## Running tests
|
84
|
+
|
85
|
+
### Unit tests
|
86
|
+
|
87
|
+
Unit tests are the most common kind of tests in the gem. They exercise matcher
|
88
|
+
code file by file using mocked results from the Lighthouse CLI.
|
89
|
+
|
90
|
+
To run a unit test, you might say something like:
|
91
|
+
|
92
|
+
```bash
|
93
|
+
bundle exec rspec spec/lighthouse/matchers/rspec_spec.rb
|
94
|
+
```
|
95
|
+
|
96
|
+
### Integration tests
|
97
|
+
|
98
|
+
The integration tests exercise matchers using real Lighthouse audit results. We aim to
|
99
|
+
select reasonably complex well-known projects that are know to have good audit scores to exercise
|
100
|
+
that our matchers correctly catch pass and fail conditions.
|
101
|
+
|
102
|
+
To run an integration test, you might say something like:
|
103
|
+
|
104
|
+
```bash
|
105
|
+
bundle exec rspec spec/integration/lighthouse_matchers_spec.rb
|
106
|
+
```
|
107
|
+
|
108
|
+
### All tests
|
109
|
+
|
110
|
+
In order to run all of the tests, simply run:
|
111
|
+
|
112
|
+
```bash
|
113
|
+
bundle exec rake
|
114
|
+
```
|
115
|
+
|
116
|
+
## Managing your branch
|
117
|
+
|
118
|
+
* Use well-crafted commit messages, providing context if possible.
|
119
|
+
* Squash "WIP" commits and remove merge commits by rebasing your branch against
|
120
|
+
`master`. We try to keep our commit history as clean as possible.
|
121
|
+
|
122
|
+
## Documentation
|
123
|
+
|
124
|
+
As you navigate the codebase, you may notice certain classes and methods that
|
125
|
+
are prefaced with inline documentation.
|
126
|
+
|
127
|
+
If your changes end up extending or updating the API, it helps greatly to update the
|
128
|
+
docs at the same time for future developers and other readers of the source code.
|
129
|
+
|
130
|
+
## A word on the changelog
|
131
|
+
|
132
|
+
You may also notice that we have a changelog at [CHANGELOG.md](CHANGELOG.md)
|
133
|
+
You may be tempted to include changes to this in your branch, but don't worry
|
134
|
+
about this — we'll take care of it when we release a new version.
|
135
|
+
|
136
|
+
## Continuous integration
|
137
|
+
|
138
|
+
While running `bundle exec rake` is a great way to check your work, this command
|
139
|
+
will only run your tests against the latest supported Ruby and Rails version.
|
140
|
+
Ultimately, though, you'll want to ensure that your changes work in all possible
|
141
|
+
environments. We make use of [Travis][travis] to do this work for us. Travis
|
142
|
+
will kick in after you push up a branch or open a PR. It takes a few minutes to
|
143
|
+
run a complete build, which you are free to
|
144
|
+
[monitor as it progresses][travis-project].
|
145
|
+
|
146
|
+
[travis-project]: https://travis-ci.org/ackama/lighthouse-matchers
|
147
|
+
|
148
|
+
What happens if the build fails in some way? Don't fear! Click on a failed job
|
149
|
+
and scroll through its output to determine the cause of the failure. You'll want
|
150
|
+
to make changes to your branch and push them up until the entire build is green.
|
151
|
+
It may take a bit of time, but overall it is worth it and it helps us immensely!
|
152
|
+
|
153
|
+
[travis]: https://travis-ci.org/
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Lighthouse Matchers [![Maintainability](https://api.codeclimate.com/v1/badges/2f1df198307f6a0489fc/maintainability)](https://codeclimate.com/github/ackama/lighthouse-matchers/maintainability) [![Build Status](https://travis-ci.org/ackama/lighthouse-matchers.svg?branch=master)](https://travis-ci.org/ackama/lighthouse-matchers)
|
1
|
+
# Lighthouse Matchers [![Gem Version](https://badge.fury.io/rb/lighthouse-matchers.svg)](https://badge.fury.io/rb/lighthouse-matchers) [![Maintainability](https://api.codeclimate.com/v1/badges/2f1df198307f6a0489fc/maintainability)](https://codeclimate.com/github/ackama/lighthouse-matchers/maintainability) [![Build Status](https://travis-ci.org/ackama/lighthouse-matchers.svg?branch=master)](https://travis-ci.org/ackama/lighthouse-matchers)
|
2
2
|
|
3
3
|
Lighthouse Matchers provides single-line RSpec matchers for
|
4
4
|
expectations against the result of [Lighthouse](https://developers.google.com/web/tools/lighthouse/)
|
data/lib/lighthouse/matchers.rb
CHANGED
@@ -20,11 +20,11 @@ module Lighthouse
|
|
20
20
|
end
|
21
21
|
|
22
22
|
def lighthouse_cli
|
23
|
-
@lighthouse_cli ||=
|
23
|
+
@lighthouse_cli ||= guess_lighthouse_cli
|
24
24
|
end
|
25
25
|
|
26
26
|
def runner
|
27
|
-
@runner ||=
|
27
|
+
@runner ||= proc { |cmd| `#{cmd}` }
|
28
28
|
end
|
29
29
|
|
30
30
|
private
|
@@ -11,8 +11,7 @@ RSpec::Matchers.define :pass_lighthouse_audit do |audit, score: nil|
|
|
11
11
|
runner = Lighthouse::Matchers.runner
|
12
12
|
|
13
13
|
url = target.respond_to?(:current_url) ? target.current_url : target
|
14
|
-
opts = "'#{url}' --quiet --output=json"
|
15
|
-
opts << " --port '#{port}'" if port
|
14
|
+
opts = "'#{url}' --quiet --output=json #{"--port=#{port}" if port}".strip
|
16
15
|
cmd = Lighthouse::Matchers.lighthouse_cli
|
17
16
|
output = runner.call("#{cmd} #{opts}")
|
18
17
|
results = JSON.parse(output)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lighthouse-matchers
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Josh McArthur on behalf of Ackama
|
@@ -77,6 +77,9 @@ files:
|
|
77
77
|
- ".rspec"
|
78
78
|
- ".rubocop.yml"
|
79
79
|
- ".travis.yml"
|
80
|
+
- CHANGELOG.md
|
81
|
+
- CODE_OF_CONDUCT.md
|
82
|
+
- CONTRIBUTING.md
|
80
83
|
- Gemfile
|
81
84
|
- Gemfile.lock
|
82
85
|
- LICENSE
|