Rails Jasmine newb -- issues running specs

306 views
Skip to first unread message

Jferg

unread,
Jun 12, 2011, 2:40:58 AM6/12/11
to Jasmine
I am trying to adhere to the directions at:
https://github.com/pivotal/jasmine/wiki/A-rails-project

My env:

OS X 10.5.8
rvm 1.2.9
ruby 1.8.7 (2010-12-23 patchlevel 330)
rails (2.3.4)
jasmine (1.0.2.1)

I have installed the gem per the WIki above and ran the generate. The
samples are in place. I ran them as is and I changed one condition to
force a failure. No matter what nothing shows up when I run the rake
task.

I have tried running:

rake spec

Per the Wiki directions and I get nothing output.

If per the install I output I run:

rake jasmine

Should I see some output at the terminal window?

I get this error:

Jasmine is not available. In order to run jasmine, you must: (sudo)
gem install jasmine

So I am not sure what I did wrong... the gem seemed to install and
generate examples. I am not sure why when running the test server
with "rake jasmine" it can not see the gem is installed -- maybe RVM
and jasmine have an issue?

Anything I need to do/investigate for this to resolve the issue?

Perry Smith

unread,
Jun 12, 2011, 8:12:16 AM6/12/11
to jasmi...@googlegroups.com
You need to open a browser to port 8888.

I got my start from: http://railscasts.com/episodes/261-testing-javascript-with-jasmine

> --
> You received this message because you are subscribed to the Google Groups "Jasmine" group.
> To post to this group, send email to jasmi...@googlegroups.com.
> To unsubscribe from this group, send email to jasmine-js+...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/jasmine-js?hl=en.
>

Jferg

unread,
Jun 12, 2011, 10:41:05 AM6/12/11
to Jasmine
Thanks:

* I love Railscasts I use them often
* This one did not help me with my problem though because....

At this time we are:

* On Rails 2.3.4 -- we know we need to move up but we do this project
after work hours in different time zones and technical currency is a
problem let alone getting the core idea developed. This effort to
move to using jasmine is my tech currency effort this sprint.
* Not using bundler for Rails 2.3 (I googled I know it can be done --
throw it on the tech backlog)
* I am on OS X and use RVM my co-devs are not on OS X... so gemsets
and so forth -- not the solution.

Whenever I do rake jasmine it barfs :
------------------------------------------------

rake jasmine
Jasmine is not available. In order to run jasmine, you must: (sudo)
gem install jasmine

* I have added: config.gem 'jasmine', :group => [:development, :test]
to my environment.rb
* The gem is installed per the jasmine wiki for Rails 2
* I ran the Wiki steps for post install
* I cannot even get their generated samples to run... nothing fails
but nothing runs!
* Why must I do sudo gem install Jasmine? IT IS ALREADY INSTALLED
* Should: rake --tasks jasmine list at least 2 jasmine targets?

Thanks

Perry Smith

unread,
Jun 12, 2011, 11:32:57 AM6/12/11
to jasmi...@googlegroups.com
I sounds like jasmine isn't be found for some reason.

Lets take it slow...

This is a rails project so the Wiki page is https://github.com/pivotal/jasmine/wiki/A-rails-project "For Rails 2 Projects"

I assume you did: gem install jasmine

I assume if you do "gem list" it shows jasmine.  You said you are using RVM so be sure that you are using the right "rvm use ...". (which I assume you are doing).

I did not use the "group" option.  (I'm on Rails 2.3.11 but just moved up from 2.3.5 so I wasn't far off from where you are starting from).  I'm not using Builder either.  I *am* using a Ruby that I installed myself (or rvm installed for me).  I'm not using the system's ruby.  With rvm, that proved pretty painful for me.

I added: 

config.gem "jasmine" 

in my config/environments/development.rb and config/environments/test.rb files.

e.g.

