require 'fakeweb' def mock_pages @mock_pages ||= begin mock_pages = {} Dir.glob("#{File.join(File.dirname(__FILE__), 'sample_pages')}/*.html").each do |sample_html| page_name = sample_html.split(/\//).last.gsub(/\.html$/,'').downcase.tr_s(' ', '_').to_sym mock_pages[page_name] = File.read(sample_html) end mock_pages end end def mock_seller_central_page_results! FakeWeb.allow_net_connect = false FakeWeb.register_uri(:any, 'https://sellercentral.amazon.com/', :response => mock_pages[:seller_central]) FakeWeb.register_uri(:any, 'https://sellercentral.amazon.com/gp/homepage.html', :response => mock_pages[:seller_central_redirect]) FakeWeb.register_uri(:post, 'https://sellercentral.amazon.com/gp/sign-in/sign-in.html', :response => mock_pages[:seller_central_homepage]) # Feedback FakeWeb.register_uri(:get, 'https://sellercentral.amazon.com/gp/feedback-manager/home.html/ref=ag_feedback_mmap_home', :response => mock_pages[:feedback_manager]) FakeWeb.register_uri(:get, 'https://sellercentral.amazon.com/gp/feedback-manager/view-all-feedback.html?ie=UTF8&sortType=sortByDate&dateRange=&descendingOrder=1', :response => mock_pages[:feedback_page_1]) FakeWeb.register_uri(:get, 'https://sellercentral.amazon.com/gp/feedback-manager/view-all-feedback.html?ie=UTF8&sortType=sortByDate&pageSize=50&dateRange=¤tPage=2&descendingOrder=1', :response => mock_pages[:feedback_page_2]) FakeWeb.register_uri(:get, 'https://sellercentral.amazon.com/gp/feedback-manager/view-all-feedback.html?ie=UTF8&sortType=sortByDate&pageSize=50&dateRange=¤tPage=3&descendingOrder=1', :response => mock_pages[:feedback_page_last]) # Inventory FakeWeb.register_uri(:get, 'https://sellercentral.amazon.com/gp/ezdpc-gui/inventory-status/status.html/ref=ag_invmgr_mmap_home', :response => mock_pages[:listings_page_1]) FakeWeb.register_uri(:get, 'https://sellercentral.amazon.com/gp/ezdpc-gui/inventory-status/status.html/ref=ag_invmgr_mmap_home&searchPageOffset=2', :response => mock_pages[:listings_page_2]) FakeWeb.register_uri(:get, 'https://sellercentral.amazon.com/gp/ezdpc-gui/inventory-status/status.html/ref=ag_invmgr_mmap_home&searchPageOffset=3', :response => mock_pages[:listings_last_page]) FakeWeb.register_uri(:post, 'https://sellercentral.amazon.com/myi/search/ProductSummary', :response => mock_pages[:update_inventory_result_from_page_1]) FakeWeb.register_uri(:post, 'https://sellercentral.amazon.com/myi/search/ProductSummary;jsessionid=455FF454220CA14A5D06A565555A0450', :response => mock_pages[:update_inventory_result_from_page_1]) end