-
-
Notifications
You must be signed in to change notification settings - Fork 766
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Integration specs appear to be broken in RSpec 2 #62
Comments
In rspec-2, integration specs live in spec/requests. Is that where you have them? If not, please try changing the directory name and let me know if that solves the problem. As for Cucumber, I use it myself, but I don't have enough context to make a recommendation for your book. |
They're in spec/requests. In fact, they aren't all broken; I have several passing tests that don't require maintaining state. For example, I have integration specs like
that work just fine. The problem lies in the (non-)persistence of data in the test database between requests. |
I figured out the problem. The issue was that I had set Unfortunately, setting By the way, the workaround I came up with is to force-load the application files on each run:
|
Thanks for posting this info. |
You're welcome. And thanks for the great work on RSpec. In the acknowledgments to the Rails Tutorial book, I express my gratitude to all the Rubyists who have taught and inspired me, and you are one of them. |
@mhartl: Thanks for your solution, it got me digging. What you proposed works, but there's a flaw: If you remove a method from a class it won't be removed on reloading. I've found a different solution that works in that case too:
|
You might be interested in http://github.com/timcharper/spork/issues#issue/37. |
Thanks. Yes, that is interesting. With respect to the flaw mentioned by @MSch, I'll give the new solution a try. Having to restart the Spork server on method removal isn't too bad, though, since that's not too common a case. |
@MSch: I tried to implement your workaround, but it failed with the error |
To get this to work on Rails 3 Beta 4 remove this line from my hack above: |
doesn't work with rails3 rc |
@gudelk - what are you seeing? |
Sorry, my fault. I had some other issues that caused problems. |
Is this solution still working for Rails 3.0 final? I got the code below in my
|
Nothing has changed in rspec that should impact this. With spork, I always put everything in the file other in one of the two spork blocks. |
any news on this issue? I'm on rails-3.0.0 and spork doesn't seem to reload any classes, I tried all hacks mentioned here. |
knoopx - check the spork tracker |
I'm writing the Ruby on Rails Tutorial book, and the Rails 2.3.8 version of the book uses RSpec integration specs for integration testing. My hope for the Rails 3.0 version is to do the same, but integration testing appears to be broken in RSpec 2. For example, consider this test to check that a user can successfully sign in and out:
As described here, this exact code works fine with Rails 2.3.8/RSpec 1.3, but it breaks in Rails 3/RSpec 2. Close examination reveals that the user gets created in the
before(:each)
block, and exists in the database immediately before the call tovisit signin_path
, but is no longer in the database after the call tovisit signin_path
. As a result, the form submission (click_button
) attempts to sign in a nonexistent user, which of course fails.I've certainly noticed that Cucumber has gotten a lot of traction in the Rails world, and it seem less likely to break going forward. Although I prefer the pure-Ruby approach of integration specs, I've considered ditching them and converting everything over to Cucumber for the Rails 3 tutorial. Please let me know if you think that's a good idea.
The text was updated successfully, but these errors were encountered: