How to Test Helpers Blocks in Sinatra, Using Rspec

How can I test helpers blocks in Sinatra, using Rspec?

maybe this can help you some way http://japhr.blogspot.com/2009/03/sinatra-innards-deletgator.html

Test a Sinatra app with RSpec - structure of tests

You could make just three folders: controllers (with, for example, posts_spec.rb), models (that contains post_spec.rb where testing the methods you have implemented in your model) and helpers (let's say utils_spec.rb).

Take a look at Testing Sinatra with Rack::Test and some repositories on GitHub to have a better idea on how you should organize your code.

How do I configure RSpec with Sinatra to dynamically determine which Sinatra app is running before my test suite runs?

Define a different helper module for each sinatra app you want to test, each of which should define its own app method that returns the corresponding app. Then you can simply include MySinatraAppHelper in the appropriate example groups where you want to test the the given app.

You can also use rspec metadata to have the module included in example groups automatically.



Related Topics



Leave a reply



Submit