Trying to understand Capybara and mock data
I've got a Twitter app. All our users come directly from Twitter. This means, you cannot do any significant interactions with the app unless you are logged on, from Twitter. Our app caches (saves the user's Twitter data in the db).
It is possible to integrate Capybara with Omniauth. For example to test OAuth integration with Twitter. I've read a few articles online about this. However, the tricky part is getting it to work with Devise + Omniaut开发者_JS百科h (I've only seen a scarce number of articles, have tried them to no avail).
Second, I've also looked into testing file uploads to S3, which make it quite difficult, since we are uploading directly to S3 using JS (Uploadify) and then instructing Carrierwave to grab the file.
A few have mentioned that it is best to provide mock data instead of trying to test OAuth directly. I guess, what they are trying to suggest, is to seed the test database with mock Twitter data. That way, I can test the user directly in the app. Without having to worry about how to get testing with Rspec + Capybara + Devise + Omniauth + Twitter to work.
I could do the same for file uploads as well. Does this make sense? Is this a sensible approach?
By seeding the database with the appropriate data beforehand, you avoid dealing with all the integration testing issues of Omniauth etc. As the library itself is already tested anyhow, you also avoid and unnecessary overhead.
So yes - seed your db with the data right away.
OmniAuth has helpers for integration testing.. i wrote a post about that, it may help you..
精彩评论