mirror of
https://github.com/jbranchaud/til
synced 2026-01-15 13:08:02 +00:00
Compare commits
4 Commits
b7a405a4fe
...
5f6d236be4
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5f6d236be4 | ||
|
|
df3492d4ef | ||
|
|
bd49b31bb0 | ||
|
|
295fe153ad |
@@ -10,7 +10,7 @@ pairing with smart people at Hashrocket.
|
||||
|
||||
For a steady stream of TILs, [sign up for my newsletter](https://crafty-builder-6996.ck.page/e169c61186).
|
||||
|
||||
_1436 TILs and counting..._
|
||||
_1438 TILs and counting..._
|
||||
|
||||
---
|
||||
|
||||
@@ -1101,6 +1101,7 @@ _1436 TILs and counting..._
|
||||
|
||||
- [Avoid Accidentally Disabling Pry](rspec/avoid-accidentally-disabling-pry.md)
|
||||
- [Check Specific Arguments To Received Method](rspec/check-specific-arguments-to-received-method.md)
|
||||
- [Configure Tests To Run In Random Order](rspec/configure-tests-to-run-in-random-order.md)
|
||||
- [Find Minimal Set Of Tests Causing A Flicker](rspec/find-minimal-set-of-tests-causing-a-flicker.md)
|
||||
- [Format Test Results As A JSON File](rspec/format-test-results-as-a-json-file.md)
|
||||
- [Run Tests With Documentation Formatting](rspec/run-tests-with-documentation-formatting.md)
|
||||
@@ -1180,6 +1181,7 @@ _1436 TILs and counting..._
|
||||
- [Map With Index Over An Array](ruby/map-with-index-over-an-array.md)
|
||||
- [Mock Method Chain Calls With RSpec](ruby/mock-method-chain-calls-with-rspec.md)
|
||||
- [Mocking Requests With Partial URIs Using Regex](ruby/mocking-requests-with-partial-uris-using-regex.md)
|
||||
- [Multi-Line Comments](ruby/multi-line-comments.md)
|
||||
- [Named Regex Captures Are Assigned To Variables](ruby/named-regex-captures-are-assigned-to-variables.md)
|
||||
- [Navigate Back In The Browser With Capybara](ruby/navigate-back-in-the-browser-with-capybara.md)
|
||||
- [Next And Previous Floats](ruby/next-and-previous-floats.md)
|
||||
|
||||
@@ -5,6 +5,8 @@ an array-like object with all of the arguments to the function. Even if not
|
||||
all of the arguments are referenced in the function signature, they can
|
||||
still be accessed via the `arguments` object.
|
||||
|
||||
> For ES6+ compatibility, the `spread` operator used via [rest parameters](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/rest_parameters) is preferred over the `arugments` object when accessing an abritrary number of function arguments.
|
||||
|
||||
```javascript
|
||||
function argTest(one) {
|
||||
console.log(one);
|
||||
|
||||
33
rspec/configure-tests-to-run-in-random-order.md
Normal file
33
rspec/configure-tests-to-run-in-random-order.md
Normal file
@@ -0,0 +1,33 @@
|
||||
# Configure Tests To Run In Random Order
|
||||
|
||||
By default, an RSpec test suite is going to run in a predictable, sequential
|
||||
order, every time.
|
||||
|
||||
When testing the parts of a complex Rails app that have all kinds of test data
|
||||
that needs to be set up, I prefer to have my tests always run in a random
|
||||
(repeatable with a seed) order. This way I'm more likely to catch sooner,
|
||||
rather than later, bugs that are hidden by passing tests due to test data setup
|
||||
that happens to work in a specific order.
|
||||
|
||||
RSpec can be configured to run tests in a random, seedable order in the
|
||||
`spec_helper.rb` file.
|
||||
|
||||
```ruby
|
||||
RSpec.configure do |config|
|
||||
config.order = :random
|
||||
end
|
||||
```
|
||||
|
||||
Whenever you run your test suite, the first thing you'll see is a message like
|
||||
this:
|
||||
|
||||
```
|
||||
Randomized with seed 7011
|
||||
```
|
||||
|
||||
That seed number can be used to re-run the suite in a repeatable order when you
|
||||
need to do so to track down an order-dependent failing test.
|
||||
|
||||
```bash
|
||||
$ be rspec --seed 7011
|
||||
```
|
||||
46
ruby/multi-line-comments.md
Normal file
46
ruby/multi-line-comments.md
Normal file
@@ -0,0 +1,46 @@
|
||||
# Multi-Line Comments
|
||||
|
||||
Ruby has an obscure syntax for creating multi-line comments.
|
||||
|
||||
In many languages, there is a multi-line comment syntax that looks something
|
||||
like this:
|
||||
|
||||
```javascript
|
||||
/*
|
||||
* multi-line comment in javascript
|
||||
*/
|
||||
```
|
||||
|
||||
This gets used often in those languages.
|
||||
|
||||
In Ruby, the multi-line comment syntax is not something we see very often. It
|
||||
is a departure from the single-line comment syntax and it also requires no
|
||||
indentation.
|
||||
|
||||
```ruby
|
||||
RSpec.configure do |config|
|
||||
config.order = :random
|
||||
|
||||
# The settings below are suggested to provide a good initial experience
|
||||
# with RSpec, but feel free to customize to your heart's content.
|
||||
=begin
|
||||
# These two settings work together to allow you to limit a spec run
|
||||
# to individual examples or groups you care about by tagging them with
|
||||
# `:focus` metadata. When nothing is tagged with `:focus`, all examples
|
||||
# get run.
|
||||
config.filter_run :focus
|
||||
config.run_all_when_everything_filtered = true
|
||||
|
||||
# ...
|
||||
|
||||
=end
|
||||
end
|
||||
```
|
||||
|
||||
Using the `=begin` and `=end` syntax (no indentation), we make everything
|
||||
inbetween into a comment.
|
||||
|
||||
Though we don't see this too often, I did pull this example directly from the
|
||||
`spec_helper.rb` file that RSpec generates.
|
||||
|
||||
[source](https://docs.ruby-lang.org/en/master/syntax/comments_rdoc.html)
|
||||
Reference in New Issue
Block a user