TypeError: Player is not a constructor

1,329 views
Skip to first unread message

Jeff S.

unread,
May 5, 2011, 4:03:03 PM5/5/11
to Jasmine
I just installed the Jasmine gem and ran the Rails generators. When I
start use rake jasmine and go to localhost:8888, all the bundled tests
fail, starting with this one:

Player
when song has been paused
should indicate that the song is currently paused
TypeError: Player is not a constructor in http://localhost:8888/__spec__/PlayerSpec.js
(line 6)
([object Object])@http://localhost:8888/__JASMINE_ROOT__/lib/
jasmine.js:94 ([object Error])@http://localhost:8888/__JASMINE_ROOT__/
lib/jasmine.js:1965 ((function () {if (jasmine.Queue.LOOP_DONT_RECURSE
&& calledSynchronously) {completedSynchronously = true;return;}if
(self.blocks[self.index].abort) {self.abort = true;}self.offset =
0;self.index++;var now = (new Date).getTime();if
(self.env.updateInterval && now - self.env.lastUpdate >
self.env.updateInterval) {self.env.lastUpdate =
now;self.env.setTimeout(function () {self.next_();}, 0);} else {if
(jasmine.Queue.LOOP_DONT_RECURSE && completedSynchronously) {goAgain =
true;} else {self.next_();}}}))@http://localhost:8888/__JASMINE_ROOT__/
lib/jasmine.js:970 ()@http://localhost:8888/__JASMINE_ROOT__/lib/
jasmine.js:1739

Here is my spec/javascripts/support/jasmine.yml

# src_files
#
# Return an array of filepaths relative to src_dir to include before
jasmine specs.
# Default: []
#
# EXAMPLE:
#
# src_files:
# - lib/source1.js
# - lib/source2.js
# - dist/**/*.js
#
src_files:
- public/javascripts/prototype.js
- public/javascripts/effects.js
- public/javascripts/controls.js
- public/javascripts/dragdrop.js
- public/javascripts/application.js
- public/javascripts/**/*.js

# stylesheets
#
# Return an array of stylesheet filepaths relative to src_dir to
include before jasmine specs.
# Default: []
#
# EXAMPLE:
#
# stylesheets:
# - css/style.css
# - stylesheets/*.css
#
stylesheets:
- stylesheets/**/*.css

# helpers
#
# Return an array of filepaths relative to spec_dir to include before
jasmine specs.
# Default: ["helpers/**/*.js"]
#
# EXAMPLE:
#
# helpers:
# - helpers/**/*.js
#
helpers:
- helpers/**/*.js

# spec_files
#
# Return an array of filepaths relative to spec_dir to include.
# Default: ["**/*[sS]pec.js"]
#
# EXAMPLE:
#
# spec_files:
# - **/*[sS]pec.js
#
spec_files:
- **/*[sS]pec.js

# src_dir
#
# Source directory path. Your src_files must be returned relative to
this path. Will use root if left blank.
# Default: project root
#
# EXAMPLE:
#
# src_dir: public
#
src_dir:

# spec_dir
#
# Spec directory path. Your spec_files must be returned relative to
this path.
# Default: spec/javascripts
#
# EXAMPLE:
#
# spec_dir: spec/javascripts
#
spec_dir: spec/javascripts

One thing of note...if I set my src_dir to public, I get errors that
Player is not defined at all, so I know it is finding the source JS
files.

Is there something I missed in the configuration? Thanks for your
help.

- Jeff Sutherland

Davis Frank

unread,
May 6, 2011, 10:08:10 AM5/6/11
to jasmi...@googlegroups.com
Which version of Rails are you using?

I've just recently done this from scratch on a Rails 3 project and didn't see the problem. Hmmm.

--dwf


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


Jeff S.

unread,
May 6, 2011, 2:15:32 PM5/6/11
to Jasmine
After a bit of digging, it turns out Player() was a name conflict with
other code in my application. I renamed Player(), and this is no
longer an issue.

- Jeff

On May 6, 8:08 am, Davis Frank <dwfr...@pivotallabs.com> wrote:
> Which version of Rails are you using?
>
> I've just recently done this from scratch on a Rails 3 project and didn't
> see the problem. Hmmm.
>
> --dwf
>

Davis Frank

unread,
May 6, 2011, 2:34:17 PM5/6/11
to jasmi...@googlegroups.com
Thanks for the update. Sorry for the confusion.

--dwf
Reply all
Reply to author
Forward
0 new messages