samedi 31 octobre 2015

Rails and rspec. uninitialized constant Errors

I have a rails App. I have this file app/errors/status.rb

I try to pass the test but is not not working.

module Errors 
  class Status
    def initialize status
      @status = status
    end

    def default_message
      "Error in the server status: #{status}"
    end

    private

    attr_reader :status
  end
end

And the test on spec/errors/status_spec.rb:

require 'rails_helper'

describe Errors::Status do
  let(:status) { double 'status' }

  subject { described_class.new status }

  describe 'default_message' do
    it 'returns the default message' do
      expect(subject.call).to eq( "Error in the server status: #{status}")
    end
  end
end

And it keeps throwing this error:

/Users/gerardmorera/bet_play/spec/errors/status_spec.rb:3:in `<top (required)>': uninitialized constant Errors (NameError)
    from /Users/gerardmorera/.rvm/rubies/ruby-2.2.0/lib/ruby/gems/2.2.0/gems/rspec-core-3.3.2/lib/rspec/core/configuration.rb:1327:in `load'
    from /Users/gerardmorera/.rvm/rubies/ruby-2.2.0/lib/ruby/gems/2.2.0/gems/rspec-core-3.3.2/lib/rspec/core/configuration.rb:1327:in `block in load_spec_files'
    from /Users/gerardmorera/.rvm/rubies/ruby-2.2.0/lib/ruby/gems/2.2.0/gems/rspec-core-3.3.2/lib/rspec/core/configuration.rb:1325:in `each'
    from /Users/gerardmorera/.rvm/rubies/ruby-2.2.0/lib/ruby/gems/2.2.0/gems/rspec-core-3.3.2/lib/rspec/core/configuration.rb:1325:in `load_spec_files'
    from /Users/gerardmorera/.rvm/rubies/ruby-2.2.0/lib/ruby/gems/2.2.0/gems/rspec-core-3.3.2/lib/rspec/core/runner.rb:102:in `setup'
    from /Users/gerardmorera/.rvm/rubies/ruby-2.2.0/lib/ruby/gems/2.2.0/gems/rspec-core-3.3.2/lib/rspec/core/runner.rb:88:in `run'

Aucun commentaire:

Enregistrer un commentaire