require "slidepay" require "spec_helper" describe SlidePay::AccountReport do def request_params(data) return { path: "report/account", data: data, token: nil, api_key: nil, endpoint: nil } end def sfa(location_id) [field: "location_id", condition: "equals", value: location_id] end def search_filter_data(location_id) return { csv: false, email_address: nil, html: false, raw_data: true, sfa: sfa(location_id) }.to_json end it "should be a post report" do r = SlidePay::AccountReport.new() expect(r.report_type).to eq(:post) end it "should be retrieve from the account_report url" do r = SlidePay::AccountReport.new() expect(r.url).to eq('report/account') end describe "initialize" do it "should interpret a string as a location_id" do location_id = "12" r = SlidePay::AccountReport.new(location_id) request_info = request_params(search_filter_data(location_id)) SlidePay.should_receive(:post).with(request_info).and_return(a_response_object) r.retrieve() end it "should interpret an integer as a location_id" do location_id = 12 r = SlidePay::AccountReport.new(location_id) request_info = request_params(search_filter_data(location_id)) SlidePay.should_receive(:post).with(request_info).and_return(a_response_object) r.retrieve() end it "should take a hash with a string for a key" do location_id = 12 r = SlidePay::AccountReport.new({ "location_id" => location_id }) request_info = request_params(search_filter_data(location_id)) SlidePay.should_receive(:post).with(request_info).and_return(a_response_object) r.retrieve() end it "should take a hash with a symbol for a key" do location_id = 12 r = SlidePay::AccountReport.new(location_id: location_id) request_info = request_params(search_filter_data(location_id)) SlidePay.should_receive(:post).with(request_info).and_return(a_response_object) r.retrieve() end end end