CSpec Rails
We are starting to get somewhere! This gem assumes that the user has install nodejs, npm and cspec. It will then provide you with a rake task called “cspec” that runs the cspec tool like so:
cspec -jquery -include app/assets/javascripts spec/*/_spec.coffee
Note: The */ is expanded by Rake, not by cspec.
We still have a long way to go but this is already pretty promosing.
Vision
This is an implementation of CSpec (github.com/hammerdr/cspec) that runs in the context of Rails applications.
The goal is to produce something that allows me to do:
$ rake cspec
.…..
6 expectations passed, 0 failed
for the files
app/assets/javascripts/*.coffee
class Post
addComment: (comment) ->
@comments.push comment
spec/assets/javascripts/*_spec.coffee
describe Post ->
it 'should add comment' ->
post = new Post()
comment = new Comment()
post.addComment comment
post.comments.length.should equal 1