Displaying 20 results from an estimated 5000 matches similar to: "expect_render, why does there need to be a warning"
2007 Jun 27
3
template.expect_render
Trunksters,
I just added a couple of methods to ActionView::Base in Spec::Rails
(as of r2136) that lets you do this in view examples:
describe ''/things/index.html.erb'' do
it "should render _thing with a collection of things" do
assigns[:things] = things = [Object.new]
template.expect_render(:partial => ''thing'', :collection => things)
2007 Oct 20
14
Problems with form_for and partials
i''m having problem with a form_for situation where i''m trying to DRY
out the repeated parts of my forms and put them in common/form and
render the form elements via another partial in controller_name/_form.
Here''s the first form
# app/views/common/form
<% form_for ... do |f| -%>
<%= render :partial => "params[:controller]/form", :object => f
2008 Jan 23
4
expect_render(...).and_return(''x'')
Hi,
I''m trying to spec a controller method which renders some rjs as part
of a render :update block. The problem I''m having is that stub_render
or expect_render don''t seem to allow and_return to work.
The controller method does:
if @thing.save
render :update do |page|
page.insert_html :bottom,
2008 Oct 24
4
Correct way to spec partials
Hi everybody,
1) Does anybody have full working example of how to test partial templates?
2) What the correct place to test partials: controller or view spec? If
controller correct place,
should I use integrate_views?
3) Is it true that expect_render is deprecated and I have to
use should_receive(:render)
4) How to test that partial''s locals hash is correct?
Thx
-------------- next
2008 Mar 12
2
RSpec view test for :partial with :locals?
I''m currently working on some RSpec view tests and I''m having problems
with expect_render. Most of the expect_render''s work fine, but in one
of my views I have:
<%= render :partial => "user_cloud", :locals => {:user =>
@featured_user} %>
I see that expect_render supports ":object" or ":collection" for the
second
2008 Mar 11
1
view spec on rails questions
Hi
I have a couple of questions
1)
how do you test the response inside a content_for block
I see reference to it in the release notes but dont know where to
find it (tried http://rspec.info/rdoc-rails/ )
2)
I dont seem to be able to stub partials in a different directory eg
<%= render :partial => "foos/show" %>
And I put this in the spec
template.stub_render(:partial =>
2008 Jun 02
1
Cherry-picking mocks?!
A colleague just came in and asked me about a problem he was having with
stub_render, which reminded me of another issue he had a week or so ago,
which seems related.
Let me start with the earlier issue.
He was trying to write specs for a method which sends the same message
possibly multiple times, but with different arguments under different
calling conditions. He wanted to write
2008 Oct 20
5
RSpec-Rails bug with to_xml?
Hello, everyone. I''ve been lurking here for a while, but this is my first post.
I think I''ve run into a RSpec bug in a Rails project I''m working on. I
was working on a few REST controllers, and started getting failures on
a specific spec that verified whether a certain action returned XML
output. I spent quite a lot of time checking my code to see if it was
something I
2007 Aug 13
3
RSpec-1.0.8
The RSpec Development Team is pleased to announce the release of RSpec-1.0.8.
RSpec 1.0.6 is the "holy cow, batman, it''s been a long time since we
released and there are a ton of bug fixes, patches and even new
features" release. RSpec 1.0.7 and 1.0.8 deal with a regression
introduced in 1.0.6 and a hiccup in releasing 1.0.7, respectively.
== RSpec
RSpec is a Behaviour Driven
2007 Aug 13
8
How to use expect_render?
Hi:
I am a rspec beginner. I have scratched my head for the whole afternoon,
trying to figure out a way of writing render expectation in controller spec.
However, I failed. It kept telling me that the ''expect_render'' was an
undefined method. I have installed rspec 1.0.8 and rspec_on_rails as well.
Below is the controller to be tested.
Controller
def index
pre
2011 Apr 06
1
Time to fix PartialRenderer#partial_path
For the longest time PartialRenderer#partial_path has prefixed the
prefix of the current controller when it is nested in a module. This
hasn''t been a problem (because nesting controllers wasn''t that common)
but with 3.1 striving for better engine support, this problem is now
larger because all of your controllers for an engine will be nested
and it makes doing <%= render
2007 Oct 01
15
how to spec views
I''m trying to spec a view but haven''t done much view specing.
This view render different partials depending on authentication of the user:
annon, admin, player
So I I''ll write if conditionals in the view with the partials
it "should render signup propaganda for annon users trying to view games"
do
render "/games/index.rhtml"
2009 Feb 03
1
Passing args to generator
I have some default_options in generator and when I wish to change they
value with --option_name I get only logical true instead of string
...
default_options :option_name => "Some string"
...
def add_options!(opt)
opt.separator ''''
opt.separator ''Options:''
opt.on("--option_name","Some Text") { |v| options[:option_name] = v
2007 Nov 20
3
How to test views with Nested Resources and Partials
Hi everyone,
I am relatively new to rspec and I am running into a wall in testing my
views. I have a RESTful resource Contracts with a nested resource of
Line_items.
I am trying to figure out how to test the "edit" form of the Line_items.
What complicates this is the nested routing and how to account for it,
and that there is a partial form (_form.haml) that both the edit.haml
and
2008 Mar 23
6
Locals do not appear in partial unless collection is explici
Maybe I''m misunderstanding something but it appears as if
<%= render :partial => @items, @locals => { :this => ''that'' } %>
does not give the local variable this but this one does:
<%= render :partial => ''items/item'', :collection => @items, @locals => {
:this => ''that'' } %>
Shouldn''t they mean
2010 Feb 12
2
How to source files from a search path?
Suppose some environment variable (say MY_R_INC) has a number of
paths. I want to source some file relative to some path in $MY_R_INC
(just as #include in C++ does, which looks for header file in a number
of directories). I RSiteSearch'ed, but I don't find any function that
satisfies my need. Could somebody let me know if I overlooked
something?
2007 Jul 14
3
expect_render twice in views
I found this:
controller.expect_render(:partial => ''thing'', :collection => things).once
but I am trying to expect_render twice in my view spec:
template.expect_render(:partial => ''order_details'').twice
This doesn''t work as the template.expect_render call seems to be
returning an array. Is it possible to expect the rendering of a
partial
2006 Dec 13
4
RSpec and simply_helpful
Hi All
I''m having some problems running my view specs when using
simply_helpful. I have it semi-working via the following:
module SimplyHelpfulHelper
def self.included(base)
base.send :include, SimplyHelpful::RecordIdentificationHelper
base.send :include, SimplyHelpful::RecordTagHelper
end
end
context "The index template" do
setup do
@shift =
2008 Mar 12
2
Warning: integrate_views and nested description groups
describe MyController do
integrate_views
describe "A common base senario" do
it "no longer integrates views" do
be_careful
end
end
end
integrate_views affects an attribute in the class formed by the describe
factory method. The second describe generates its own class, so
integrate_views is OFF at that level. I''ve already spent far, far too much
2008 May 26
7
Mocking Models in Controller Specs...
I find myself doing this kind of thing a lot in Controller Specs:
@vacancy = mock_model(Vacancy)
@vacancy.stub!(:reference)
@vacancy.stub!(:title)
@vacancy.stub!(:created_at)
@vacancy.stub!(:updated_at)
@vacancy.stub!(:body)
@vacancy.stub!(:contract)
@vacancy.stub!(:location)
@vacancy.stub!(:salary)
@vacancy.stub!(:benefits)