Giter Site home page Giter Site logo

learn-vimscript-the-tdd-way's Introduction

Learn Vimscript the TDD way!

Setup

The test runner for this Vimscript Dojo depends on ruby tooling. You'll need to have each of the following installed on your system:

With those dependencies satisfied, run these steps to set up this Vimscript Dojo:

  • check out this repository: git clone [email protected]:VimLondon/learn-vimscript-the-tdd-way.git
  • cd learn-vimscript-the-tdd-way
  • install dependencies: bundle install
  • run the tests: bundle exec rake

You should have a passing test suite.

Also, it's advised that you install the vspec plugin for Vim, which adds indentation support for vspec files, and syntax highlighting for keywords describe, it, before, after, end.

Working through the exercises

The exercises are listed in the t directory. Open them up in Vim:

vim t/*

hint: that populates the argument list, so you can advance/reverse through the lessons by running :next/:prev.

You should start off in a file called t/001_about_true_and_false.vim. The tests should all pass at first, because the solutions are filled in. To conceal the answers, run this command:

:source conceal_solutions.vim

That script performs two changes to each example. It:

  • removes the solutions, and
  • marks each test as TODO

For example, this test:

it 'number 1 is treated as true'
  Expect ___('truthy') ==# TruthValue(1)
end

is converted to this:

it 'number 1 is treated as true'
  TODO
  Expect ___ ==# TruthValue(1)
end

The TODO statement prevents the test from running. Delete that line, then run the test suite and you should get your first error message:

t/001_about_true_and_false.vim ........ 1/?
not ok 1 - About True and False number 1 is treated as true
# function <SNR>1_main..vspec#test..5, line 1
# Vim(call):E121: Undefined variable: ___
t/001_about_true_and_false.vim ........ Failed 1/6 subtests

The relevant bit is: Undefined variable: ___. To fix it, change the ___ placeholder to the correct answer, in this case:

it 'number 1 is treated as true'
  Expect 'truthy' ==# TruthValue(1)
end

Run the tests again and they should pass.

Move on to the next exercise: delete the line with TODO, then change the ___ placeholder to the correct answer.

learn-vimscript-the-tdd-way's People

Contributors

krisajenkins avatar kynan avatar nelstrom avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

learn-vimscript-the-tdd-way's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.