Greg
Greg

Reputation: 2609

RSpec in TextMate: NameError: uninitialized constant RSpec

Trying to use RSpec in Ruby and also with a Rails project. Works fine from the command line, but Cmd-R in TextMate results in 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

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.

Upvotes: 0

Views: 293

Answers (1)

Greg
Greg

Reputation: 2609

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

Upvotes: 1

Related Questions