spin icon indicating copy to clipboard operation
spin copied to clipboard

View specs failing with spin (rails 3.2.1)

Open namxam opened this issue 13 years ago • 22 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.

namxam avatar Mar 03 '12 16:03 namxam

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.

andhapp avatar Mar 09 '12 12:03 andhapp

Error messages would be key.

jstorimer avatar Mar 10 '12 01:03 jstorimer

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 avatar Mar 14 '12 12:03 ryanharkins

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

andhapp avatar Mar 14 '12 13:03 andhapp

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

https://gist.github.com/2036785

ryanharkins avatar Mar 14 '12 14:03 ryanharkins

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

Edit: replete => replicate (damn iPhone)

andhapp avatar Mar 15 '12 09:03 andhapp

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

andhapp avatar Mar 19 '12 10:03 andhapp

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 avatar Mar 23 '12 11:03 marten

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

andhapp avatar Mar 23 '12 13:03 andhapp

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

andhapp avatar Mar 24 '12 00:03 andhapp

@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.

andhapp avatar Mar 24 '12 00:03 andhapp

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.

ches avatar Apr 03 '12 20:04 ches

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.

cutalion avatar Apr 14 '12 19:04 cutalion

@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, [email protected] 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: https://github.com/jstorimer/spin/issues/36#issuecomment-5133709

andhapp avatar Apr 14 '12 19:04 andhapp

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.

andhapp avatar May 02 '12 18:05 andhapp

I'm experiencing this issue too, with similar versions

edrex-janrain avatar Jun 13 '12 23:06 edrex-janrain

I can confirm @andhapp's Hacky Solution works.

jc00ke avatar Jun 14 '12 17:06 jc00ke

i'm using the hack solution too :)

edrex-janrain avatar Jun 14 '12 17:06 edrex-janrain

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, [email protected] wrote:

i'm using the hack solution too :)


Reply to this email directly or view it on GitHub: https://github.com/jstorimer/spin/issues/36#issuecomment-6334866

andhapp avatar Jun 14 '12 17:06 andhapp

I believe https://github.com/jstorimer/spin/pull/60 is related to this issue. Let me know how it works for everyone.

jdelStrother avatar Jul 26 '12 17:07 jdelStrother

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

jstorimer avatar Jul 27 '12 06:07 jstorimer

Yay! It works! :ok_hand:

cutalion avatar Jul 27 '12 07:07 cutalion