Skip to content

Instantly share code, notes, and snippets.

@tomkersten
Forked from anonymous/gist:57595
Created February 3, 2009 16:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tomkersten/57599 to your computer and use it in GitHub Desktop.
Save tomkersten/57599 to your computer and use it in GitHub Desktop.
def new
#send .nil? then you can stub that on @billing_information
if !user.billing_information.nil?
user.build_billing_information
user.billing_information.first_name = user.first_name
user.billing_information.last_name = user.last_name
user.billing_information.postal_code = user.profile.postal_code
end
define_subscription_details
end
describe "a GET to new without a subscription and without billing information" do
before do
#as_null_object will catch #first_name=, etc so you don't have to stub them all
@billing_information = mock(BillingInformation, :nil? => true).as_null_object
@user.stub!(:subscription).and_return(nil)
# like this
@user.stub!(:billing_information).and_return(@billing_information)
end
it "should get the new subscription page" do
get :new
response.should be_success
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment