Displaying 20 results from an estimated 110 matches similar to: "Mocking Time, delegating to original object"
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
2008 Jan 02
2
Proxies
I really like the idea of Mock Proxies as explained in Brian Takita''s post here:
http://pivots.pivotallabs.com/users/brian/blog/articles/352-introducing-rr
I posted to this list eariler with an incomplete implementation of
.stops_mocking in the thread "Mocking Time, delegating to original
object." The Mock Proxy pattern would make this simpler.
2007 Sep 06
1
any reason we can''t use the concise stubs on Object
I like the concise version of stubs available on true mocks:
=> #<Mock:0x32f76d4>
>> foo.stubs(:one => ''hi'', :two => ''again'')
=> {:one=>"hi", :two=>"again"}
Why can''t we do it on ''real'' objects?
>> foo = Object.new
>> foo.stubs(:method1 => ''a'',
2006 Dec 21
1
need some guidance with a test
This is part of a rails project. The following method is part of the Ams
class (a rails model). I''m a bit unsure of the rspec/bdd way of testing this
method.
def persist_as_domains
@current_domains.each do |d|
dom = Domain.new
dom.domain = d
dom.source_id = 1
dom.at = Time.now
dom.save
end
end
The following is what came out when I tried to write my test. Notice
2006 Apr 10
0
Inheriting data from one model to another
Hello
I''ve been struggling with something for hours that I thought would be
a simple job. Hopefully somebody can shed some light on what I''m
trying to do :o)
First of all I''ll explain what I''m trying to achieve. In a store
application I want to have products and product variations. A product
variation should inherit all of its properties from product unless
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
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 =
2006 Aug 06
0
view cannot see the method...:(
Hi all,
I just can''t figure why the view cannot find a method that I defined in
another class. I do this in the view:
<%= check_box("item_search_page", "method_name")
Here, item_search_page is a variable in the controller, which creates a new
ItemSearchPage object.
class ItemSearchPage
def method_name
end
end
So, although I defined it and it''s
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:
2005 Dec 18
0
Extending AR::B to provide translations
Hi all,
I want to extend AR::B is such a way as to be able to support and
display different language versions of objects. I know of and have
tried Globalize but still want to do this on my own for a multitude
of reasons (the educational value probably being most important).
My table for the objects has columns named like en_name, de_name,
fr_name, en_description, de_description,
2009 May 06
1
How to extend ActionMailer
I wish to extend ActionMailer::Base by method chaining a class instance
variable:
module ActionMailer
class Base
class << self
def method_name
...
What is the magic incantation to accomplish this?
I cannot get this to work with action mailer:
module MyMethods
def self.include(base)
base.alias_method_chain :method_name, :my_method
def
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
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
2007 May 21
0
[1025] trunk/wxruby2/swig: Use Wx::THE_APP constant as global reference to App (as per WxWidgets);
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" /><style type="text/css"><!--
#msg dl { border: 1px #006 solid; background: #369; padding:
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 =
2012 Feb 17
0
HtmlSlicer 0.0.1
How to split HTML content?
Well, the text like:
<p>Ruby on Rails is a next-generation web-framework<br><b>YEAH!</b>And of course Java killer?! :) ©</p>
You can split to a pages in a smart way.
I tried to realize it in a gem for my internal use, and now when it works for my Rails 3.1.3 application, this is enough to make it public.
I
2006 Sep 22
2
foo.expects(:blah).returns(10).then(11) syntax
I recently needed the behavior of my object to change on subsequent
method calls so I added the syntax above.
Here''s the diff of changes I made:
Index: test/mocha/expectation_test.rb
===================================================================
--- test/mocha/expectation_test.rb (revision 854)
+++ test/mocha/expectation_test.rb (working copy)
@@ -95,6 +95,12 @@
2008 Jan 28
6
client first, top down, outside in, etc with rails
I''m starting a new project and I want to try writing the client first. I.e. I want to write my ''views'' first and I would like to mock out all the models in such a way that I can run the site and browse it with the mocked out models. Is it easy to use rspec''s mocking for this sort of thing and has anyone done it before? Does anyone know of a tutorial out there
2019 Aug 23
2
[nbdkit PATCH 3/3] plugins: Add .can_fast_zero hook
Allow plugins to affect the handling of the new NBD_CMD_FLAG_FAST_ZERO
flag, then update affected plugins. In particular, in-memory plugins
are always fast; the full plugin is better served by omitting .zero
and relying on .pwrite fallback; nbd takes advantage of libnbd
extensions proposed in parallel to pass through support; and
v2 language bindings expose the choice to their scripts.
The
2007 Oct 29
2
rspec throws exception (nameError)
Hi,
I''m running Rails 1.2.5 with rspec 1.0.8.
When i runned autotest first time, it complained about this line.
#include ActionView::Helpers::JavaScriptMacrosHelper
in vendor/plugins/rspec_on_rails/lib/spec/rails/dls/behaviour/helper.rb
...I commented it out, then I got another error about this line, so I
also commented this out.
#Test::Unit.run = true
in