Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8976997
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T19:16:26+00:00 2026-06-15T19:16:26+00:00

So, this was quite an interesting problem I have been running into. I am

  • 0

So, this was quite an interesting problem I have been running into.

I am currently building a backbone.js – Rails app. Generally just building this for learning purposes. I am (like any good rails dev) doing my best at TDD/BDD and I ran into a problem with capybara.

I have an integration spec that merely tests root_path works (Backbone history starts, displays initial information, etc…).

require 'spec_helper'

describe "RentalProperties", js: true do
  describe "GET /" do
    it "should show a list of properties" do
      visit root_path
      eventually{page.should have_content("Something")}
    end
  end
end

I am running tests with jasmine, sinon, and capybara/rspec/webkit. I am loosely following both the “Rspec on Rails” book by thoughtbot (awesome book by the way), and this tutorial: http://tinnedfruit.com/2011/03/03/testing-backbone-apps-with-jasmine-sinon.html.

When running the above spec, I came across this error:

undefined|0|ReferenceError: Strict mode forbids implicit creation of global property 'csrf_token'

I took a long time sorting this out because there’s really nothing google-able for this error.

Eventually I stumbled across using “use strict-mode” in JS. Essentially this will use some new EMCA5 script conventions. It will catch more coding bloopers, and keep you from accessing global variables. All good things.

So I check, and in my sinon.js file, I see:

"use strict";

on line 36 of the file. Lo and behold I comment out the line, and my tests work just fine.

Here is my question: Why did use strict mess up csrf? I am assuming this has something to do with csrf_meta_tags in my rails layout. If possible I would like to put this line back in sinon js as I assume its the “right thing to do”

Does anyone have more information on this? I appreciate any details in advance!!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T19:16:27+00:00Added an answer on June 15, 2026 at 7:16 pm

    It is telling you that a value is being assigned to a variable called csrf_token that has not been declared, e.g.

    csrf_token = 'foo';
    

    In non–strict mode, that will create a property of the global object (usually called a global variable) called csrf_token when that line of code is executed.

    In strict mode, it will throw the error you see because strict mode prevents the implicit creation of global variables. You could also fix it by including:

    var csrf_token;
    

    anywhere in a global context in the same script element as the code the error comes from, or a previous script element.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this quite popular problem, but have failed to find a solution that
Summary: I've run into an interesting problem, and I'm not quite sure how to
I have an interesting problem, however I don't know quite how to articulate it
I've come across a very interesting problem.. quite lost actually. Suppose I have a
This is an interesting problem I've come across that I feel should have an
This is a quite interesting question, in my opinion. I have a strongly typed
Demo http://people.mywot.com/dean/tour/ie6test.html I have narrowed down this problem into the test case above. You'll
I have ran into quite an interesting mapping scenario. I have two entities (
I ran into an interesting problem yesterday and while the fix was quite simple,
I have a quite interesting problem that's making my head twist. I'm working on

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.