Project

superdupe

0.0
Repository is archived
No commit activity in last 3 years
No release in over 3 years
SuperDupe is a fork of the originally Dupe and rides on top of ActiveResource to allow you to cuke the client side of a service-oriented app without having to worry about whether or not the service is live or available while cuking.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Runtime

 Project Readme

SuperDupe

SuperDupe provides two things:

  • Mock ActiveResource objects like the originally gem dupe
  • Superdupe send no requests to external services registerd by the ARes. It has an extra parameter to send explicitly extrnal requests.

SuperDupe is a fork of the originally gem dupe 0.5.1 (Matt Parker). At first, the gem try to use only the available mocked resources. If you have the requirement to send external requests without mocking, take an extra parameter for this situation.

Install the gem

gem install superdupe

Usage

Implemented ActiveResource class class Customer < ActiveResource::Base self.site = '' end

Register a mock response Dupe.create <class_name>, Dupe.create Customer, :name => 'test customer'

Find a registered object Customer.find 1

Find all registered objects Customer.find :all

Find registered url patterns Dupe.network.mocks[] Dupe.network.mocks[:get]

Reset registered url patterns Dupe.reset

Register a custom mock with a param-filter Get %r{/customers.xml?state=(active|inactive)} do |state| if state == 'active' Dupe.find(:"Customers") {|c| c.state == 'active'} else Dupe.find(:"Customers") {|c| c.state == 'inactive'} end end # Register a custom mock with the entered url pattern

Find the custom registered object Customer.find :all, :params => {:state => 'active'}