require "spec_helper"

describe "Payment" do

	let(:customer) { create :customer }

	trade{page}

	it "with valid card, should update the uri of customer" do

		login_as_user customer 
		click_link "new_payment"

		fill_in "Card number", with: "4111111111111111"
		fill_in "Expiration month", with: "03"
		fill_in "Expiration year", with: '2014'
		click_button "Save Details"

		current_path.should eq home_path
	end

	describe "with invalid card, should show error" do
		before do
			login_as_user customer 
			click_link "new_payment"

			fill_in "Card number", with: "4111111111111001"
			fill_in "Expiration month", with: "03"
			fill_in "Expiration year", with: '2014'
			click_button "Save Details"
		end

		it{ current_path.should eq create_card_payment_payments_path }
		it{ should have_content "Invalid card details." }
	end
end