2017-11-13 7 views
0

jasmine 사양이 정상적으로 실행 중입니다.jasmine-gem에서 jquery가 제대로로드되지 않습니다.

ReferenceError: Can't find variable: $ in http://localhost:57132/__spec__/

그래서, 난 여전히 bundle install 같은 오류 후 gem "jasmine-jquery-rails"

추가 : 나는 $ 같은 JQuery와 구문을 사용해야 할 때 나는 다음과 같은 오류를 얻고있다.

이제 jasmine.yml 파일에 jasmine-jquery을 추가하기로 결정했지만 여전히 같은 오류가 발생합니다.

그런 다음 jasmine-jquery.js을 수동으로 다운로드하여 app/assets/javascripts에 입력하고 jasmine.yml에 추가하기로 결정했습니다. 그런 다음 모든 사양에 오류가 발생합니다.

TypeError: Right-hand side of 'instanceof' is not an object 

TypeError: $ is not a function 

내가 여기서 잘못하고있는 것을 이해하지 못합니다.

파일을로드하는 순서가 여기에있는 문제라고 생각합니다. 그러나 이것을 알아낼 수는 없습니다.

답변

1

나는 방금 재스민 보석을 사용하여 어제 사용하기 시작했으나 잠시 동안 그걸로 싸운 후에 나는 그것을 위해 일했다.

필요한 것은 $ 처리기를 등록하기 위해 JQuery를 얻는 것입니다. src_filesyasmine.yml의 JQuery 라이브러리를 추가하는 것만으로는 도움이되지 않습니다.

src_files: 
    - assets/application.js 
    - '../vendor/javascripts/*.js' 
    - 'javascript/**/*.js' 

(필자는 javascript/ 폴더에 내 실제 소스 파일을 가지고와의 ..vender/javascripts/ 폴더를 사용 : 나를 위해 일을 한 일

src_files 아래 첫 번째 항목로 jasmine.yml에 assets/application.js를 포함했다 타사 라이브러리, 이것은 다른 것입니다)

확인 JQuery와이 같은 assets/javascripts/application.js 필요합니다 확인하십시오.

// This is a manifest file that'll be compiled into application.js, which will include all the files 
// listed below. 
// 
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts, 
// or any plugin's vendor/assets/javascripts directory can be referenced here using a relative path. 
// 
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the 
// compiled file. JavaScript code in this file should be added after the last require_* statement. 
// 
// Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details 
// about supported directives. 
// 
//= require jquery 
//= require jquery_ujs 
//= require turbolinks 
//= require_tree . 

이것은 rails new 명령 줄 도구를 통해 새 응용 프로그램을 생성 할 때 사용자의 assets/javascripts/application.js이 어떻게 나타나는지 보여줍니다.

보석이 기본 JQuery 지원이 아닌 추가 테스트 기능을 추가하기 때문에 문제가 도움이되지 않습니다.

재스민 설치가 성공적으로 완료되었습니다.