Module: Ebayr::TestHelper
- Defined in:
- lib/ebayr/test_helper.rb
Constant Summary collapse
- @@success =
Ebayr.xml(:Ack => "Success")
Class Method Summary collapse
Instance Method Summary collapse
-
#stub_ebay_call!(call, content, &block) ⇒ Object
Allows you to stub out the calls within the given block.
Class Method Details
.included(mod) ⇒ Object
6 7 8 9 10 11 12 |
# File 'lib/ebayr/test_helper.rb', line 6 def self.included(mod) begin require 'fakeweb' unless const_defined?(:FakeWeb) rescue LoadError throw "Couldn't load fakeweb! Is it in your Gemfile?" end end |
Instance Method Details
#stub_ebay_call!(call, content, &block) ⇒ Object
Allows you to stub out the calls within the given block. For example:
def test_something
stub_ebay_call!(:GeteBayOffficialTime, :Timestamp => "Yo") do
assert Ebayr.call(:GeteBayOfficialTime) # => stubbed call
end
end
This method is deprecated, and will be removed in a future release.
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/ebayr/test_helper.rb', line 23 def stub_ebay_call!(call, content, &block) puts "stub_ebay_call! is deprecated, and will be removed in a future release. Please\nuse Ruby techniques to stub eBay calls your way. See the wiki for details.\n" content = Ebayr.xml(content) unless content.is_a?(String) _allow_net_connect_ = FakeWeb.allow_net_connect? FakeWeb.allow_net_connect = false body = " <\#{call}Response>\n \#{Ebayr.xml(:Ack => \"Success\")}\n \#{content}\n </\#{call}Response>\n XML\n FakeWeb.register_uri(:any, Ebayr.uri, :body => body)\n yield\n FakeWeb.clean_registry\n FakeWeb.allow_net_connect = _allow_net_connect_\nend\n" |