Displaying 20 results from an estimated 600 matches similar to: "dynamic mock object anyone?"
2007 Jan 02
4
allow stubbing of previously defined methods such as "id"
On my current project I needed to create a stub that responded
correctly to the id message. Here''s the change I put into my copy of
head.
Index: lib/mocha/mock_methods.rb
===================================================================
--- lib/mocha/mock_methods.rb (revision 1114)
+++ lib/mocha/mock_methods.rb (working copy)
@@ -68,6 +68,7 @@
method_names =
2007 Mar 04
4
Rails functional testing and Mocha
I''ve always wanted to be able to do stuff like this in my functional
tests
c = customers(:customer_1)
c.expects(:great_customer_service)
post :service_customer, :id => c.id
This of course fails because inside the rails action a different
instance of customer is used. Some of the time setting your
expectation/stubbing on Customer.any_instance works, but it''s not
2005 Jun 09
8
RDoc Dashboard Widget
Hi everyone - sorry if this is a bit OT, I''m not subscribed to the
''ruby-talk'' list, but if anyone wants to cross post this over there...
This is just a quick announcement to let people know that I''ve built a
basic RDoc Dashboard widget for Mac OS X Tiger. It''s still beta-ish,
but seems to work okay for me - and it''s a convenient reference
2007 Mar 30
7
problem with using any_instance
Hey all,
I have a question with using mocha in my tests.
In the same test file, I have two tests,
<code>
def test_a
klass.any_instance.stubs(:method_name).returns("something")
klass.new.method_name
...
end
def test_b
...
klass.new.method_name
...
end
</code>
where klass is some class
when the tests run, test _a passes, but test_b had an error like this:
2006 Aug 06
2
help with method_missing in ActiveRecord
I am serializing a data object (FooData) into an ActiveRecord column (Foo).
I''d like to be able to do delegate methods to the data class if the Foo
class doesn''t have that attribute. So instead of:
f = Foo.new
f.data.item1
I''d like to do:
f = Foo.new
f.item1
I was hoping that I could add a method_missing method to my Foo class and
call methods in the FooData class
2006 Aug 09
2
How do you define a method
Hi all,
I was wondering if anybody could help me figure why a view cannot find a
method that I defined in another class. I do this in the view: (let''s
say index.rhtml)
<%= check_box("item_search_page", "method_name")
Here, item_search_page is a variable in the view''s controller, which
creates a new ItemSearchPage object. And I defined
2006 Mar 19
3
How can I access an attribute via a symbol?
In my model I''d like to write a method that accesses the attributes by
name. A very simple implementation would be
class MyModel < ActiveRecord::Base
def get_value(attribute)
return value_of_attribute
end
end
Then I can call it with m.get_value(:name) to get the value of the
name column in the db. I''m not sure what to put in for
2006 Jun 26
4
why can''t I call this without parentheses?
I have a little helper that lets me add legacy fields to models where
they have common prefixes, suffixes, or something else weird. Here is
the method signature:
def legacy_fields(options = {}, *attributes)
.....
end
options is a hash containing things like :prefix => "post_" - and
attributes is a list of attribute names. This gets mixed into the
class with extend, so I call
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) "
2004 Dec 29
2
icecast2.2 and aac?
Trying to get the LE version for months now, still treamguys can?t
deliver....
Regards,
Dennis Heerema
-----Original Message-----
From: "Greg J. Ogonowski" <greg@orban.com>
To: qiang Bao <jakobao@yahoo.com>, icecast@xiph.org
Date: Wed, 29 Dec 2004 11:08:04 -0800
Subject: Re: [Icecast] icecast2.2 and aac?
Icecast 2.2 works fine with AAC/aacPlus at any bitrate.
32kbps
2006 Apr 27
12
how to do a count with a variable...
hi guys, got this problem...
in my controller, when i wanna do a @temp.count it fails...
then i went to try counter = @temp.count which also failed..
thus, i feel that the count is not available for ActiveRecord::Base..so
i went to the Model class eg. user.rb
so in user.rb :
...
def count_uesr
count = 0
self.each do |record|
count ++
end
return count
end
then it ended up having
2006 Apr 18
7
Functional test, pls help!!!!
Hi guys, recently encountered this funny problem which i really dunno
wat happen...
I have been trying on it for the past few days and just doesnt work.Hope
you guys can give me some enlightenment.
Problem:
The functional test doesnt seems to be able to recognise one of my
model, and when i run the test, it keeps giving me the error of"You have
nil object when you don''t expect
2005 Feb 04
2
how to generate a function from a linear model
Hi All,
I am trying to generate a function from a linear model. I think there
should be build-in function that perform this action but I've had no
luck finding it.
For example, I have a model created using lm().
model <- lm(sat.d~1+sat.n+I(sat.n^2))
What I would like to have is a function (similar to the one generated
by splinefun()) so that I can use it on different data-sets.
2007 Dec 08
6
Rails 2.0 ActionMailer breaks my redmine render_message
I am using ''redmine'' (v 0.6) as my major project manager, seems running
fine w Rails 2.0 (slight modifs for paginations..) but I am stuck with a
major error when sending a confirmation email :
mailer.rb
class Mailer < ActionMailer::Base
....
# Renders a message with the corresponding layout
def render_message(method_name, body)
layout =
2006 Jun 07
4
WEBrick wouldnt start....
hi guys, just did a search and cant find anything helpful..
suddenly my WEBrick cant start.... omg.... dunno wat''s wrong with it
that''s wat i typed :
......$ruby script/server
=> Booting WEBrick...
......$
that''s all... i dont even know wat''s wrong and when i did a ps -F -C
ruby, i also couldnt find anything.....
did i jsut corrupt the file or wat???
2005 Apr 05
5
R can not show plots (in Mac OS X terminal)
Dear all:
I am a newbie in Mac. Just installed R and found R did not react on my
command plot (I use command line in terminal). It did not give me any
error message, either. All it did was just giving out a new command
prompt--no reaction to the plot command. I suppose whenever I gives out
a command of plot, it will invoke the AquaTerm for a small graph, as I
experience in octave. What can I
2004 Dec 29
3
icecast2.2 and aac?
it seems that icecast 2.2 can only stream aac at 128kbps!
mp3 and ogg are ok at all bitrates.
is it a bug or my config wrong?
---------------------------------
Do you Yahoo!?
Jazz up your holiday email with celebrity designs. Learn more.
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
2009 Apr 13
4
Creating Methods in the Model?
Hey Everyone.
First day diving in to ROR and Ruby...
My question is how do you define methods with in the model class and/or
should I even be doing this?
It is my understanding that you should put as much of the business logic
into the model as possible. I want to do some data manipulation before
I things are submitted to the database
IE (Create a variable out of two submitted via form, as
2005 Jun 13
1
RDoc Dashboard Widget v1.2
Hi all,
This is just another quick email to let everyone know that I''ve
updated the RDoc Dashboard Widget to fix all the reported bugs and add
most of the requested features. The changes include:
* Bug fixes for erratic scrolling and ''stuck'' navigation panes
* The ability to have multiple instances of the RDoc widget on your
dashboard
* Bookmarking functionality for
2006 Jun 03
12
How to get dynamically created inputs from html form back to rails app
Thank you in advance.
Although I have many years of experience in general, including cross-
platform processing, I am not an HTML/Javascript programmer. As a
result, I do not have certain specific baseline skills and/or knowledge
that are presumed in the Rails and Ajax documentation.
I am experienced with DOM manipulations, so the bare mechanics of
manipulating the browser GUI via Javascript