LoginSignup
1
1

More than 5 years have passed since last update.

SpringでRSpecが実行できなくなった

Posted at

spring経由で実行すると以下の様なエラーが出てしまった。

コマンド
$ spring rspec spec
/Users/uchiko/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/rspec-rails-3.1.0/lib/rspec/rails/matchers.rb:15:in `rescue in <top (required)>': Test is not a module (TypeError)

spring stopしてみても直らない。
springを経由しなければエラーは起こらない。

原因は、railsのTask機能を確認するために、
以下の内容のファイルを作っていたからだった。

lib/tasks/test.rb
class Test
  def self.hoge
    puts 'hoge'
  end
end

springを実行した時、
Railsアプリ全体が読み込まれてTestクラスが定義されてしまった後、
rspec-railsTestモジュールを定義しようとしてエラーが出ていた。

lib/tasks/test.rbを消したら直った。

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1