confidence-check 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +8 -0
- data/.rspec +1 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/CONTRIBUTING.md +5 -0
- data/Gemfile +6 -0
- data/Gemfile.lock +60 -0
- data/LICENSE.md +34 -0
- data/README.md +190 -0
- data/Rakefile +4 -0
- data/bin/console +7 -0
- data/bin/rake +29 -0
- data/bin/rspec +29 -0
- data/bin/setup +6 -0
- data/confidence-check.gemspec +27 -0
- data/lib/confidence-check.rb +3 -0
- data/lib/confidence_check/check_method.rb +19 -0
- data/lib/confidence_check/confidence_check_failed.rb +14 -0
- data/lib/confidence_check/for_minitest.rb +18 -0
- data/lib/confidence_check/for_rspec.rb +18 -0
- metadata +106 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 0551447cc3cebd68bfa29b13f024e6ad309ea8bcb45e259c9de276c8eef7aa1a
|
4
|
+
data.tar.gz: ef09063ae2d1d69fa21a22a113d07ac5aaa2bca3d36d28a663b6ce0b193ae546
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: ba539f0ba74fcff7a4b8cbf2750fec5c34f661c29503de6a591705cb0dcba58f39f2ac7d6427d1e8fb65df4c6bc8ba148f5574dfa26a90b4930e8dec0ec78bb4
|
7
|
+
data.tar.gz: 9ba87507903df09364a7ed84f963bc8652385072eda427e1e1f123598439243449447fc9bb6abcd892d9c117b9ca7ae6e4c20a0fa579355b0c90015c3d464c3b
|
data/.gitignore
ADDED
data/.rspec
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--require spec_helper
|
data/CODE_OF_CONDUCT.md
ADDED
@@ -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, 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 davetron5000 (at) 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 https://www.contributor-covenant.org/version/1/4/code-of-conduct.html
|
72
|
+
|
73
|
+
[homepage]: https://www.contributor-covenant.org
|
74
|
+
|
data/CONTRIBUTING.md
ADDED
@@ -0,0 +1,5 @@
|
|
1
|
+
# Contributing
|
2
|
+
|
3
|
+
* Code changes for style, cleanliness, eleganance, or other aesthetic stuff will not be accepted.
|
4
|
+
* All proposed changes must have a clear problem statement and be based on a real-world scenario. Imagined problems will not be solved.
|
5
|
+
* Tests are appreciated with all pull requests.
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,60 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
confidence-check (1.0.0)
|
5
|
+
|
6
|
+
GEM
|
7
|
+
remote: https://rubygems.org/
|
8
|
+
specs:
|
9
|
+
addressable (2.7.0)
|
10
|
+
public_suffix (>= 2.0.2, < 5.0)
|
11
|
+
capybara (3.35.3)
|
12
|
+
addressable
|
13
|
+
mini_mime (>= 0.1.3)
|
14
|
+
nokogiri (~> 1.8)
|
15
|
+
rack (>= 1.6.0)
|
16
|
+
rack-test (>= 0.6.3)
|
17
|
+
regexp_parser (>= 1.5, < 3.0)
|
18
|
+
xpath (~> 3.2)
|
19
|
+
diff-lcs (1.4.4)
|
20
|
+
mini_mime (1.0.2)
|
21
|
+
mini_portile2 (2.5.0)
|
22
|
+
minitest (5.14.3)
|
23
|
+
nokogiri (1.11.1)
|
24
|
+
mini_portile2 (~> 2.5.0)
|
25
|
+
racc (~> 1.4)
|
26
|
+
public_suffix (4.0.6)
|
27
|
+
racc (1.5.2)
|
28
|
+
rack (2.2.3)
|
29
|
+
rack-test (1.1.0)
|
30
|
+
rack (>= 1.0, < 3)
|
31
|
+
rake (12.3.3)
|
32
|
+
regexp_parser (2.0.3)
|
33
|
+
rspec (3.10.0)
|
34
|
+
rspec-core (~> 3.10.0)
|
35
|
+
rspec-expectations (~> 3.10.0)
|
36
|
+
rspec-mocks (~> 3.10.0)
|
37
|
+
rspec-core (3.10.1)
|
38
|
+
rspec-support (~> 3.10.0)
|
39
|
+
rspec-expectations (3.10.1)
|
40
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
41
|
+
rspec-support (~> 3.10.0)
|
42
|
+
rspec-mocks (3.10.2)
|
43
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
44
|
+
rspec-support (~> 3.10.0)
|
45
|
+
rspec-support (3.10.2)
|
46
|
+
xpath (3.2.0)
|
47
|
+
nokogiri (~> 1.8)
|
48
|
+
|
49
|
+
PLATFORMS
|
50
|
+
ruby
|
51
|
+
|
52
|
+
DEPENDENCIES
|
53
|
+
capybara
|
54
|
+
confidence-check!
|
55
|
+
minitest
|
56
|
+
rake (~> 12.0)
|
57
|
+
rspec
|
58
|
+
|
59
|
+
BUNDLED WITH
|
60
|
+
2.1.4
|
data/LICENSE.md
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
[SOFTWARE NAME] Copyright (YEAR) (COPYRIGHT HOLDER(S)/AUTHOR(S))(“Licensor”)
|
2
|
+
|
3
|
+
Hippocratic License Version Number: 2.1.
|
4
|
+
|
5
|
+
Purpose. The purpose of this License is for the Licensor named above to permit the Licensee (as defined below) broad permission, if consistent with Human Rights Laws and Human Rights Principles (as each is defined below), to use and work with the Software (as defined below) within the full scope of Licensor’s copyright and patent rights, if any, in the Software, while ensuring attribution and protecting the Licensor from liability.
|
6
|
+
|
7
|
+
Permission and Conditions. The Licensor grants permission by this license (“License”), free of charge, to the extent of Licensor’s rights under applicable copyright and patent law, to any person or entity (the “Licensee”) obtaining a copy of this software and associated documentation files (the “Software”), to do everything with the Software that would otherwise infringe (i) the Licensor’s copyright in the Software or (ii) any patent claims to the Software that the Licensor can license or becomes able to license, subject to all of the following terms and conditions:
|
8
|
+
|
9
|
+
* Acceptance. This License is automatically offered to every person and entity subject to its terms and conditions. Licensee accepts this License and agrees to its terms and conditions by taking any action with the Software that, absent this License, would infringe any intellectual property right held by Licensor.
|
10
|
+
|
11
|
+
* Notice. Licensee must ensure that everyone who gets a copy of any part of this Software from Licensee, with or without changes, also receives the License and the above copyright notice (and if included by the Licensor, patent, trademark and attribution notice). Licensee must cause any modified versions of the Software to carry prominent notices stating that Licensee changed the Software. For clarity, although Licensee is free to create modifications of the Software and distribute only the modified portion created by Licensee with additional or different terms, the portion of the Software not modified must be distributed pursuant to this License. If anyone notifies Licensee in writing that Licensee has not complied with this Notice section, Licensee can keep this License by taking all practical steps to comply within 30 days after the notice. If Licensee does not do so, Licensee’s License (and all rights licensed hereunder) shall end immediately.
|
12
|
+
|
13
|
+
* Compliance with Human Rights Principles and Human Rights Laws.
|
14
|
+
|
15
|
+
1. Human Rights Principles.
|
16
|
+
|
17
|
+
(a) Licensee is advised to consult the articles of the United Nations Universal Declaration of Human Rights and the United Nations Global Compact that define recognized principles of international human rights (the “Human Rights Principles”). Licensee shall use the Software in a manner consistent with Human Rights Principles.
|
18
|
+
|
19
|
+
(b) Unless the Licensor and Licensee agree otherwise, any dispute, controversy, or claim arising out of or relating to (i) Section 1(a) regarding Human Rights Principles, including the breach of Section 1(a), termination of this License for breach of the Human Rights Principles, or invalidity of Section 1(a) or (ii) a determination of whether any Law is consistent or in conflict with Human Rights Principles pursuant to Section 2, below, shall be settled by arbitration in accordance with the Hague Rules on Business and Human Rights Arbitration (the “Rules”); provided, however, that Licensee may elect not to participate in such arbitration, in which event this License (and all rights licensed hereunder) shall end immediately. The number of arbitrators shall be one unless the Rules require otherwise.
|
20
|
+
|
21
|
+
Unless both the Licensor and Licensee agree to the contrary: (1) All documents and information concerning the arbitration shall be public and may be disclosed by any party; (2) The repository referred to under Article 43 of the Rules shall make available to the public in a timely manner all documents concerning the arbitration which are communicated to it, including all submissions of the parties, all evidence admitted into the record of the proceedings, all transcripts or other recordings of hearings and all orders, decisions and awards of the arbitral tribunal, subject only to the arbitral tribunal's powers to take such measures as may be necessary to safeguard the integrity of the arbitral process pursuant to Articles 18, 33, 41 and 42 of the Rules; and (3) Article 26(6) of the Rules shall not apply.
|
22
|
+
|
23
|
+
2. Human Rights Laws. The Software shall not be used by any person or entity for any systems, activities, or other uses that violate any Human Rights Laws. “Human Rights Laws” means any applicable laws, regulations, or rules (collectively, “Laws”) that protect human, civil, labor, privacy, political, environmental, security, economic, due process, or similar rights; provided, however, that such Laws are consistent and not in conflict with Human Rights Principles (a dispute over the consistency or a conflict between Laws and Human Rights Principles shall be determined by arbitration as stated above). Where the Human Rights Laws of more than one jurisdiction are applicable or in conflict with respect to the use of the Software, the Human Rights Laws that are most protective of the individuals or groups harmed shall apply.
|
24
|
+
|
25
|
+
3. Indemnity. Licensee shall hold harmless and indemnify Licensor (and any other contributor) against all losses, damages, liabilities, deficiencies, claims, actions, judgments, settlements, interest, awards, penalties, fines, costs, or expenses of whatever kind, including Licensor’s reasonable attorneys’ fees, arising out of or relating to Licensee’s use of the Software in violation of Human Rights Laws or Human Rights Principles.
|
26
|
+
|
27
|
+
* Failure to Comply. Any failure of Licensee to act according to the terms and conditions of this License is both a breach of the License and an infringement of the intellectual property rights of the Licensor (subject to exceptions under Laws, e.g., fair use). In the event of a breach or infringement, the terms and conditions of this License may be enforced by Licensor under the Laws of any jurisdiction to which Licensee is subject. Licensee also agrees that the Licensor may enforce the terms and conditions of this License against Licensee through specific performance (or similar remedy under Laws) to the extent permitted by Laws. For clarity, except in the event of a breach of this License, infringement, or as otherwise stated in this License, Licensor may not terminate this License with Licensee.
|
28
|
+
|
29
|
+
* Enforceability and Interpretation. If any term or provision of this License is determined to be invalid, illegal, or unenforceable by a court of competent jurisdiction, then such invalidity, illegality, or unenforceability shall not affect any other term or provision of this License or invalidate or render unenforceable such term or provision in any other jurisdiction; provided, however, subject to a court modification pursuant to the immediately following sentence, if any term or provision of this License pertaining to Human Rights Laws or Human Rights Principles is deemed invalid, illegal, or unenforceable against Licensee by a court of competent jurisdiction, all rights in the Software granted to Licensee shall be deemed null and void as between Licensor and Licensee. Upon a determination that any term or provision is invalid, illegal, or unenforceable, to the extent permitted by Laws, the court may modify this License to affect the original purpose that the Software be used in compliance with Human Rights Principles and Human Rights Laws as closely as possible. The language in this License shall be interpreted as to its fair meaning and not strictly for or against any party.
|
30
|
+
|
31
|
+
* Disclaimer. TO THE FULL EXTENT ALLOWED BY LAW, THIS SOFTWARE COMES “AS IS,” WITHOUT ANY WARRANTY, EXPRESS OR IMPLIED, AND LICENSOR AND ANY OTHER CONTRIBUTOR SHALL NOT BE LIABLE TO ANYONE FOR ANY DAMAGES OR OTHER LIABILITY ARISING FROM, OUT OF, OR IN CONNECTION WITH THE SOFTWARE OR THIS LICENSE, UNDER ANY KIND OF LEGAL CLAIM.
|
32
|
+
|
33
|
+
This Hippocratic License is an Ethical Source license (https://ethicalsource.dev) and is offered for use by licensors and licensees at their own risk, on an “AS IS” basis, and with no warranties express or implied, to the maximum extent permitted by Laws.
|
34
|
+
|
data/README.md
ADDED
@@ -0,0 +1,190 @@
|
|
1
|
+
# confidence\_check - Get confidence in your test setup
|
2
|
+
|
3
|
+
Sometimes tests have some setup required before you run the test, and sometimes that setup is complicated, and sometimes that
|
4
|
+
setup can break if other parts of the system aren't working. When that happens, you can a test failure that doesn't mean your
|
5
|
+
code is broken, just that some other code is broken.
|
6
|
+
|
7
|
+
```ruby
|
8
|
+
visit "/"
|
9
|
+
click_on "sign_up"
|
10
|
+
|
11
|
+
fill_in :username, with: "davetron5000"
|
12
|
+
expect {
|
13
|
+
click_on "Create an Account"
|
14
|
+
}.to change {
|
15
|
+
Account.count
|
16
|
+
}.by(1)
|
17
|
+
```
|
18
|
+
|
19
|
+
What if the `sign_up` link is broken, but your account registration code is working perfectly? You'll get a test failure on
|
20
|
+
that call to `fill_in`. This is confusing.
|
21
|
+
|
22
|
+
```ruby
|
23
|
+
confidence_check do
|
24
|
+
visit "/"
|
25
|
+
click_on "sign_up"
|
26
|
+
end
|
27
|
+
|
28
|
+
fill_in :username, with: "davetron5000"
|
29
|
+
expect {
|
30
|
+
click_on "Create an Account"
|
31
|
+
}.to change {
|
32
|
+
Account.count
|
33
|
+
}.by(1)
|
34
|
+
```
|
35
|
+
|
36
|
+
Now, if something goes wrong getting to the page, i.e. setting up for your test, you'll get a different error: CONFIDENCE CHECK
|
37
|
+
FAILED.
|
38
|
+
|
39
|
+
This can help tremendously with isolating the root cause of a test failure. Instead of digging into the code you are testing, you can quickly see that some *other* code that is needed just to run a test is broken.
|
40
|
+
|
41
|
+
## Install
|
42
|
+
|
43
|
+
```
|
44
|
+
> gem install confidence-check
|
45
|
+
```
|
46
|
+
|
47
|
+
Or, if using a `Gemfile`:
|
48
|
+
|
49
|
+
```ruby
|
50
|
+
gem "confidence-check"
|
51
|
+
```
|
52
|
+
|
53
|
+
### Setup - RSpec
|
54
|
+
|
55
|
+
1. Include `ConfidenceCheck::ForRSpec` in your test. The most common way is in your `spec_helper.rb`:
|
56
|
+
|
57
|
+
```ruby
|
58
|
+
RSpec.configure do |c|
|
59
|
+
c.include ConfidenceCheck::ForRSpec
|
60
|
+
end
|
61
|
+
```
|
62
|
+
2. You can now call `confidence_check` anywhere you need to assert your test is set up:
|
63
|
+
|
64
|
+
```ruby
|
65
|
+
RSpec.describe Person do
|
66
|
+
include ConfidenceCheck
|
67
|
+
describe "#age" do
|
68
|
+
it "is based on birthdate" do
|
69
|
+
person = create(:person)
|
70
|
+
|
71
|
+
confidence_check do
|
72
|
+
expect(person.birthdate).not_to be_nil
|
73
|
+
end
|
74
|
+
|
75
|
+
expect(person.age).to eq(47)
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
79
|
+
```
|
80
|
+
|
81
|
+
## Setup - Minitest
|
82
|
+
|
83
|
+
1. Include `ConfidenceCheck::ForMinitest` in your test. For Rails, you'd include this in `ActiveSupport::TestCase`:
|
84
|
+
|
85
|
+
```ruby
|
86
|
+
# test/test_helper.rb
|
87
|
+
|
88
|
+
class ActiveSupport::TestCase
|
89
|
+
include ConfidenceCheck::ForMinitest
|
90
|
+
|
91
|
+
# ...
|
92
|
+
end
|
93
|
+
```
|
94
|
+
2. You can now call `confidence_check` anywhere you need to assert your test is set up:
|
95
|
+
|
96
|
+
```ruby
|
97
|
+
class PersonTest < MiniTest::Test
|
98
|
+
include ConfidenceCheck
|
99
|
+
def test_age
|
100
|
+
person = create(:person)
|
101
|
+
|
102
|
+
confidence_check do
|
103
|
+
refute_nil person.birthdate
|
104
|
+
end
|
105
|
+
|
106
|
+
assert_equal 47,person.age
|
107
|
+
end
|
108
|
+
end
|
109
|
+
```
|
110
|
+
|
111
|
+
### Setup - Custom
|
112
|
+
|
113
|
+
1. The module `ConfidenceCheck::CheckMethod` makes a call to `exception_klasses`, which returns an array of exception classes you want to rescue inside a `confidence_check` call. You'll need to implement this yourself:
|
114
|
+
|
115
|
+
```ruby
|
116
|
+
module MyCustomConfidenceCheck
|
117
|
+
include ConfidenceCheck::CheckMethod
|
118
|
+
def exception_klasses
|
119
|
+
[ MyCustomError ]
|
120
|
+
end
|
121
|
+
end
|
122
|
+
```
|
123
|
+
2. Note that you can include any of the other modules as a base. For example, if you want to use RSpec but add your own
|
124
|
+
additional method:
|
125
|
+
```ruby
|
126
|
+
module MyCustomConfidenceCheck
|
127
|
+
include ConfidenceCheck::ForRSpec
|
128
|
+
include ConfidenceCheck::CheckMethod
|
129
|
+
def exception_klasses
|
130
|
+
super + [ MyCustomError ]
|
131
|
+
end
|
132
|
+
end
|
133
|
+
```
|
134
|
+
3. Now, you need to include this module in your tests. HOw to do this dependson how you are writing tests, but hopefully it's
|
135
|
+
as simple as `include MyCustomConfidenceCheck`
|
136
|
+
|
137
|
+
### Setup - with Capybara
|
138
|
+
|
139
|
+
Capybara raises several exceptions if navigation or page manipulation fails. These are almost always the types of failures
|
140
|
+
a confidence check should notify you about because they usually mean a page or pages aren't even working enough for you to
|
141
|
+
execute a test.
|
142
|
+
|
143
|
+
If you use the `*WithCapybara` versions of the modules, you can wrap your Capybara navigation commands in a `confidence_check`:
|
144
|
+
|
145
|
+
#### RSpec
|
146
|
+
|
147
|
+
```ruby
|
148
|
+
RSpec.configure do |c|
|
149
|
+
c.include ConfidenceCheck::ForRSpec::WithCapybara
|
150
|
+
end
|
151
|
+
```
|
152
|
+
|
153
|
+
#### Minitest
|
154
|
+
|
155
|
+
```ruby
|
156
|
+
# test/test_helper.rb
|
157
|
+
|
158
|
+
class ActiveSupport::TestCase
|
159
|
+
include ConfidenceCheck::ForMinitest::WithCapybara
|
160
|
+
|
161
|
+
# ...
|
162
|
+
end
|
163
|
+
```
|
164
|
+
|
165
|
+
#### Custom
|
166
|
+
|
167
|
+
```ruby
|
168
|
+
module MyCustomConfidenceCheck
|
169
|
+
include ConfidenceCheck::CheckMethod
|
170
|
+
def exception_klasses
|
171
|
+
[ MyCustomError, Capybara::CapybaraError ]
|
172
|
+
end
|
173
|
+
end
|
174
|
+
|
175
|
+
# OR, to e.g. re-use RSpec's
|
176
|
+
|
177
|
+
module MyCustomConfidenceCheck
|
178
|
+
include ConfidenceCheck::ForRSpec::WithCapybara
|
179
|
+
include ConfidenceCheck::CheckMethod
|
180
|
+
def exception_klasses
|
181
|
+
super + [ MyCustomError ]
|
182
|
+
end
|
183
|
+
end
|
184
|
+
```
|
185
|
+
|
186
|
+
## Developing
|
187
|
+
|
188
|
+
* Set up with `bin/setup`
|
189
|
+
* Run tests with `bin/rspec` or `bin/rake`
|
190
|
+
|
data/Rakefile
ADDED
data/bin/console
ADDED
data/bin/rake
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
#
|
5
|
+
# This file was generated by Bundler.
|
6
|
+
#
|
7
|
+
# The application 'rake' is installed as part of a gem, and
|
8
|
+
# this file is here to facilitate running it.
|
9
|
+
#
|
10
|
+
|
11
|
+
require "pathname"
|
12
|
+
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
|
13
|
+
Pathname.new(__FILE__).realpath)
|
14
|
+
|
15
|
+
bundle_binstub = File.expand_path("../bundle", __FILE__)
|
16
|
+
|
17
|
+
if File.file?(bundle_binstub)
|
18
|
+
if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
|
19
|
+
load(bundle_binstub)
|
20
|
+
else
|
21
|
+
abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
|
22
|
+
Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
require "rubygems"
|
27
|
+
require "bundler/setup"
|
28
|
+
|
29
|
+
load Gem.bin_path("rake", "rake")
|
data/bin/rspec
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
#
|
5
|
+
# This file was generated by Bundler.
|
6
|
+
#
|
7
|
+
# The application 'rspec' is installed as part of a gem, and
|
8
|
+
# this file is here to facilitate running it.
|
9
|
+
#
|
10
|
+
|
11
|
+
require "pathname"
|
12
|
+
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
|
13
|
+
Pathname.new(__FILE__).realpath)
|
14
|
+
|
15
|
+
bundle_binstub = File.expand_path("../bundle", __FILE__)
|
16
|
+
|
17
|
+
if File.file?(bundle_binstub)
|
18
|
+
if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
|
19
|
+
load(bundle_binstub)
|
20
|
+
else
|
21
|
+
abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
|
22
|
+
Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
require "rubygems"
|
27
|
+
require "bundler/setup"
|
28
|
+
|
29
|
+
load Gem.bin_path("rspec-core", "rspec")
|
data/bin/setup
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
require_relative "lib/confidence-check"
|
2
|
+
|
3
|
+
Gem::Specification.new do |spec|
|
4
|
+
spec.name = "confidence-check"
|
5
|
+
spec.version = ConfidenceCheck::VERSION
|
6
|
+
spec.authors = ["Dave Copeland"]
|
7
|
+
spec.email = ["davec@naildrivin5.com"]
|
8
|
+
|
9
|
+
spec.summary = %q{Assert that the conditions of your test are correct before testing}
|
10
|
+
spec.homepage = "https://sustainable-rails.com"
|
11
|
+
spec.required_ruby_version = Gem::Requirement.new(">= 2.3.0")
|
12
|
+
|
13
|
+
spec.metadata["homepage_uri"] = spec.homepage
|
14
|
+
spec.metadata["source_code_uri"] = "https://github.com/sustainable-rails/confidence-check"
|
15
|
+
spec.metadata["changelog_uri"] = "https://github.com/sustainable-rails/confidence-check/releases"
|
16
|
+
|
17
|
+
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
18
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
19
|
+
end
|
20
|
+
spec.bindir = "exe"
|
21
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
22
|
+
spec.require_paths = ["lib"]
|
23
|
+
|
24
|
+
spec.add_development_dependency("rspec")
|
25
|
+
spec.add_development_dependency("minitest")
|
26
|
+
spec.add_development_dependency("capybara")
|
27
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require_relative "confidence_check_failed"
|
2
|
+
|
3
|
+
module ConfidenceCheck
|
4
|
+
module CheckMethod
|
5
|
+
def confidence_check(context=nil, &block)
|
6
|
+
if block.nil?
|
7
|
+
raise "#confidence_check requires a block"
|
8
|
+
end
|
9
|
+
block.()
|
10
|
+
rescue Exception => ex
|
11
|
+
$stdout.puts context.inspect if context
|
12
|
+
if exception_klasses.any? {|_| ex.kind_of?(_) }
|
13
|
+
raise ConfidenceCheckedFailed.new(ex)
|
14
|
+
else
|
15
|
+
raise
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require "forwardable"
|
2
|
+
module ConfidenceCheck
|
3
|
+
class ConfidenceCheckedFailed < Exception
|
4
|
+
extend Forwardable
|
5
|
+
def initialize(exception)
|
6
|
+
super("CONFIDENCE CHECK FAILED: #{exception.message}")
|
7
|
+
@exception = exception
|
8
|
+
end
|
9
|
+
|
10
|
+
def_delegators :@exception, :backtrace, :cause
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require_relative "check_method"
|
2
|
+
|
3
|
+
module ConfidenceCheck
|
4
|
+
module ForMinitest
|
5
|
+
include ConfidenceCheck::CheckMethod
|
6
|
+
def exception_klasses
|
7
|
+
[::Minitest::Assertion]
|
8
|
+
end
|
9
|
+
|
10
|
+
module WithCapybara
|
11
|
+
include ConfidenceCheck::CheckMethod
|
12
|
+
include ConfidenceCheck::ForMinitest
|
13
|
+
def exception_klasses
|
14
|
+
super + [ ::Capybara::CapybaraError ]
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require_relative "check_method"
|
2
|
+
|
3
|
+
module ConfidenceCheck
|
4
|
+
module ForRSpec
|
5
|
+
include ConfidenceCheck::CheckMethod
|
6
|
+
def exception_klasses
|
7
|
+
[::RSpec::Expectations::ExpectationNotMetError ]
|
8
|
+
end
|
9
|
+
|
10
|
+
module WithCapybara
|
11
|
+
include ConfidenceCheck::CheckMethod
|
12
|
+
include ConfidenceCheck::ForRSpec
|
13
|
+
def exception_klasses
|
14
|
+
super + [ ::Capybara::CapybaraError ]
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
metadata
ADDED
@@ -0,0 +1,106 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: confidence-check
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Dave Copeland
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2021-02-09 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: :development
|
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: minitest
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
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: capybara
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
description:
|
56
|
+
email:
|
57
|
+
- davec@naildrivin5.com
|
58
|
+
executables: []
|
59
|
+
extensions: []
|
60
|
+
extra_rdoc_files: []
|
61
|
+
files:
|
62
|
+
- ".gitignore"
|
63
|
+
- ".rspec"
|
64
|
+
- CODE_OF_CONDUCT.md
|
65
|
+
- CONTRIBUTING.md
|
66
|
+
- Gemfile
|
67
|
+
- Gemfile.lock
|
68
|
+
- LICENSE.md
|
69
|
+
- README.md
|
70
|
+
- Rakefile
|
71
|
+
- bin/console
|
72
|
+
- bin/rake
|
73
|
+
- bin/rspec
|
74
|
+
- bin/setup
|
75
|
+
- confidence-check.gemspec
|
76
|
+
- lib/confidence-check.rb
|
77
|
+
- lib/confidence_check/check_method.rb
|
78
|
+
- lib/confidence_check/confidence_check_failed.rb
|
79
|
+
- lib/confidence_check/for_minitest.rb
|
80
|
+
- lib/confidence_check/for_rspec.rb
|
81
|
+
homepage: https://sustainable-rails.com
|
82
|
+
licenses: []
|
83
|
+
metadata:
|
84
|
+
homepage_uri: https://sustainable-rails.com
|
85
|
+
source_code_uri: https://github.com/sustainable-rails/confidence-check
|
86
|
+
changelog_uri: https://github.com/sustainable-rails/confidence-check/releases
|
87
|
+
post_install_message:
|
88
|
+
rdoc_options: []
|
89
|
+
require_paths:
|
90
|
+
- lib
|
91
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
92
|
+
requirements:
|
93
|
+
- - ">="
|
94
|
+
- !ruby/object:Gem::Version
|
95
|
+
version: 2.3.0
|
96
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
97
|
+
requirements:
|
98
|
+
- - ">="
|
99
|
+
- !ruby/object:Gem::Version
|
100
|
+
version: '0'
|
101
|
+
requirements: []
|
102
|
+
rubygems_version: 3.1.2
|
103
|
+
signing_key:
|
104
|
+
specification_version: 4
|
105
|
+
summary: Assert that the conditions of your test are correct before testing
|
106
|
+
test_files: []
|