[rspec-users] Test for a gem/plugin?

Matt Wynne matt at mattwynne.net
Wed Dec 10 13:08:23 EST 2008

On 10 Dec 2008, at 16:26, James Byrne wrote:

> James Byrne wrote:
> Of course, the last example should have been:
> When /user is authenticated/ do
>  # We use Authlogic for authentication so just test that gem is loaded
>  assert defined?("Authlogic")
> end

To verify that the user has been authenticated, why not try something  

Then /I should see that I am logged in/ do
   user = User.first
   response.should include_text "welcome, #{user.username}"

This is much less coupled to your implementation, though it does  
assume that the 'I' referred to in the step is the only User in your  
database, or at least happens to be the first one. I'll leave it as a  
exercise to the reader to work around that one.

Matt Wynne

More information about the rspec-users mailing list