jstorimer / spin

Spin speeds up your Rails testing workflow by preloading your Rails environment.

Home Page:http://jstorimer.github.com/spin/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

View specs failing with spin (rails 3.2.1)

namxam opened this issue · comments

I have a really weird spin behavior. When running a view spec with rspec spec/views/edit.html.erb_spec.rb all examples pass. But when starting a spin server and pushing the same spec to spin, all examples fail.

I really do not know where to start investigating, but it would be great if someone could give me a hint.

Is it possible to see the code that you are running? And possibly get a copy or can you let us know any error messages that you see.

Error messages would be key.

Not sure if this is related to the original issue or not, but I am also getting an error message when I call any routes in views. It works fine when run manually. I'm using Rails 3.1 and Rspec

@ryanharkins It will be helpful if you could post a gist of errors in the comment.

@andhapp Sorry for that, here it is...

https://gist.github.com/2036785

Thanks. Will try and replicate this on my side first. Will post my findings here.

Edit: replete => replicate (damn iPhone)

I tried replicating the issue and failed. Please have a look at the rails app I created for the same. Here's the repo: https://github.com/andhapp/spin-test

Just wanted to report I'm having the same issue with our view specs. I'm trying to reproduce it on your spin-test app, but no luck so far. I did notice though that because you don't have haml listed as a gem, the view doesn't get rendered at all, so that as-is is a moot test case :P

For reference, here's a gist with the errors we get, the view, the spec and our Gemfile.lock: https://gist.github.com/849192f60a182a8a47c7

@marten: Thanks. I will use your Gemfile.lock and try and replicate the issue my side. Will post my findings.

@marten: Can you gist your Gemfile here please? Thanks.

@marten: I added the haml gem and tried reproducing the issue but no luck. Is there anything particular about your app, in terms of settings, different from the spin-test app.

I don't use view specs, but I'm also seeing this problem with helper specs -- route helpers not being available.

I'm not sure, but digging into it just a little, I bet it may be related to whatever reason spork-rails has for doing this. That's monkey-patching AbstractController::Helpers, which is included by ActionView::TestCase::Behavior and seemingly used to include all helpers, and which incidentally is used by RSpec's HelperExampleGroup and ViewExampleGroup, but notably not in request specs where I'm using route helpers without error in spin.

Hopefully that can get someone less tired than me started on figuring this out. I haven't dug through git blame history for insight on why Spork does that monkey patching since spork-rails was moved to its own repo, but maybe the Spork folks or perhaps @dchelimsky can shed some light on some of the machinery here.

Hey guys, I can confirm the issue.
Anyone can use my app to test. I just started it, so it's quite simple.
https://github.com/cutalion/SetupMeetup

I can disable spin temporary soon. In that case, you can use this commit to test, for instance.

@alexander cool, thanks. I will look at it. Thanks again for the app as I couldn't reproduce it myself.

On 14 Apr 2012, at 20:11, Alexanderreply@reply.github.com wrote:

Hey guys, I can confirm the issue.
Anyone can use my app to test. I just started it, so it's quite simple.
https://github.com/cutalion/SetupMeetup

I can disable spin temporary soon. In that case, you can use this commit to test, for instance.


Reply to this email directly or view it on GitHub:
#36 (comment)

Regarding this issue, I've found the cause of the problem but I'm still not sure why it happens when you run it through spin because spin just offloads things to rspec anyways. Thanks to @cutalion for fixing the spin_test rails app, that allowed me to replicate this issue.

Problem

url_helpers, for example: users_path, messages_path aren't recognised in the view specs when run via spin.

Hacky Solution

In your spec_helper.rb, please add the following line for now:

ActionView::TestCase::TestController.send(:include, Rails.application.routes.url_helpers)

Correct Solution

Coming soon as I need to investigate it further and see why running rspec on it's own doesn't have that issue.

I'm experiencing this issue too, with similar versions

I can confirm @andhapp's Hacky Solution works.

i'm using the hack solution too :)

That was only meant as a quick solution. I haven't had a chance to look at it again but this weekend I am surely going to fix this one.

On 14 Jun 2012, at 18:19, edrex-janrainreply@reply.github.com wrote:

i'm using the hack solution too :)


Reply to this email directly or view it on GitHub:
#36 (comment)

I believe #60 is related to this issue. Let me know how it works for everyone.

I just released the change from #60 as v0.5.3. Give it a try and reply here with your results.

Yay! It works! 👌