Testing nested modules with rspec and rails

Possible duplicate:
Unit testing in rspec

I am currently successfully testing my modules with rspec as follows:

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 

My modules live in application / services / services.rb application / services / app_service.rb

However, is there a more elegant solution for testing my modules without declaring namespaces in the specification? I feel that it is closely related to my specifications, and making changes will cause a lot of headaches.

+4
source share
1 answer

Instead of duplicating AppServices you can do:

 module Services describe AppService do end ene 

Or:

 describe Services::AppService do end 

I prefer the first, because it allows me to completely not qualify constant names in the specification (since everything is in the Services module, it will first look in relation to this).

+9
source

Source: https://habr.com/ru/post/1438991/


All Articles