grep jasmine config/environments/*
config/environments/development.rb:config.gem "jasmine"
config/environments/test.rb:config.gem "jasmine"

At this point, "rake gems" should not die (and should list Jasmine). Other rake tasks should work too.  To answer your last question: "yes"  rake -T jasmine should list two tasks.  e.g.

rake -T jasmine
(in /Users/pedzan/Source/Rails/raptor)
rake jasmine     # Run specs via server
rake jasmine:ci  # Run continuous integration tests

That might be after you do:

script/generate jasmine
rake spec

as the Rails wiki page describes.

Is it possible that rake is switching out of rvm?  Do "type rake" and make sure it is executing the rake that you want.  Again, rvm using the *system* is awkward for me.  If you have installed a ruby using rvm, then it should be executing out of that area.  In my case it is: 

/usr/local/rvm/gems/ruby-1.9.1-p378@raptor/bin/rake

because I have rvm installed system wide (which is also painful at times).



Jferg

unread,
Jun 12, 2011, 12:52:02 PM6/12/11
to Jasmine
Well, I did follow your steps to cross check my setup, but still no
luck.

* I verified the rake is the one I am on via RVM:

which rake
/Users/johnferguson/.rvm/gems/ruby-1.8.7-p330/bin/rake

* I updated my environment configs and am no longer using the group
option.

* I rechecked rake -T jasmine: still no targets

* I am NOT using the system Ruby via RVM:
rvm list
rvm rubies
=> ruby-1.8.7-p330 [ i386 ]
ruby-1.9.2-p0 [ i386 ]

If I use: rvm system the ruby is the original 1.8.6

I tried using rake --trace to get more info. Nothing new comes up
there.

Thanks for your help.

On Jun 12, 11:32 am, Perry Smith <pedz...@gmail.com> wrote:
> I sounds like jasmine isn't be found for some reason.
>
> Lets take it slow...
>
> This is a rails project so the Wiki page ishttps://github.com/pivotal/jasmine/wiki/A-rails-project"For Rails 2 Projects"

Perry Smith

unread,
Jun 12, 2011, 1:15:19 PM6/12/11
to jasmi...@googlegroups.com
I'm going to hang out on #jasmine on irc.freenode.net if you have some type of IRC client we can chat -- maybe get this going for you.

My next suggestion is to add to your Rakefile:

task :list_gems do
  system("gem list")
end

Then do: rake gem_list

to verify that we are seeing jasmine in your list of gems.  If it is listed, then my initial diagnosis was wrong and I need to rethink what might be wrong.  If it is not listed and "gem list" from the command prompt shows it, then somehow, something is changing your rvm setup when you do rake...

Jferg

unread,
Jun 12, 2011, 2:22:58 PM6/12/11
to Jasmine
Okay four more bits of information:

What you said about Rake made me go look around in my rails app and I
noticed:

lib/tasks/jasmine.rake
=================
begin
require 'jasmine'
load 'jasmine/tasks/jasmine.rake'
rescue LoadError
task :jasmine do
abort "Jasmine is not available. In order to run jasmine, you
must: (sudo) gem install jasmine"
end
end

The LoadError must be bombing out so I try this....

Under irb
========

uby-1.8.7-p330 :001 > require 'rubygems'
=> true
ruby-1.8.7-p330 :002 > require 'jasmine'
=> true
ruby-1.8.7-p330 :003 > load 'jasmine/tasks/jasmine.rake'
NoMethodError: undefined method `namespace' for #<Object:0x38950>
from /Users/johnferguson/.rvm/gems/ruby-1.8.7-p330/gems/
jasmine-1.0.2.1/lib/jasmine/tasks/jasmine.rake:1
from (irb):3:in `load'
from (irb):3


I also think that script/console is probably more "real" for Rails
but.....

Under script/console
================
require 'jasmine'
Gem::LoadError: can't activate rack (>= 1.1, runtime) for
["jasmine-1.0.2.1"], already activated rack-1.0.1 for
["actionpack-2.3.4", "rails-2.3.4"]
from /Users/j

Using your debugging suggestion for Rakefile:
===================================
Running it show jasmine is there......

jasmine (1.0.2.1)

Some loading in irb world breaks and in script/console world also
breaks..... something there. Not sure yet what.

Also, I am on Rails 2.3.4 and you are on at least 2.3.5. I may have
to upgrade anyway it is annoying getting warnings from the system
about :

gem_dependency.rb:119:Warning: Gem::Dependency#version_requirements is
deprecated and will be removed on or after August 2010. Use
#requirement

And being so far behind has possible risks. Given we are working on
Heroku we need to see what stack we can go to.

Again, thanks

Perry Smith

unread,
Jun 12, 2011, 2:33:33 PM6/12/11
to jasmi...@googlegroups.com
Ugg...

As I recall, "namespace" was added to rake after it was first deployed.  Which rake do you have?  I kinda think you can upgrade that -- perhaps not to the latest but to at least a place that has namespace -- without much work.

Yes... being behind in this game is awful.  I'm behind too although not quite as far as you.  I really need to get up to Ruby 1.9.2 and Rails 3 "soon"... but that never seems to happen (and I'm just one guy working on his own).

I'm running rake 0.8.7:

rake --version
rake, version 0.8.7

Jferg

unread,
Jun 12, 2011, 5:10:41 PM6/12/11
to Jasmine
Well I have the same version of Rake and I have a project specific
rake file which uses namespaces and I added a test task for good
measure -- it all works. So much for the easy way out for me.

I will look into upgrading Rails 2.3.4 up .... I mean at least then
I'll be less out of date. Maybe this will work.

Jferg

unread,
Jun 13, 2011, 11:47:54 PM6/13/11
to Jasmine

After dodging the bullet of Rails upgrading I went through with it -
thanks to RVM and Git for making it reasonable to do this in another
gemset on another branch. Moving to Rails 2.3.12 and upgrading Rake I
ended up with Jasmine samples and tasks running. It may be possible
to move up from 2.3.4 to get this too... but I figured might as well
really get current.

Rajan Agaskar

unread,
Jun 14, 2011, 8:10:23 AM6/14/11
to jasmi...@googlegroups.com
Yeah, the minimum dependency for the jasmine-gem is rack 1.1. I think that puts our minimum Rails dependency somewhere around Rails 2.3.8 

We used to have a backport for Rack 1.0 compatibility but it was yanked in this commit: https://github.com/pivotal/jasmine-gem/commit/3e6f62a1c8c8275d2532c417c9e323f0b05564a7

A good option here (if upgrading is not possible) may be to use an older version of Jasmine (< 1.0.2.0). Another option may be to fork it and include the 1.0 patch. 

Glad you were able to solve your problem! 
Reply all
Reply to author
Forward
0 new messages