Monthly Archives: April 2013

Shared Examples for Testing Session Links

When I was adding tests for user authentication, I noticed an opportunity to DRY up the code a little by moving some duplicate tests into a shared example group. The tests expect to find different links in the header depending on the whether or not a user was signed in: #partials_spec.rb shared_examples "it has signed… Read more »

Adding Dynamic Versions to the Policy Factory

FactoryGirl provides a lot of flexibility when it comes to creating associations, so following their example, TOSBack is using an after(:create) callback to produce some content in the tests that appears to be changing over time: factory :policy_with_sites_and_versions do ignore do sites_count 5 versions_count 5 end after(:create) do |policy, eval| eval.sites_count.times { policy.sites << FactoryGirl.create(:site)… Read more »