similar to: Mock with an attributes that has state

Displaying 20 results from an estimated 600 matches similar to: "Mock with an attributes that has state"

2006 Jul 21
3
How can I create OrderItems that go in a Order?
I suspect my problem is similar to having an order and wanting to have order items as part of the order, so I''ll explain the problem in those more familiar terms and then explain what if anything makes my actual situation different at the end. In an Order lets say you have: shipping_address and a shipped bool. OrderItem has quantity and name So Order has_many :OrderItems, and OrderItem
2006 May 26
4
Using ''validates_inclusion_of'' to validate foreign key
I seem to be missing something trying to use ''validates_inclusion_of'' to validate a foreign key and was hoping some one could piont out my mistake? The problem seems to be that Order.find_all.collect is not returning an array that contains the order_id, if I replace it with a hardcoded array everything works as expected. The model: class OrderItem < ActiveRecord::Base
2005 Dec 25
2
[repost] newbie questions
Hi all, I''m following the shop example in ''Agile Web Development with Rails''. I would like to extend the checkout screen, in such a way people can change the number of items they have selected in there cart. In my controller I have: def checkout @cart = find_cart @items = @cart.items if @items.empty?
2005 Apr 13
2
Creating multiple option groups
I''m setting up a basic shopping cart type app, and the products we have will have multiple options. Size, color, etc. I''m trying to figure out how I can collect the the options that are selected when a user adds the item to their cart. An OptionSet is a group of options ("Size", "Color", etc), and an ItemOption is the option itself ("12 oz",
2008 Jul 25
21
Problems with mock assigned to a constant
Hi all, Initially I thought this was a bug in the built-in mocking framework(and it still may be), but I better hash it out on the mailing list before I file/reopen the ticket: http://rspec.lighthouseapp.com/projects/5645/tickets/478-mocks-on-constants#ticket-478-6 I thought my example illustrated my problem, but obviously I was passing the wrong arguments to the mock. I revised my example to
2006 Mar 13
8
Nested find(:all, :include => ) statements
Is there a way for me to do: OrderItem.find(:all, :include => [:user, :product => [:supplier]] So I don''t have a supplier_id on my order_item, but have it on my product, which is part of order_item. Joerg -- Posted via http://www.ruby-forum.com/.
2006 Mar 14
5
GROUP BY and SUM
I have orders, order_items, and products. I want to collate several orders so that I can get a SUM of quantities ordered for each product etc. Can I say something like (the below gives an error on :sum, and ignores :group) OrderItem.find(:all, :sum => ''quantity'', :group => ''product_id'', :include => [:order, :product]) I want to get back a
2006 Dec 02
0
Fwd: Re: Mocha and ActiveRecord
---------- Forwarded message ---------- From: J. B. Rainsberger <jbrains762 at gmail.com> Date: 02-Dec-2006 02:48 Subject: Re: Mocha and ActiveRecord To: ruby-talk ML <ruby-talk at ruby-lang.org> James Mead wrote: > On 28/11/06, J. B. Rainsberger <jbrains762 at gmail.com> wrote: >> >> Suppose I have an Order, which has_many OrderItems. Suppose I want to >>
2007 Oct 23
6
Problem Upgrading from 1.0.5 to 1.0.8
Hey Guys, I''m getting the following error: 1) NameError in ''ProductsController with a GET to /products NO NAME (Because of Error raised in matcher)'' uninitialized constant Spec::Mocks::BaseExpectation::AnyArgsConstraint /Users/mattlins/Projects/RailsProjects/SWNetworkServices/vendor/plugins/rspec_on_rails/lib/spec/rails/dsl/behaviour/render_observer.rb:86:in
2007 Dec 05
9
Does mock_model''s :null_object option work?
Please understand in the following that I am making relatively minor changes to legacy (non-TDD/BDD) code in Substruct and don''t have the time to refactor nicely right now. I''m just trying to get past the untested/un-speced cruft quickly to write the spec for my new code, so I''m looking for expediency over prettiness. I''m specifying before( :each ) do
2005 Dec 23
0
newbie question
Hi all, I''m following the shop example in ''Agile Web Development with Rails''. I would like to extend the checkout screen, in such a way people can change the number of items they have selected in there cart. In my controller I have: def checkout @cart = find_cart @items = @cart.items if @items.empty?
2006 Jul 29
0
SOAP for large datasets
I''ve been playing around with a soap interface to an application that can return large datasets (up to 50mb or so). There are also some nested structures for which I''ve used ActionWebService::Struct with 2-3 nested members of oher ActionWebService::Struct members. In addition to chewing up a ton of memory, cpu ulilization isn''t that great either. My development
2004 Nov 30
1
RE: question about rails regarding handling more than onetable in one view
Hi, Jarkko: Thanks for the quick reply. I understand I can use ActiveRecord to specify the relation between the table as you have suggested, The part that I have trouble to understand is 1. Since I have a third table ProvWorkAtDept, do I need to specify this table somewhere when I define Provider or Dept? 2. If the provider view has both the provider name and several depts the provider
2007 Nov 20
2
confirming that a model instance was correctly created from POST params
I''m wondering whether I''m wasting my time trying to verify that an addition I''ve made to legacy code is in fact setting a new attribute on a model. Substruct''s (http://dev.subimage.com/projects/substruct) OrderHelper contains this method: 1 def create_order_from_post 2 @use_separate_shipping_address = params[:use_separate_shipping_address]
2007 Jan 30
0
nil object in mocks
RSpecrs, I''ve been running into some trouble lately when passing mock objects into rich views. Either I have to obscure my specs by stubbing every method the view would call on my object, or I have to resort to trickery like stubbing ActionController#render, which is also less than ideal. The solution I''ve some up with is a variant on the :null_object option that can be passed
2000 Jul 11
2
Administering SWAT using userid's other than root...
Hi all... Has anyone got SWAT administration working from other userid's other than root? I've got a rh6.2 box running Samba 2.0.7. I have myself (wkim) in the "domain admin users" and the "admin users". Both the smb.conf file and the swat binarary are owned by root:swat. I'm a part of group "swat". (I'm also a part of group "root" just to
2008 May 18
2
Using Hash to mock classes that respond to :
Hi I''ve been doing this a while now. If I have a class that responds to : [], and all I''m interested in stubbing is that method, then instead of using a mock I just create a hash. (Similarly, you could create an array when you are testing an Enumerable object.) Example from code I just worked on, where uses MigrationGraph#[] looks up graph vertices by name:
2014 Jun 25
2
How to enable EDAC kernel module for checking ECC memory?
In order to support ZFS, we upgraded a backups server with a new, ECC motherboard. We're running CentOS 6 with ZFS on Linux, recently patched. Now, I want to enable EDAC so we can check for memory errors (and maybe PCI errors as well) but so far, repeatedly pounding on the Google hasn't yielded exactly what I need to do to enable EDAC. One howto was covering PCI and edac, but
2008 Nov 03
1
stub! and null_object
I have some code I want to stub out as it''s not part of what I''m testing. It''s got a bit of DSL going on, so there are method calls chained together. The call I want to stub out looks like this: user.record_action(:uploaded_a_photo => concert).with_result(photo) So ideally, I''d just do @user.stub!(:record_action) and that would return a null
2008 Jan 05
3
Builder Plugin vs. Rails Plugin vs. ??? for one-click deploy
This morning I sat down to try to start writing a cruise plugin that allows you to deploy (''cap deploy'' or something similar) a revision that has built successfully by clicking a link or button on the builds/show page. (I.e., something that satisfies http://jira.public.thoughtworks.org/browse/CCRB-55.) Since I want to be able to configure the command to run in each