[英]Running rspec test in RubyMine gets `bin/rspec:2: `$(' is not allowed as a global variable name`
I have a rspec file that tests a controller. 我有一个测试控制器的rspec文件。
When I right-click in this rspec file and select Run
/ Debug
for the file I'm in, it shows the following in the console: 当我右键单击此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
My bin/rspec file has two lines of bash script: 我的bin / rspec文件有两行bash脚本:
#!/usr/bin/env bash
exec $(dirname $0)/spring rspec "$@"
So rubymine (or rspec? not sure) is interpreting bash script as if it were ruby. 所以rubymine(或rspec?不确定)是将bash脚本解释为ruby。 Why is it doing this and how can I fix it so I can debug the file?
为什么这样做以及如何修复它以便我可以调试文件?
--Edit:-- - 编辑: -
If it helps, here is the spec file. 如果有帮助,这是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
For anyone who has this same question...what I ended up doing was, a friend of mine showed me to rename rspec to rspec.rb so it can actually just be run as ruby. 对于那些有同样问题的人...我最终做的是,我的一个朋友告诉我将rspec重命名为rspec.rb,所以它实际上可以作为ruby运行。 And then change it's contents to this:
然后将其内容更改为:
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')
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.