Rails 4 - syntax error, unexpected tIDENTIFIER, expecting end-of-input

前端 未结 1 1565
忘了有多久
忘了有多久 2020-12-30 14:51

I have a piece of code that I am trying to run with rspec.

require \'spec_helper\'

    describe \"User\" do
        before { @user = User.new(name: \"Exampl         


        
相关标签:
1条回答
  • 2020-12-30 15:54

    You seem to indeed have been bitten by the "zero-width space problem". This is extremely frustrating, I know. You'd think that "show white space" should take care of the problem, particularly in an editor as advanced as Sublime.

    In any event, to detect the existence of these characters in Sublime 2, you can use this plugin. to display them.

    As an aside, I wasted hours if not days on this problem a few months ago when I copy/pasted some code from a website that had one of the little nasties in it.

    I searched the Sublime 2 site for any postings related to this (e.g. feature requests, etc.), but didn't find anything, so I don't know if this is on their radar.

    Note: The original version of this answer assumed that the zero-width space character was the same as the non-breaking space, which it is not. Non-breaking spaces, while they will still generate syntax errors, are much easier to detect since they "take up space" in your display (i.e. "look like" a space). There's also the "zero-width non-breaking space", which is different still. While it's easy to enter the non-breaking space on a Mac (i.e. Option-Space), I know of no way to enter any of the zero-width spaces.

    0 讨论(0)
提交回复
热议问题