bradphelan / jasminerice

Pain free coffeescript testing under Rails 3.1
478 stars 113 forks source link

Does not work with mountable engines #40

Closed luxerama closed 11 years ago

luxerama commented 12 years ago

Unfortunately this is currently not working when used in a mountable engine.

dev4:rails vincent$ rails -v
Rails 3.2.2
dev4:rails vincent$ rvm use 1.9.3
Using /Users/vincent/.rvm/gems/ruby-1.9.3-p125
dev4:rails vincent$ rails plugin new gajas --mountable
      create  
      create  README.rdoc
      create  Rakefile
      create  gajas.gemspec
      create  MIT-LICENSE
      create  .gitignore
      create  Gemfile
      create  app
      create  app/controllers/gajas/application_controller.rb
      create  app/helpers/gajas/application_helper.rb
      create  app/mailers
      create  app/models
      create  app/views/layouts/gajas/application.html.erb
      create  app/assets/images/gajas
      create  app/assets/images/gajas/.gitkeep
      create  config/routes.rb
      create  lib/gajas.rb
      create  lib/tasks/gajas_tasks.rake
      create  lib/gajas/version.rb
      create  lib/gajas/engine.rb
      create  app/assets/stylesheets/gajas/application.css
      create  app/assets/javascripts/gajas/application.js
      create  script
      create  script/rails
      create  test/test_helper.rb
      create  test/gajas_test.rb
      append  Rakefile
      create  test/integration/navigation_test.rb
  vendor_app  test/dummy
         run  bundle install
Fetching source index for http://rubygems.org/
Using rake (0.9.2.2) 
Using i18n (0.6.0) 
Using multi_json (1.2.0) 
Using activesupport (3.2.3) 
Using builder (3.0.0) 
Using activemodel (3.2.3) 
Using erubis (2.7.0) 
Using journey (1.0.3) 
Using rack (1.4.1) 
Using rack-cache (1.2) 
Using rack-test (0.6.1) 
Using hike (1.2.1) 
Using tilt (1.3.3) 
Using sprockets (2.1.2) 
Using actionpack (3.2.3) 
Using mime-types (1.18) 
Using polyglot (0.3.3) 
Using treetop (1.4.10) 
Using mail (2.4.4) 
Using actionmailer (3.2.3) 
Using arel (3.0.2) 
Using tzinfo (0.3.32) 
Using activerecord (3.2.3) 
Using activeresource (3.2.3) 
Using bundler (1.0.22) 
Using rack-ssl (1.3.2) 
Using json (1.6.6) 
Using rdoc (3.12) 
Using thor (0.14.6) 
Using railties (3.2.3) 
Using rails (3.2.3) 
Using gajas (0.0.1) from source at /xyz/gajas 
Using jquery-rails (2.0.2) 
Using sqlite3 (1.3.5) 
Your bundle is complete! Use `bundle show [gemname]` to see where a bundled gem is installed.

now lets go into the engine root cd gaja

dev4:gajas vincent$ cat gajas.gemspec 
$:.push File.expand_path("../lib", __FILE__)

# Maintain your gem's version:
require "gajas/version"

# Describe your gem and declare its dependencies:
Gem::Specification.new do |s|
  s.name        = "gajas"
  s.version     = Gajas::VERSION
  s.authors     = ["TODO: Your name"]
  s.email       = ["TODO: Your email"]
  s.homepage    = "TODO"
  s.summary     = "TODO: Summary of Gajas."
  s.description = "TODO: Description of Gajas."

  s.files = Dir["{app,config,db,lib}/**/*"] + ["MIT-LICENSE", "Rakefile", "README.rdoc"]
  s.test_files = Dir["test/**/*"]

  s.add_dependency "rails", "~> 3.2.3"
  s.add_dependency "guard-jasmine"
  s.add_dependency "jasminerice"
  s.add_dependency "jquery-rails"

  s.add_development_dependency "sqlite3"
end

lets bundle and generate bundle && guard init jasmine, now create the necessary files and dirs

mkdir -p spec/javascripts
echo -e "#=require application\n#=require_tree ./" > spec/javascripts/spec.js.coffee
echo -e "/*\n * add css using =require application\n */" > spec/javascripts/spec.css

now lets give it a go test/dummy/script/rails s,
going to http://localhost:3000/jasmine and http://localhost:3000/gaja/jasmine returns No route matches [GET] "/jasmine" and No route matches [GET] "/gaja/jasmine" respectively

Guard encounters the following problem:

dev4:gajas vincent$ bundle exec guard
Guard could not detect any of the supported notification libraries.
Guard is now watching at '/xyz/gajas'
ERROR: Jasmine test runner isn't available at http://localhost:8888/jasmine: Connection refused - connect(2)
ERROR: Jasmine test runner isn't available at http://localhost:8888/jasmine: Connection refused - connect(2)
apneadiving commented 12 years ago

I share this concern, would love to have this working.

chamnap commented 11 years ago

i vote for this as well.

cantonic commented 11 years ago

I have the same issue. I cannot run "rails g jasminerice:install" on a rails engine. It returns "Error: uninitialized constant Jasminerice". Would love to see that feature as Rails Engine are more and more used.

UPDATE: there is an article ( http://n-so.com/blog/2012/09/08/using-jasminerice-to-test-coffeescript-in-a-rails-engine/ ) which helps working around that issue. I tried it and it works fine.

jejacks0n commented 11 years ago

Thanks for the link. I'll be writing a wiki article about this shortly.