簡體   English   中英

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

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

嘗試在Ruby中以及在Rails項目中使用RSpec。 從命令行可以正常工作,但是TextMate中的Cmd-R導致NameError: uninitialized constant RSpec

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

我首先嘗試在Ruby中從Marston-Dees運行coffee_spec.rb ,但遇到了同樣的問題,但是我也在Rails項目中嘗試了相同的結果。

我只是重新考慮了這一點,因為它仍然無法正常工作。 這次我通過將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