What is the state of testing in Sinatra?

1 view
Skip to first unread message

Christer Nilsson

unread,
Jul 5, 2009, 11:16:37 AM7/5/09
to sinatrarb
I'm a bit confused over how to test my Sinatra app, as matters seem to
evolve rather quickly.

I would like to use the rspec style and also be able to use these
constructs in my testing code:

1) get '/'

2) haml

3) calling methods defined in the helper block


Currently I'm using my own testing framework based on defining

get '/test' do
... asserts goes here, returning results in a web page
end


This approach solves 2) and 3), but fails on 1)

Using rspec, 1) works, but methods in 2) and 3) are not recognized.


Please, just give me a proper url to a testable app, and I will be
fine!

/Christer

Damian Janowski

unread,
Jul 5, 2009, 1:06:51 PM7/5/09
to sina...@googlegroups.com

Have you looked at http://www.sinatrarb.com/testing.html?

Personally I like to do black-box testing as much as possible, so I
prefer not to test my views in isolation. And while I test my helpers
sometimes, I think of them as an implementation detail of the view.

Let me know if you need more examples, I could pastie some later.

D.

Christer Nilsson

unread,
Jul 5, 2009, 2:35:23 PM7/5/09
to sina...@googlegroups.com
 
 
All the examples are calling "get '/'" only. (I understand any url can be tested this way.)
 
I haven't thought of using black box testing only, as I prefer to test on all levels, as the test result pinpoints me to the troubled method directly. And the tests are documenting the inside of the program too, which is nice for fellow maintenance developers.
 
Maybe I should use two different testing frameworks,
one for blackbox testing and a second for inside testing.
 
But, it would be nice to use just one framework, of course.
 
Christer
Reply all
Reply to author
Forward
0 new messages