comment-spec

Comment driven spec builder
0.2.2 released

comment-spec.cr Build Status

Comment driven spec builder for Crystal.

  • This is a spec string generator.
  • This is not a kind of spec tools.
  • crystal: 0.20.3

Installation

Add this to your application's shard.yml:

dependencies:
  comment-spec:
    github: maiha/comment-spec.cr
    version: 0.2.2

Usage

require "comment-spec"

CommentSpec.parse "1 + 2 # => 3"                   # => "( 1 + 2 ).should eq( 3 )"
CommentSpec.parse "value # => 2016-03-31 12:36:21" # => "( value ).should eq( Time.parse(\"2016-03-31 12:36:21\", \"%F %T\") )"
CommentSpec.parse "v[10] # raises IndexError"      # => "expect_raises(IndexError) { v[10] }"
CommentSpec.parse "value # => #<XXX>"              # => "( value ).class.to_s.should eq( \"XXX\" )"

Converting Rules

Restrictions

This library is line based and roughly parses code by split("#").

Line based

  ...
end # => "foo"

will generate following spec and fail

( end ).should eq( "foo" )

Roughly

foo "a # => b"

will generate following spec and fail

( foo "a ).should eq( b )

Experimental

Parser strictly parses code by using Crystal::Lexer.

CommentSpec::Parser.parse("foo \"a # => b\"")

generates

foo "a # => b"

Development

make spec

Roadmap

0.3.0

  • [ ] use Crystal::Lexer

Contributing

  1. Fork it ( https://github.com/maiha/comment-spec.cr/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request

Contributors

  • maiha maiha - creator, maintainer
comment-spec:
  github: maiha/comment-spec.cr
  version: ~> 0.2.2
License MIT
Crystal 0.20.3

Authors

Dependencies 0

Development Dependencies 0

Dependents 1

Last synced .
search fire star recently