--- !ruby/object:RI::ClassDescription attributes: - !ruby/object:RI::Attribute comment: name: mocked_class rw: R class_methods: - !ruby/object:RI::MethodSummary name: echo - !ruby/object:RI::MethodSummary name: keys - !ruby/object:RI::MethodSummary name: mock - !ruby/object:RI::MethodSummary name: mocks - !ruby/object:RI::MethodSummary name: spin comment: - !ruby/struct:SM::Flow::H level: 1 text: Mock Object - !ruby/struct:SM::Flow::P body: A straightfoward mocking facility. Typically used in test cases. The Mock class offers a few constructors for quickly building mockups. - !ruby/struct:SM::Flow::VERB body: " mock - Returns a static reponse.\n echo - Returns the arguments passed-in.\n spin - Returns a rotation of responses.\n keys - Returns an index of responses.\n" - !ruby/struct:SM::Flow::P body: Mock classes can be built from sratch or partially framed against other classes. - !ruby/struct:SM::Flow::H level: 3 text: Usage - !ruby/struct:SM::Flow::VERB body: " class ContextMock < Mock\n mock :response_headers, {}\n spin :host_url, ['http://www.nitrohq.com','http://www.rubyforge.com']\n end\n\n ctx = ContextMock.new\n ctx.response_headers['location'] = url\n ctx.host_url #=> "http://www.nitrohq.com"\n ctx.host_url #=> "http://www.rubyforge.com"\n" - !ruby/struct:SM::Flow::P body: Or - !ruby/struct:SM::Flow::VERB body: " class ContextMock < Mock(Context)\n ...\n end\n" constants: - !ruby/object:RI::Constant comment: - !ruby/struct:SM::Flow::P body: "Certain methods are not mocked:" - !ruby/struct:SM::Flow::VERB body: " inspect (tricky)\n class (delegated)\n kind_of? (delegated)\n is_a? (delegated)\n instance_of? (delegated)\n method (works as-is)\n send (works as-is)\n respond_to? (works as-is)\n hash (no way to mock)\n\n id, call, etc. (not meant to be mocked, ever!)\n" name: UnmockedMethods value: "%r{^( |inspect |kind_of\\?|is_a\\?|instance_of\\?|class |method|send|respond_to\\? |hash |__ )}x" full_name: Quarry::Mock::Object includes: [] instance_methods: [] name: Object superclass: OpenStruct