5

重複の可能性:
rspecでモジュールをテストする

現在、次のようにrspecを使用してモジュールを正常にテストしています。

require 'spec_helper'

module Services
  module AppService
    describe AppService do
      describe "authenticate" do
        it "should authenticate the user" do
          pending "authenticate the user"
        end
      end
    end
  end
end

私のモジュールはapp/services / services.rb app / services/app_service.rbにあります

ただし、仕様で名前空間を宣言せずにモジュールをテストするためのより洗練されたソリューションはありますか?それは私の仕様にしっかりと結びついていて、変更を加えることは多くの頭痛の種になると思います。

4

1 に答える 1

11

複製する代わりに、次のAppServicesことができます。

module Services
  describe AppService do
  end
ene

または:

describe Services::AppService do
end

私は前者を好む傾向があります。これは、仕様内の定数名を完全に修飾できないためです(すべてがServicesモジュール内にあるため、最初はそれに関連して表示されます)。

于 2012-10-10T20:35:38.503 に答える