search for: undef_method

Displaying 13 results from an estimated 13 matches for "undef_method".

2006 Apr 20
11
dynamic mock object anyone?
Hi guys, got this problem with creating such a thing... hope anyone could help.. the problem: ok, now i have this mock object that would simulate a external rpc call. eg require ''models/xmlrpc_agent'' class XmlrpcAgent def create(params) 200 end end but the value of the value returned is fixed. which is quite hard for me to test the controller when different
2006 Nov 22
2
.class call to the mock object (or any existing methods)
Hi I run into problem trying to set expectations for the mockobject.class method, I had to undefine a method before I could set some expectation. Is there any better way of doing it? object = mock() .... klass = class <<object; self; end klass.send(:undef_method, "class") # I had to do this because Mocha utilizes "method_missing(symbol, *arguments, &block) " method. object.expects(:class).returns(SomeClass) ... And thanks for such a nice library. ------------------------------ Kurman Karabukaev Application Developer ThoughtWork...
2008 Feb 02
0
Adding methods to Object in Rails -- WARNING
...tually AssociationProxy objects pretending to be some other object. The reason is that AssociationProxy removes all but a few methods from itself. You will find this line at the top of vendor/rails/activerecord/lib/active_record/associations/association_proxy.rb instance_methods.each { |m| undef_method m unless m =~ /(^__|^nil\?$|^send$|proxy_)/ } This happens before the files in initializers gets loaded. And that is where I added Object#wrap. So, for a proxied object, it would call Object#wrap instead of the specialized wrap that I had defined in my class. My solution to this was to do this:...
2007 Jan 02
4
allow stubbing of previously defined methods such as "id"
...ng copy) @@ -68,6 +68,7 @@ method_names = method_names.is_a?(Hash) ? method_names : { method_names => nil } method_names.each do |method_name, return_value| expectations << Stub.new(self, method_name, backtrace).returns(return_value) + self.metaclass.send :undef_method, method_name if self.metaclass.method_defined? method_name end expectations.last end Index: test/mocha/auto_verify_test.rb =================================================================== --- test/mocha/auto_verify_test.rb (revision 1114) +++ test/mocha/auto_verify_tes...
2006 Jun 05
1
file_column & RMagick
...ng file_column. This was working great, for about an hour, but all of the sudden I began to get the following error (only when i attempt to resize). NameError (undefined method `assoc'' for class `Magick::ImageList''): /usr/local/lib/ruby/site_ruby/1.8/RMagick.rb:1002:in `undef_method'' /usr/local/lib/ruby/site_ruby/1.8/RMagick.rb:1002 /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:21:in `require'' /usr/local/lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active_support/dependencies.rb:147:in `require'' /vendor/plugins/trunk/lib/magick_...
2011 Jul 14
0
subclasses with inherited_resources?
I''m trying out inherited_resources and so far so good. However, one problem I''ve run into is that it''s very difficult to customize inherited_resource behaviour in subclasses. Looking through the source I see it uses things like undef_method and class_attribute. For example, if I have the following controllers: class ItemsController inherit_resources actions :new, :create def create # custom stuff here creat! end end class VideoController < ItemsController actions :new, :create, :show end videos controller wi...
2007 Mar 04
4
Rails functional testing and Mocha
...self.class.any_instance_with_id( self.id) any.expectations.each do |e| method = stubba_method.new(stubba_object, e.method_name) $stubba.stub(method) e.mock = self.mocha self.mocha.expectations << e self.mocha.__metaclass__.send(:undef_method, e.method_name) if self.mocha.__metaclass__.method_defined? (e.method_name) end end end end end There''s also one or 2 places where i''ve made attributes writable/ readable on Expectation etc... to get this all to hold together. Limitations: - The big l...
2005 May 04
0
New win32-dir
...result = SHGetSpecialFolderPath.call(0, path, const, 0) end if result != 0 path = nil else path.gsub!(/\000/, '''') path.strip! end path end module_function :cget end class Dir include Win32 undef_method :cget # Not meant to be public DESKTOP = Win32.cget(CSIDL_DESKTOP) INTERNET = Win32.cget(CSIDL_INTERNET) PROGRAMS = Win32.cget(CSIDL_PROGRAMS) CONTROLS = Win32.cget(CSIDL_CONTROLS) PRINTERS = Win32.cget(CSIDL_PRINTERS) PERSONAL = Win32.cget(CSIDL_PERSONAL)...
2007 Jul 30
4
Win32 namespace
I''ve been working on a library called ruby-wmi, that is basically just an abstraction layer around wmi. I''m a windows sys admin, and I use wmi scripts a lot at work. My code looks like this: disks = WMI::Win32_LogicalDisk.find(:all, :conditions => {:drivetype => 5}) It''s supposed to mimic the active_record interface, and it works pretty well. My next thought
2006 Mar 10
0
WEBrick crashing
...1 0.00 0.00 Object#require 0.00 6.55 0.00 1 0.00 0.00 Array#select 0.00 6.55 0.00 3 0.00 0.00 String#empty? 0.00 6.55 0.00 3 0.00 0.00 Kernel.== 0.00 6.55 0.00 96 0.00 0.00 Module#undef_method 0.00 6.55 0.00 1 0.00 0.00 WEBrick::HTTPRequest#body 0.00 6.55 0.00 1 0.00 0.00 ActionController::Base#all ow_concurrency 0.00 6.55 0.00 1 0.00 0.00 ThreadGroup#list 0.00 6.55 0.00 1 0.00 270...
2006 Mar 26
4
edge and 1.8.2/1.8.4 issues
I recently upgraded to 1.8.4 to try out mongrel, and so far have been in a kind of hell where I can''t get my app working! Currently running (or trying to run): Ruby version 1.8.4 (i386-mswin32) RubyGems version 0.8.11 Rails version 1.0.0 Active Record version 1.13.2 Action Pack version 1.11.2 Action Web Service version 1.0.0 Action Mailer version 1.1.5 Active Support version
2010 May 06
5
Garbage collection outside of request cycle?
I''ve been analyzing our Unicorn-powered Rails app''s performance, and have found that garbage collection is a big factor in slow requests. In the interest of avoiding those performance hits while handling requests, would it be possible to have a unicorn worker run garbage collection after handling a request and before waiting for the next one? Would this be a good idea? Cheers,
2008 Mar 17
8
should have_tag outside Rails
Hi Google has not helped me here. I''m looking for a way to use the have_tag assert_select wrapper outside RSpec on Rails (but in a Rails project) so I can use it to check text strings. Has anyone managed this? Thanks Ashley -------------- next part -------------- An HTML attachment was scrubbed... URL: