Skip to content

Commit

Permalink
Merge pull request #15 from zombocom/schneems/readme-too
Browse files Browse the repository at this point in the history
Rspec instructions in the README
  • Loading branch information
schneems authored Nov 18, 2020
2 parents b9ef6da + eea6d05 commit 6cfd32b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ What if I told you, that there was a library that helped find your missing `def`

How much would you pay for such a library? A million, a billion, a trillion? Well friends, today is your lucky day because you can use this library today for free!

## Installation
## Installation in your codebase

To automatically search syntax errors when they happen, add this to your Gemfile:

Expand All @@ -50,6 +50,16 @@ If your application is not calling `Bundler.require` then you must manually add
require "syntax_search/auto"
```

If you're using rspec add this to your `.rspec` file:

```
--require syntax_search/auto
```

> This is needed because people can execute a single test file via `bundle exec rspec path/to/file_spec.rb` and if that file has a syntax error, it won't load `spec_helper.rb` to trigger any requires.
## Install the CLI

To get the CLI and manually search for syntax errors, install the gem:

$ gem install syntax_search
Expand All @@ -73,6 +83,10 @@ We know that source code that does not contain a syntax error can be parsed. We

Since there can be multiple syntax errors in a document it's not good enough to check individual code blocks, we've got to check multiple at the same time. We will keep creating and adding new blocks to our search until we detect that our "frontier" (which contains all of our blocks) contains the syntax error. After this, we can stop our search and instead focus on filtering to find the smallest subset of blocks that contain the syntax error.

Here's an example:

![](assets/syntax_search.gif)

## How is source code broken up into smaller blocks?

By definition source code with a syntax error in it cannot be parsed, so we have to guess how to chunk up the file into smaller pieces. Once we've split up the file we can safely rule out or zoom into a specific piece of code to determine the location of the syntax error. This libary uses indentation and empty lines to make guesses about what might be a "block" of code. Once we've got a chunk of code, we can test it.
Expand Down
Binary file added assets/syntax_search.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 6cfd32b

Please sign in to comment.