RailsApps / rails-stripe-membership-saas

An example Rails 4.2 app with Stripe and the Payola gem for a membership or subscription site.
http://railsapps.github.io/rails-stripe-membership-saas
1.14k stars 232 forks source link

Update user_spec to account for pre-existing Roles in database #68

Closed Austio closed 11 years ago

Austio commented 11 years ago

Updated user_spec to store the number of initial roles in the database before FactoryGirl creates 2 additional ones. Then we check for the number of roles after the @user role is changes for the number we had before plus the number that we have added (@number_of_initial_roles + 2)

DanielKehoe commented 11 years ago

Thanks @tmock12. I'll wait for clarification from @Austio before accepting.

Austio commented 11 years ago

@danielkehoe and @tmock12 you are correct, this was because i removed the database cleaner and needed to deal with having users in the database already.

tmock12 commented 11 years ago

Instead of storing the Role count in an instance variable it would be better to use Rspecs expect methods. Something like:

   it "wont remove original role from database" do
       expect { @user.update_plan(@role2) }.to_not change(Role.count)
   end
Austio commented 11 years ago

I agree and if you think this/your rspec addition is valuable enough to add please feel free. If not, no biggie