0

尝试在 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

我首先尝试coffee_spec.rb在 Ruby 中从 Marston-Dees 运行并遇到同样的问题,但也在 Rails 项目中尝试了相同的结果。

4

1 回答 1

1

我只是重新审视了这个,因为它仍然无法正常工作。这次我通过将 TextMate 设置PATH为来修复它$PATH:/usr/local/bin:/usr/texbin:/opt/local/bin

于 2019-07-02T04:12:42.700 回答