Sign in through GitHub

Please read for an updated status on RailsCasts:

Learn more or hide this

Gustavo Delfino's Profile

GitHub User: gdelfino

Site: http://gdsolutions.com.ve

Comments by Gustavo Delfino

Avatar

After, pulling my hair for a few hours, this is how I am testing it:

ruby
it 'does not creates a new subscription if stripe fails to create a token' do
  exception = Stripe::InvalidRequestError.new("",{})
  Stripe::Customer.should_receive(:create).and_raise(exception)
  expect {
    post :create, subscription: valid_attributes
  }.to change(Subscription, :count).by(0)
end

The tricky part was creating the exception, I had to take a look at this