Given /^the user "(.+)" has the following categories to follow$/ do |user_name,table| person = User.find_by(:login => user_name).person table.hashes.each do |category| Circle.create!(:person => person, :name => category[:name]) end end Then /^"(.+)" should be a follower of "(.+)" (?:with no category|with category "(.+)")$/ do |person, profile, category| profile = Profile.find_by(identifier: profile) followers = profile.followers person = Person.find_by(identifier: person) followers.should include(person) # TODO fix profile follower follower if category ProfileFollower.find_by(:follower => person, :profile => profile).follow_category.name.should == category else ProfileFollower.find_by(:follower => person, :profile => profile).follow_category.should == nil end end Then /^"(.+)" should not be a follower of "(.+)"$/ do |person, profile| profile = Profile.find_by(identifier: profile) followers = profile.followers person = Person.find_by(identifier: person) followers.should_not include(person) end Given /^"(.+)" is a follower of "(.+)" (?:with no category|with category "(.+)")$/ do |person, profile, category| profile = Profile.find_by(identifier: profile) person = Person.find_by(identifier: person) params = {:follower => person, :profile => profile} # TODO fix profile follower follower if category category = Circle.find_by(:name => category, :person => person) params.merge!({:follow_category => category}) end ProfileFollower.create!(params) end