简体   繁体   English

TextMate中的RSpec:NameError:未初始化的常量RSpec

[英]RSpec in TextMate: NameError: uninitialized constant RSpec

Trying to use RSpec in Ruby and also with a Rails project. 尝试在Ruby中以及在Rails项目中使用RSpec。 Works fine from the command line, but Cmd-R in TextMate results in NameError: uninitialized constant RSpec 从命令行可以正常工作,但是TextMate中的Cmd-R导致NameError: uninitialized constant RSpec

spec/coffee_spec.rb : spec/coffee_spec.rb

class Coffee
  def ingredients
    @ingredients ||= []
  end

  def add(ingredient)
    ingredients << ingredient
  end

  def price
    1.00
  end
end

RSpec.describe 'A cup of coffee' do
  let(:coffee) { Coffee.new }

  it 'costs $1' do
    expect(coffee.price).to eq(1.00)
  end

  context 'with milk' do
    before { coffee.add :milk } 

    it 'costs $1.25' do
      expect(coffee.price).to eq(1.25)
    end
  end
end

I first tried to run coffee_spec.rb from Marston-Dees in Ruby and had same problem, but also tried in Rails project with same result. 我首先尝试在Ruby中从Marston-Dees运行coffee_spec.rb ,但遇到了同样的问题,但是我也在Rails项目中尝试了相同的结果。

I just revisited this because it still wasn't working right. 我只是重新考虑了这一点,因为它仍然无法正常工作。 This time I fixed it by setting TextMate PATH to $PATH:/usr/local/bin:/usr/texbin:/opt/local/bin 这次我通过将TextMate PATH设置为$PATH:/usr/local/bin:/usr/texbin:/opt/local/bin PATH来修复它$PATH:/usr/local/bin:/usr/texbin:/opt/local/bin

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM