I am trying to get an overall perspective. So after watching the first two weeks of the TDD workshop, I looked at Ben Orenstein’s “Getting the TDD Ball Rolling”. His first test is to create a request spec… same thing as I saw in a Railscast that is about 2 years old. In the
TDD workshop OTOH, the first is to create an “integration” directory and manually create a spec. I saw some comment that capybara is no longer supported as of Capybara 2.0.0. So perhaps this is a change.
Can someone give me some perspective here? Are we no long using requests? Should we start with spec requests or integration tests? Also what about the usefulness of generated spec?
As I recall, prior to RSpec 2, capybara specs went into the spec/integration or the spec/requests directory. With Rspec 2+, and capybara 2+, those now go in the spec/features directory.and capybara works just fine there.
During the transition it WAS all very confusing, and if you watch old workshops, you’ll see the old behavior and will have to translate it.
Bottom line: get the latest versions of rspec & capybara and put all your capybara-type stuff in spec/features and you should be good to go.
Jes, Thanks for clarifying. I had seen comments like that on the web but wanted to confirm.
Perhaps you could comment on Minitest. I gather that is the standard for unit tests in Rails 4. Just the other week, one lead developer was commenting how they were going to Minitest over Spec. The reason being was that Spec was so robust that it could be hard to trace.
I have played with minitest. I see that there are apparently two versions of gems these days. One is minitest-rails. The other is minitest-spec-rails. One apparent difference is that you must work a bit harder to configure the test-helper for minitest-rails to setup the environment for the different types of tests. It seems that minitest-spec-rails tries to use the built-in Rails features for setting up test environment.
Any comments, recommendations or experience is most welcome.
I’ve never used MiniTest, Ray, so cannot comment (I think it was made the standard around Rails 3, not just Rails 4?). MiniTest is still, I think, the “original” test approach using assert… Frankly I like RSpec better and have most of my experience there so I’m sticking with that.
Jes, That makes sense. Minitest does have the option for spec like syntax. I am not sure the specific issues they had with rspec, but it had to do with a very complex test that in itself was hard to debug. For their latest versions, they went to Minitest. It seems to a minority approach.
My experience playing with Minitest is that the guides are not as good. A particular issue is that like rspec and Capybara, it has been a moving target.