我有一个测试控制器的rspec文件。
当我在此rspec文件中右键单击并为我所在的文件选择Run
/ Debug
时,它会在控制台中显示以下内容:
Fast Debugger (ruby-debug-ide 0.6.1.beta2, debase 0.2.2.beta8, file filtering is supported) listens on 0.0.0.0:64675
Uncaught exception: /develop/warranty-web/bin/rspec:2: `$(' is not allowed as a global variable name
Process finished with exit code 0
我的bin / rspec文件有两行bash脚本:
#!/usr/bin/env bash
exec $(dirname $0)/spring rspec "$@"
所以rubymine(或rspec?不确定)是将bash脚本解释为ruby。为什么这样做以及如何修复它以便我可以调试文件?
- 编辑: -
如果有帮助,这是spec文件。
require 'spec_helper'
require 'ruby-debug'
describe Api::V1::Internal::SessionsController do
before do
@request.env['devise.mapping'] = Devise.mappings['api_v1_internal_user']
end
context 'when invalid email' do
it 'returns a 401 (invalid credentials)' do
post :create, user: { email: 'invalidemail@mail.com', password: 'madeuppassword' }
expect(response.status).to eq(401)
end
end
context 'when valid email but invalid password' do
it 'returns a 401 (invalid credentials)' do
post :create, user: { email: 'justin.eisenhauer@metova.com', password: 'madeuppassword' }
expect(response.status).to eq(401)
end
end
context 'when valid email and password' do
it 'returns a 200 (ok)' do
post :create, user: { email: 'justin.eisenhauer@metova.com', password: 'metova' }
expect(response.status).to eq(200)
end
end
end
答案 0 :(得分:0)
对于那些有同样问题的人......我最终做的是,我的一个朋友告诉我将rspec重命名为rspec.rb,这样它实际上就可以作为ruby运行了。然后将其内容更改为:
require 'pathname'
ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
Pathname.new(__FILE__).realpath)
require 'rubygems'
require 'bundler/setup'
load Gem.bin_path('rspec-core', 'rspec')