Displaying 20 results from an estimated 2000 matches similar to: "mocking singletons"
2013 Jan 20
1
[LLVMdev] Get the value of a GlobalVariable
Hi,
I am executing a C program using JIT. When the program exits, the control
comes back to my program which initiates the JIT. Now, I want to read
the value(not the LLVM nomenclature) of a global variable (not the LLVM
nomenclature). I am able to get the global variable, using the following
command:
GlobalVariable *my_global = Mod->getNamedGlobal("MY_GLOBAL");
I want to know the
2006 Jul 25
3
Question about how Mongrel process works with singletons
Hi,
I have a controller where I access a singleton class that I use to
connect to a DRbprocess
DrbConnector.instance.some_method
I notice that on every request, the constructor is called so it is
making a new instance of this singleton. Is this normal?
Thanks,
Curtis
2006 Jul 03
6
Req: Workers as singletons
Hi,
it would be nice to be able to specify workers as singletons. By this
I mean that every call to the new_worker method returns the same
instance of said worker. This can be done transparently either by
adding a new argument to new_worker (something like :singleton =>
true) or adding a new method, like I did in my installation of
BackgrounDrb:
def get_worker_by_class(klass)
2005 Mar 30
2
Beginner question: serverside singletons?
Hello all, just started tinkering with Rails after reading all the hype about
it. I''m a raw novice with Ruby and (obviously) Rails, but have extensive
experience with serverside Java (J2EE stack, Tapestry, etc). Rails looks
cool, though embedding Ruby code in HTML reminds me unpleasantly of JSP +
Struts and I''m deeply suspicious of all the behind-the-scenes magic going on
in
2007 Jul 16
4
Set the return value to "same as block"
It would be good to be able to set the return value to be the same as
the return value of the block. I am trying to test opening a file in a
block and reading from it. It would be nice to use code like this:
object.stubs(:open).with("/path/to/file", "r").yields(
stub(:read => "The file contents")
).returns(from_block)
Which would make open() take the return
2007 Oct 25
4
Insure a method is called with no arguments.
We''ve been working with the ParameterMatchers (so cool!) but I don''t
see a way to insure a method is called with no arguments.
I imagined something like:
user = mock(''User'')
user.expects(:friends).with(nothing)
Anyone run into this?
2006 Sep 08
1
A quick guide to Mocha
Hello :)
Having just gone through the (admittedly simple) API of Mocha to learn
how it works, I wrote a quick guide (190 lines) to help others get up to
speed. I''ve attached it as RDOC and as HTML.
It is a first draft - please help me improve by giving feedback !
Contents :
Overview - Quick overview of Mocha
Unit testing, mock object and stubs - Very quick introduction to mock
2007 Mar 13
1
Opening the singleton class of mocked objects
I wrote a plugin [1] a while ago that lets me do validations on a
single AR instance. Instead of defining validations in an AR class, I
can define them on a AR instance''s singleton class:
class << @video
validates_presence_of :title
end
One of my specs mocks Video.find, and the above code is run on the
mock object. When I run the spec, I get the expected
undefined method
2012 Mar 16
2
Singleton pattern
Hi all,
I know it may not have much sense thinking about a Singleton Pattern in an
R application which doesn't use any OOP facilities, however I'm curious to
know if anybody faced the same issue. I've been googling but using
"singleton pattern" as a key word leads to typical OOP languages like Java
or C++ among others.
So my problem is that I'd like to ensure some very
2012 May 24
4
Manually modifying an hclust dendrogram to remove singletons
Dear R-Help,
I have a clustering problem with hclust that I hope someone can help
me with. Consider the classic hclust example:
hc <- hclust(dist(USArrests), "ave")
plot(hc)
I would like to cut the tree up in such a way so as to avoid small
clusters, so that we get a minimum number of items in each cluster,
and therefore avoid singletons. e.g. in this example, you can see
2008 May 28
3
Mocking objects to test Rails Controllers
Hi all,
I''m currently considering the use of Mocha to aid in writing my Rails
unit/functional tests.
I currently have a Rails model which mixes in a series of methods to
allow it to talk to an external service. The code is roughly of this form:
class Person < ActiveRecord::Base
include SMSNotifier
def send_notification(message)
send_sms(number,message)
#
2006 Aug 15
7
Trying to Overide Class Object Methdos For Testing
Hi,
I thought I had a handle on the whole singleton class thing but now I''m
not too sure.
I have a class definition:
class ValidationMaster
def validate(params)
# complex and time consuming validation
# returns true on success, raises Exception
# on failure
end
end
Okay, so when I''m running my functional tests within rails, I want to be
able to control how
2007 Mar 18
5
Automatically mocking ActiveRecord methods
Seems like I do a fair amount of mocking ActiveRecord''s automatically
generated routines when I''m testing controllers. Things like:
@portalspace = PortalSpace.new :public_readable => true,
:public_writable => true, :name => ''public''
@portalspace.stubs(:id).returns(203)
PortalSpace.stubs(:find).with(203).returns(@portalspace)
2006 Oct 16
4
Singleton Pattern in RoR
Hi all
how can I implement the singleton patter in RoR?
thanks
--
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this
2006 May 22
2
using Singleton with Prototype
Hello all. I''m writing my own object using prototype and I
wonder how you write and call only one instance of class. Can
anyone share his idea of singleton?
thanks
Gregor
----------------------------------------------------
Gdy nadchodzi przełomowy moment w historii, musisz zdecydować,
po czyjej stronie będziesz.
"X-Men: Ostatni bastion" - w kinach od 26 maja.
2006 Aug 23
5
Singleton-like Worker
Hello there,
I need a Worker Class to be Singleton-like, that means there must be at
maximum one Instance at a time. When a new Request is made to create another
worker of this type, it should return and wait for the other instance to be
destroyed.
what i need to do: i have a worker who needs to do sth with java and
openoffice, and it seems when i have more tha one worker simultaneously,
2007 Jun 17
2
Testing a call to super
Hi,
Is there or could there be any way to test that a method calls "super"?
Thanks
--
Jonathan Leighton, Web Developer
http://jonathanleighton.com/
2009 Oct 08
4
[LLVMdev] Is ExecutionEngine always meant to be a singleton?
Right now, on X86, creating multiple ExecutionEngines in the same
process causes an assertion.
If it's supposed to always be a singleton, should there be a way to
get the process's ExecutionEngine instance?
This would, among other things, allow "lli" to execute bitcode that
itself uses the ExecutionEngine.
2008 Jun 04
2
Mock with an attributes that has state
I''m developing a rails application. I have an Order model that has_many
OrderItems.
I mocked the OrderItem model in my Order specs using mock_model. I thought
I should focus my specs on each model and always mock associated models.
In my Order model I need a way to merge OrderItems which have the same cost
and same product_id. That I can spec.
The other thing this merge helper
2007 Mar 06
15
mocking missing methods
Hi folks.
So I''m using mocha on a ruby project, and I really like it. One thing
I''ve noticed is that it can be a bit "surprising" when I''m mocking
methods that don''t exist on an object, and I think there''s an easyish fix.
At the moment, you use sheep = mock() to create a mock sheep. What I''d
like to do is something like sheep =