I accepted an application that has some testing coverage, but most tests are of mixed quality. Most applications work against the JSON api. I was going to write request specifications, but authentication and sending POST with authentication data were not trivial. For testing JSON api would be more appropriate controller specifications?
For instance,
match 'api/login-mobile' => 'api#login_mobile', :as => :login_mobile, :defaults => {:format => 'json' }
It would seem trivial, but integration with capybara would be required. In addition, capybara does not send session data natively and will require
page.driver.post .....
I get integration tests to test user interface interaction, but this seems like a really bad model for testing JSON api. Am I missing something? Or is there a tutorial for conducting integration / requeset tests? Now I am considering a discourse, and almost all of their tests are controllers .... If the integration / query specifications were bee knees, why would they make this decision?
thanks in advance
source share