Module: FbGraph::Mock
- Defined in:
- lib/fb_graph/mock.rb
Instance Method Summary collapse
- #mock_fql(query, response_file, options = {}) ⇒ Object
- #mock_graph(method, path, response_path, options = {}) ⇒ Object
- #request_to(path, method = :get) ⇒ Object
Instance Method Details
#mock_fql(query, response_file, options = {}) ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/fb_graph/mock.rb', line 27 def mock_fql(query, response_file, = {}) [:params] ||= {} [:params].merge!(:q => query) stub_request(:get, FbGraph::Query.new(query).endpoint).with( request_for(:get, ) ).to_return( response_for(response_file, ) ) if block_given? response = yield a_request(:get, FbGraph::Query.new(query).endpoint).with( request_for(:get, ) ).should have_been_made.once response end end |
#mock_graph(method, path, response_path, options = {}) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/fb_graph/mock.rb', line 6 def mock_graph(method, path, response_path, = {}) stub_request( method, endpoint_for(path) ).with( request_for(method, ) ).to_return( response_for(response_path, ) ) if block_given? response = yield a_request( method, endpoint_for(path) ).with( request_for(method, ) ).should have_been_made.once response end end |
#request_to(path, method = :get) ⇒ Object
44 45 46 47 48 49 |
# File 'lib/fb_graph/mock.rb', line 44 def request_to(path, method = :get) raise_error(WebMock::NetConnectNotAllowedError) { |e| e..should include("Unregistered request: #{method.to_s.upcase}") e..should include(endpoint_for path) } end |