Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Karma + Rails: File structure?

When using the karma javascript test library (née Testacular) together with Rails, where should test files and mocked data go be placed?

It seems weird to have them in /assets/ because we don’t actually want to serve them to users. (But I guess if they are simply never precompiled, then that’s not an actual problem, right?)

like image 523
Alan H. Avatar asked May 13 '13 18:05

Alan H.


People also ask

What is directory structure Ruby on rails?

Ruby on Rails - Directory Structure. When you use the Rails helper script to create your application, it creates the entire directory structure for the application. Rails knows where to find things it needs within this structure, so you don't have to provide any input.

What files are available in demo Directory of rails?

Apart from these directories, there will be two files available in demo directory. README − This file contains a basic detail about Rail Application and description of the directory structure explained above. Rakefile − This file is similar to Unix Makefile, which helps with building, packaging and testing the Rails code.

How does the rails helper script create a directory structure?

When you use the Rails helper script to create your application, it creates the entire directory structure for the application. Rails knows where to find things it needs within this structure, so you don't have to provide any input. Here is a top-level view of a directory tree created by the helper script at the time of application creation.

What are the different subdirectories in rails?

It's got subdirectories that hold the view (views and helpers), controller (controllers), and the backend business logic (models). app/controllers − The controllers subdirectory is where Rails looks to find the controller classes. A controller handles a web request from the user.


1 Answers

Via this post: https://groups.google.com/forum/#!topic/angular/Mg8YjKWbEJ8

I'm experimenting with something that looks like this:

// list of files / patterns to load in the browser
files: [
  'http://localhost:3000/assets/application.js',
  'spec/javascripts/*_spec.coffee',
  {
    pattern: 'app/assets/javascripts/*.{js,coffee}',
    watched: true,
    included: false,
    served: false
  }
],

It watches app js files, but doesn't include them or serve them, instead including the application.js served by rails and sprockets.

I've also been fiddling with https://github.com/lucaong/sprockets-chain , but haven't found a way to use requirejs to include js files from within gems (such as jquery-rails or angularjs-rails).

like image 139
Peter Ehrlich Avatar answered Sep 28 '22 17:09

Peter Ehrlich