similar to: Re: Stubbing out ThinkingSphinx for Rspec

Displaying 20 results from an estimated 1000 matches similar to: "Re: Stubbing out ThinkingSphinx for Rspec"

2008 Sep 17
1
Stubbing Paperclip calls to Amazon S3 (for Rspec)
Would anyone happen to know how to stub a call to S3 from Paperclip? I''ve searched every where and no one seems to have posted anything about this. I''ve done very little in the way of spec''ing dependencies on external services, so any ideas on how to do this with Paperclip & S3 would be most appreciated. I''m happy with stubbing out Thinking Sphinx - would
2006 Jun 27
5
Can''t call public application.rb method from ERb template
All, I have a left navigation partial that I want to dynamically generate CSS classes for based on the current controller action. In my ERb template, I have <DIV class="<%= get_menu_display_style(''login_form'') %>"> In application.rb, I have the method get_menu_display_style defined as: public def get_menu_display_style(action_requested)
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 Oct 05
7
Easy AR association stubbing
I''ve added a method to the mock class that makes it pretty easy to stub associations in rails. I''ve been using it for awhile and it seems to cut down on a lot of setup code for the controller and model specs that use associations. #before @person = mock_model(Person) posts = mock(''post_proxy'') posts.stub!(:build).and_return(mock_model(Post, :save => true))
2006 Oct 04
3
do we need stubbing?
Hey all - The trunk currently supports three types of mocking/stubbing: Mock Objects (created dynamically at runtime) Partial Mocking of methods on existing classes Stubbing of methods on existing objects or classes The main difference between Partial Mocking and Stubbing is that Stubs don''t verify. I''m wondering if we really need the stubbing facility at all, given that we
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 May 15
3
NOOB question RSPEC
Hi all !! I have this code: require ''account'' describe Account, "when first created" do before do @account = Account.new end it "should have a balance of $0" do @account.balance.should eql(Money.new(0, :dollars)) end after do @account = nil end end How can I pass the @account.balance.should eql(Money.new(0, :dollars)) spec. From my
2008 Mar 19
2
Stub / Mock - A little guidance?
Hi there, I''m still trying to wrap my head around when to use a stub and a mock. If I understand this right, I should be using a ''mock'' when imitating an object, but not its behavior. I should be using a stub when I want to imitate the behavior of an object. Does that sound about right? With that said, I''m struggling a little trying to spec out this instance
2007 Dec 03
5
spec for model_id should eql
Hello, I''m confused why the spec described below is failing. Other simple comparison specs are passing fine for the same model. The code is working accordingly when I test it through the console, I''m just having difficulty getting this spec to work. Any pointers would be appreciated. Failure message: ''Address fetch and geocode should extract department and write to
2007 Feb 23
4
How can I spec this? The method gets passed a block...
I''m using Jim Weirich''s Builder library. The code I want to spec is xml.video do xml.id @video_id xml.views @views xml.date(@date.to_s) if @date end I''d like to mock it, rather than asserting that the XML is the right string. I can do one spec: specify "should create a video tag" do @mock_builder.should_receive(:video)
2008 Oct 01
10
Recaptcha (or other captchas)
Does anyone have any suggestions for a best practice implementation of Recaptcha (or other captchas - if you recommend going another route, I''m all ears)? I''ve found the recaptcha gem and a plugin but I don''t know which is the best implementation, and I haven''t found a thorough tutorial plus example code for either. Thanks -- Posted via
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:
2008 Mar 10
6
Probably OT, but CSS Help?
Ok I know this is off topic, but since you guys are usualy so helpful, I thought I''d try here first. Building a Rails App and one of the things we''ve done is put a CSS class of; * { font-family:"Lucida Grande",verdana,arial,helvetica,sans-serif; margin:0pt; padding:0pt; } Now the problem is that the padding setting, for one reason or another is killing my select
2008 Aug 28
12
Rendering User attributes in XML
Let''s say an app has a User, and a User has many friends. Also, let''s say the app authentication was built on the restful_authentication plugin, and we have email and password in the Users table. The friends controller index might look like this; # GET /users/1/friends # GET /users/1/friends.xml def index @users = @user.friends respond_to do |format| format.html
2008 Sep 02
4
Attachment_fu, Paperclip, & S3
For various reasons, I made a git branch and installed Paperclip in place of attachment_fu. Paperclip works great except that images seem to have lost some quality; edges have gone a little too jaggy to be able to drop attachment_fu just yet. After a post on the Paperclip Google Group, someone suggested the :convert_options could be passed additional attributes, like ''quality'',
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 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 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
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
2008 Nov 07
15
any tricks re using " eql(5.5)", but where 5.5 is a decimal not float?
-- Sent from my mobile device