GithubHelp home page GithubHelp logo

Comments (15)

searls avatar searls commented on June 12, 2024

This strikes me as requiring live debugging to identify the cause. Can you prepare a minimal sample project? Unless @wireframe has an idea?

from jasmine-rails.

wireframe avatar wireframe commented on June 12, 2024

can you check your asset pipeline settings for development/test? specifically, the assets.debug flag. try flipping it to false (the default) and re-run the specs

config.assets.debug = false

from jasmine-rails.

jerodsanto avatar jerodsanto commented on June 12, 2024

@wireframe I set config.assets.debug to false in my development environment and it fixed the problem! This begs two questions:

  1. Shouldn't the test environment be in effect when running Jasmine specs, not the development environment?
  2. Why does having this setting set to true (the default on a newly generated 3.2.13 app) cause this problem?

from jasmine-rails.

searls avatar searls commented on June 12, 2024

Both very valid questions.

from jasmine-rails.

jerodsanto avatar jerodsanto commented on June 12, 2024

So turning of assets debugging in dev mode is pretty annoying. I confirmed that explicitly running the specs in test mode, eg:

RAILS_ENV=test rake spec:javascript

fixes the 'run twice' behavior. This is most likely because asset debugging is disabled by default in test mode.

Having the specs run in test mode by default makes a lot of sense to me. Alternatively, fixing how jasmine-specs.js is generated also makes a lot of sense to me.

Thoughts?

from jasmine-rails.

searls avatar searls commented on June 12, 2024

Either way, 👍 to flipping test mode on for that rake task.

from jasmine-rails.

searls avatar searls commented on June 12, 2024

Can anyone find a decent example of how one's supposed to favor the test environment from a rake task that inherits from :environment? I couldn't find one.

from jasmine-rails.

floehopper avatar floehopper commented on June 12, 2024

I'm still seeing this issue in v0.4.5. It works fine if I use RAILS_ENV=test rake spec:javascript, but not if I don't set the environment to test i.e. I'm not convinced 7f00190 fixed the problem. Note that I'm using Rails v4.0.0.

from jasmine-rails.

searls avatar searls commented on June 12, 2024

Yep, this is a regression caused by how Rails 4 preloads the Rails environment for every executed task. I've asked several people and received zero productive comments on how to work around it.

For now, just use RAILS_ENV=test. If we can't find a way to wrangle the Rails environment, I think a new release should probably just eschew rake altogether and include a CLI bin for jasmine-rails.

from jasmine-rails.

floehopper avatar floehopper commented on June 12, 2024

Cool. Thanks for letting me know.

from jasmine-rails.

searls avatar searls commented on June 12, 2024

I'm still pretty stumped about how to flip Rails environment after Rake starts. I've heard from multiple people that it's not possible anymore.

Please Internet, you're my only hope

from jasmine-rails.

wireframe avatar wireframe commented on June 12, 2024

@searls I think the key to fixing this issue is to not depend on :environment in the rake task declaration. The environment task is triggered to load the current Rails environment (which defaults to development) and afterwards, you won't be able to change back into test mode.

Instead, you should be able to define the task with no dependencies, manually set the RAILS_ENV environment variable, and then programmatically trigger the :environment task to load the rest of the Rails environment.

Here's a gist as an example, but I have not tested it yet to confirm that it works as expected.
https://gist.github.com/wireframe/6581238

from jasmine-rails.

searls avatar searls commented on June 12, 2024

I spiked this but what I found was that rails' env is preloaded as of rails 4 in such a way that it doesn't matter whether we depend on the :environment. Did you test your spike to verify it works on rails 4?

On Mon, Sep 16, 2013 at 10:18 AM, Ryan Sonnek [email protected]
wrote:

@searls I think the key to fixing this issue is to not depend on :environment in the rake task declaration. The environment task is triggered to load the current Rails environment (which defaults to development) and afterwards, you won't be able to change back into test mode.
Instead, you should be able to define the task with no dependencies, manually set the RAILS_ENV environment variable, and then programmatically trigger the :environment task to load the rest of the Rails environment.
Here's a gist as an example, but I have not tested it yet to confirm that it works as expected.

https://gist.github.com/wireframe/6581238

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

from jasmine-rails.

danilopopeye avatar danilopopeye commented on June 12, 2024

@wireframe @searls I just tested the gist mentioned above in a rails 4 app and it didn't worked 😞

from jasmine-rails.

searls avatar searls commented on June 12, 2024

Indeed, in Rails 4, Rake always has Rails loaded before tasks run. :-(

On Mon, Oct 21, 2013 at 9:41 AM, Danilo Sousa [email protected]
wrote:

@wireframe @searls I just tested the gist mentioned above in a rails 4 app and it didn't worked 😞

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

from jasmine-rails.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.