I have an application that has a User model, and users have different roles. The roles are represented internally as integer indexes, but are presented to the user as strings. I also have a helper function access_level (in application_controller.rb - is that a sensible place for it?) that takes either the integer index or the string representation and returns a hash of loads of information about the role (including the string representation and the index, so this is a convenient way of converting between them). In case it matters, access_level depends in turn on role definitions defined in a file in config\initializers.
Because the interface presented to the user depends on the role, my tests have lots of things like Given I have the role of administrator and such like. I'm trying to create the user with FactoryGirl.create(:user, role: access_level(role).index) but I can't get Cucumber to see access_level.
Most of the advice I find by Googling this says "don't do that" because calling functions behind the scenes violates the principle of keeping Cucumber at the UI level, but I can't see a way of testing this user behaviour without Cucumber knowing how to map role names to indexes. I could duplicate access_level in one of my Cucumber support files, of course, but that violates DRY. So how should I structure this in such a way as to be able to test it cleanly in Cucumber?