Category: ruby

  • Hooking in an LDAP Test Server to Cucumber Tests

    I managed to get a custom Devise strategy with LDAP working, but had no clear way of automating tests. I wanted to validate if I still had to keep the password fresh in the database, and needed to be able to write scenarios around that in case someone attempted to refactor out the code. After…

  • devise_ldap_authentication for your domain email on top of database_authenticatable

    I have a devise user model named LoginUser whose authentication key is :login. I want normal users of the system to be database_authenticatable. However, I want to be able to authenticate previously added users via internal LDAP. Furthermore, I didn’t want the underlying database_authenticatable password to be used or to expire on me (also using devise_security_extensions).…

  • Monkey patching if you need to force an error in delayed_job

    I wanted to force an error condition in my cucumber tests, but the code ran through a DelayedJob, so I couldn’t redefine the code running under the .delay chain, because the DelayedJob worker will reload the normal code base for its processing. I finally realized that simply patching the delay instance method to return self…