Displaying 20 results from an estimated 10000 matches similar to: "mocking out helper method in a view spec"
2007 Aug 16
3
Mocking a non-existent method
I don''t like this:
i = mock(Integer)
i.should_receive(:asdfasdf).and_return(''foo'')
puts i.asdfasdf
Shouldn''t rspec check to see that :asdfasdf is a valid message to be
sending Integer?
Joe
2007 Jul 24
11
Mock or Stub strategy for validates_uniqueness_of
Hi,
I''m a bit stuck with mocking a unit test of a join model with regards to a
validates_uniqueness_of clause.
I have
class Book < AR:B
has_many :clippings
various validates_presence_of etc
end
class Clip < AR:B
has_many :clippings
various validates_presence_of etc
end
class Clipping < AR:B
belongs_to :book
belongs_to :clip
validates_uniqueness_of :clip_id,
2007 May 23
4
content_for
Any ideas how I would go about writing specs for views which make use
of content_for?
I''d like, for example, to be able to specify that ABC view places XYZ
in the sidebar, which I do using content_for(:sidebar).
Am I missing something obvious?
Kyle
2008 Mar 17
8
should have_tag outside Rails
Hi
Google has not helped me here. I''m looking for a way to use the have_tag
assert_select wrapper outside RSpec on Rails (but in a Rails project) so I
can use it to check text strings.
Has anyone managed this?
Thanks
Ashley
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
2007 May 22
3
Comments wanted about spec''ing out a couple controller methods
(oops, accidentally sent this to the rspec-devel list, sorry about that)
Could someone help me spec out these Rails controller methods? I
don''t know where to get started, especially with the transaction
stuff. Or, if anyone else could suggest ways I could improve the
code, that would be great as well.
Puzzle has_one Media. Both are AR model objects.
class PuzzlesController <
2007 Dec 09
1
Story HTML Formatter
I recently noticed the HTML formatter for the story runner, but I''m
unable to figure out how to make it function.
''ruby stories/all.rb --format html'' seems like it should work, in that
--help works as expected, but I still get only plain text output.
Maybe it''s not been wired up yet and/or this is a bug. Maybe I''m just
being dumb. I have no clue at
2007 Nov 23
12
namespaced controllers
Out of curiosity, I''ve seen the following fail:
module Admin
describe MyController
...
end
end
But this works fine:
describe Admin::MyController
..
end
Why?
Scott
2007 May 22
3
rspec_on_rails'' spec:doc and dry runs
In rspec_on_rails, the spec:doc task uses --dry-run, which doesn''t
jive well with rspec''s ability to write docs for you.
For example, I use the rspec_expectation_matchers plugin from
spicycode.com (scanned for a name, didn''t find one =), and end up
writing specs like:
it { @ticket.should validate_presence_of(:name) }
Which results in specdocs such as:
Ticket
2006 Jan 24
5
simple formmail question
I have a few forms that I''d like users to fill out. The results of
the form will be sent to a few addresses.
What''s the least painless way to do this and keep everything DRY?
There''s no database involved. Ideally, I''d like to email the form
questions with the answers inline.
Seems like using ActionMailer and separate email views would be
overkill in this
2005 Sep 18
5
NameError: uninitialized constant Addres
I created some scaffolding for an Address model and an Addresses controller.
When running the functional tests for the addresses controller, I get
this exception: "NameError: uninitialized constant Addres"
The exception seems to start from this function:
def list
@address_pages, @addresses = paginate :address, :per_page => 10
end
I''m guessing pluralization bug?
2006 Jan 14
11
accessing models from migrations
Ok, so now Users need to be associated with Organizations. I''ve
created a migration and added a ''organization_id'' column to the users
table. I want the default organization_id to be the first
Organization. So I have :default => Organization.find(:first). But
it''s complaining about not being able to find the constant
''Organization''.
Any
2006 Feb 08
5
validates_acceptance_of + functional testing
I had to add a check box indicating that a user accepted certain terms
to a page. So, I put in a ''validates_acceptance_of :terms'' line into
the appropriate model and added a checkbox to my view. Everything
works as expected in my web browser.
However, my functional tests still pass and I didn''t add or change
anything to them. I was expecting to have to add another
2007 May 17
4
How to mock helpers in view specs ?
Hi all,
I am mocking the following Rails view (inside a partial):
<%= render :partial => "forums/forum",
:collection => forum_category.forums.readable_by(current_user? ?
current_user : nil) %>
My spec fails with the following message:
1)
ActionView::TemplateError in ''forum_categories/index (anonymous user)
should only render forums accessible to anonymous
2005 Mar 10
6
images from database + caching
Is the information in
http://wiki.rubyonrails.com/rails/show/HowtoUploadFiles on caching
images still the best way on how to cache images that are served from
the database?
I haven''t added time information to my image table yet, and the images
are sent after every single page view (even if it''s been downloaded
already).
Joe
2006 Jul 02
5
"the number of parameters does not match the number of substitutions" error
All of a sudden, I''m getting this error:
1) Error:
test_index(AccountControllerTest):
RuntimeError: The number of parameters does not match the number of
substitutions.
/home/joe/projects/tanga/trunk/config/../vendor/rails/actionpack/lib/action_controller/assertions.rb:92:in
`assert_redirected_to''
2005 Mar 09
16
rails on low memory vps
Anyone got any tips for running Rails (w/ either webrick or
lighttpd/fcgi) on a VPS with a pretty small amount of memory (like
64MB memory and 64MB swap).
Thanks,
Joe
2006 Jun 29
5
2D display in Rails
Hi,
Imagine you have a program that contains information on an entity
called a Player. There can be lots of Players, say a thousand of
them. Players have 20 or so attributes, two of them are an X and Y
position. The Players'' attributes are updated many times per second.
Now imagine you need to create a web app that shows a 2D overhead
display of the all the Players. A grid should be
2007 Sep 28
6
Couple questions about backgroundrb
So, what''s the status of this project? I''m a little confused. The
documentation at http://backgroundrb.rubyforge.org seems out of date.
It refers to http://svn.devjavu.com/backgroundrb/tags/release-0.2.1,
which doesn''t work.
All I want is a way to easily set up tasks that should run
periodically. Some stuff should run every 10 seconds, some stuff once
a day, etc.
2006 Mar 15
10
Question on hardware for site
For a medium-sized website, does one machine for database server
(either mysql or postgres) and another for the web server (lighttpd)
sound ok? How much traffic could I expect to handle? (I know it
depends on the application, but some rough estimates would be nice)
Joe
2006 Jun 29
6
adding a before_filter to static content
Hi,
I have a Rails site that uses a before_filter in the application
controller that does some authentication and authorization work.
I also have a bunch of HTML in folders in the application''s public directory.
Before a user can view anything in the public directory, I''d like to
authenticate them. How could I do that?
I''m using mongrel, if it matters.
Thanks,
Joe