pangloss/vim-javascript — pull request #178 by gabrielelana (2014-03-24 08:45:46+00:00)
Title: Syntax pecs

This is a rudimental way to test that a change in the file don't cause
some unwanted regression.

This is based on the *Golden Master* approach:
- When you run the tests for the first time, it generates an html file
for each file in spec/fixtures directory, those files are the html
export (:help :TOhtml) of the current file highlighted with the syntax
found in syntax/javascript.vim
- Those html files are the *Golden Master* aka the known state of the
current syntax that is supposed to be good
- Next time you run the tests the produced html file will be compared to
the *Golden Master* of the same file, if the diff is not empty then
the test fails
- When you change something in the syntax you could test the effects of
this change running the tests and inspecting the diffs
- When you think that the current status is good then you need to
regenerate the *Golden Master*

Right now I have included only one file in the fixtures (the latest
version of jquery) as an example, ideally we should have small files
with specific examples, more the example is focused and more the
diff will be helpful. The best way is to build those fixtures
incrementally feature by feature

INSTALLATION AND USAGE: Install Ruby 2.0 and Bundler, run `bundle
install` in the root directory, run `rspec` to run all the tests, run
`GENERATE_GOLDEN_MASTER=1 rspec` to regenerate the *Golden Master* files

DOCUMENTATION: If you might like this I would add proper development
documentation (in CONTRIBUTING.md?)

ONE LAST THING: in a local .vimrc file I've added some mappings that I
found very useful
- `r` (short for reload) will reload the plugin in the current
buffer for rapid feedback when you change something
- `h` (short for help) will show the syntax attributes of the
element under the cursor
- `t` (short for trace) will enter in a sub mode that shows the
syntax attributes of the element under the cursor when you move
(warning: could be pretty slow but it's really helpful sometimes)