Possible Duplicate:
Testing modules in rspec
Currently I am successfully testing my modules with rspec like so:
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 app/services/services.rb app/services/app_service.rb
However is there a more elegant solution to testing my modules without having to declare the namespaces in the spec? I feel that it becomes tightly bound to my specs and making changes will cause a lot of headaches.
Instead of duplicating AppServices
, you can do:
module Services
describe AppService do
end
ene
Or:
describe Services::AppService do
end
I tend to prefer the former, because it allows me to not fully-qualify constant names in the spec (since everything is in the Services
module, it'll look relative to that, first).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With