Rspec uninitialized constant NameError, when not requiring Rails -
i'm trying speed tests not requiring rails. moving things modules , testing separately. things faster, yay (if little confusing)...
the issue have right when module requires module.
my guard tests pass however, when running rspec, following:
uninitialized constant useralerts::usermailerhelper (nameerror)
my useralerts module looks this:
module useralerts include usermailerhelper def state_events(params) .. stuff ... state_events_email(emails, params) end def state_events_email(emails, params) emails.each |email| send_message(email, params) end end
and usermailerhelper so:
module usermailerhelper def send_message(email, params={}) send... end end
in spec/lib/user_alerts.rb test, have this:
require file.expand_path("../../../app/lib/user_alerts", __file__) class biscuit include useralerts end describe useralerts context "finds users send emails to" "should return users email" users = [stub(:email => email, beta: true, system_alerts: 'email'), stub(:email => email, beta: false, system_alerts: 'sms')] bis = biscuit.new bis.stub(:users) { users } ... end end end
i run rspec follows:
rspec -i . ./spec/lib/user_alerts_spec.rb
what should rspec pick module??
Comments
Post a Comment