Displaying 20 results from an estimated 2000 matches similar to: "Accessing content_for html in view specs?"
2008 Apr 19
4
Is testing output within content_for possible?
I wanted to test that the links below were being rendered in the views.
- content_for :sidebar do
%ul.links
%li= edit_link edit_admin_contact_url(@contact), "Contact"
# view test
it "should have the correct side bar links" do
do_render
response.should have_tag("ul.links") do
with_tag("a[href=?]",
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 Jan 24
3
Help to spec a rails helper method that uses content_for
Hi guys,
I am a Rspec newbie and am having problems creating a spec for a RoR helper
method.
I have in fact already implemented the helper method and am trying to create
retrospective specs. I know its the wrong way to do it but I am still
learning Rspec.
In my view I have a call to a helper method.
<% body_class "users" %>
which sets a CSS class declaration in the content_for
2010 Aug 18
2
RSpec 2/Rails 3 - content_for in view specs
My main layout includes separate content_for/yield sections for my header,
sidebar, footer, and content. However, when running a view spec, the
`rendered` variable seems to only contain a string of just the primary
content and ignores the header/footer/sidebar as well as the rest of my
layout file (the "render" call just returns my primary content wrapped in
generic <html> and
2007 May 21
9
Ordering in view specs using have_tag and with_tag
When writing view specs is there any way to test not only for the
presence of tags (have_tag) and nested tags (with_tag), but also test
that they appear in a given order?
For example, consider the following:
it ''should display the login names, display names and email
address in alternating rows'' do
response.should have_tag(''div.odd>div'') do
2006 Jun 14
3
In memory IndexReader bug?
Hi All,
Hope all is going well.
I''m having trouble with the following code creating an in memory index
reader - it seems to be attempting to read from a file regardless.
Here''s the simple code:
require ''rubygems''
require ''ferret''
a = Ferret::Index::Index.new
r = Ferret::Index::IndexReader.new(nil)
Running the code on my OS X machine
2007 Sep 14
6
Need help in View Spec
Hello everyone:
I am kind of puzzled in writing spec on view partials. I can not find much
information about the "should have_tag" syntax in Rspec. Can rspec test a
particular attribute of a tag (e.g. input tag)? Let me put an example here:
#../view/group/_index
<div id="test">
<input type="button" value="update" onclick="update()"
2006 Jun 13
5
Grep style output?
Hi All,
Hope all is going well. Was just wondering if anyone has implemented a
grep style output page of hits using Ferret as the index/query engine?
Any thoughts about how best to implement it? The previous thread
discussess highlighting - would that be the best approach to follow or
is there a better way?
Cheers,
Marcus
--
Posted via http://www.ruby-forum.com/.
2008 Sep 17
2
Layouts and content_for
when i studied the tutorial about layouts & content_for from railscast.I
need a clarification as per their tutorial.
url:http://railscasts.com/episodes/8-layouts-and-content-for
<!- projects/index.rhtml ->
<% content_for :head do %> <= stylesheet_link_tag ‘projects’ %>
< end %>
<!- layouts/application.rhtml ->
<head> <title>Todo List</title>
2007 Mar 09
6
AssertSelect for strings?
Hi,
Is there a way to use the have_tag matcher on a string instead of the
response body from a view? I have a helper in a method rails project
that returns an html fragment which I would like to test.
Like this:
module SomeHelper
def some_helper_method
"<p>foo</p>"
end
end
context "The SomeHelper"
helper_name :some
specify do
2007 May 04
11
spec template for CRUD?
Hello,
Has anyone already come up with a set of shared behaviours that
someone could leverage when adhering to a CRUD concept, with respect
to controllers?
Relatedly, it would be nice if there were a way to share generalized
behaviour specs.
-Chris
2007 Aug 02
2
Do the :attributes and :content matchers work
[Rails plugin 1.0.5]
Hi,
I am looking for some guidance.
When working on a partial which looks like this
<div class="bug" style="width: 100%;" />
I have some examples which should fail - I think - but do not:
it '' should fail'' do
response.should have_tag( ''div.bug'', :content => ''There is no
2007 Jul 22
2
have_tag for href with specific link?
Hi folks,
I''m trying out this idea of "outside-in" and writing specs for my views
first. Being a person who generally starts with some scribbles of a user
interface and moves right to models, this has yet to be fun, but I''m
giving it a shot.
My question: I''m trying to specify that an index page should show a list
of things, each with a link to a delete
2010 May 05
2
Add method to get at captured content_for
In Rails 3 the only way to get for content captured with the
content_for method in a view is to call yield from within a view.
However, sometimes is it useful to get to this data from within a
helper (for instance to provide a default value). Calling yield from
within the helper method won''t work, and accessing the @_content_for
variable directly is not encouraged.
Proposed solution: add
2007 Oct 05
4
have_xml_tag
Hi
Was just using have_tag on an xml response and found the problem
outlined and resolved here
http://weblog.jamisbuck.org/2007/1/4/assert_xml_select
Just wondered if there is any support in rspec?
Cheers
Shane
Shane Mingins
ELC Technologies (TM)
PO Box 247
Santa Barbara, CA 93102
Phone: +64 4 568 6684
Mobile: +64 21 435 586
Email: smingins at elctech.com
AIM: ShaneMingins
Skype:
2009 May 23
9
undefined method `assert_select'
I''m having trouble getting the specs to run for a plugin where I want to
fix a bug. (I''ve actually already found and fixed the bug, but I don''t
want to submit a fix without a test!) When I started the specs weren''t
running, but it may be that I''m using Rails 2.3.3 and the plugin has
been tested on 2.1 and earlier. I went through writing a spec for a
2007 Jun 29
12
testing instance variables that are set inside views
Hi all,
In my view specs (for Rails), how can I get at instance variables that
are set within my view? For example, if my view looks like this:
<% @header = "My Header" -%>
<div>some content</div>
How can I get to @header from within my view spec? I''ve tried @header
and assigns[:header] to no avail.
TIA,
Jeremy
--
Jeremy Stephens Computer Systems
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 Oct 09
23
Testing layouts with RSpec on Rails
Hey guys,
Does anyone have any wisdom to share on the subject of speccing Rails
layouts?
Most of it''s plain old view specs stuff, but are there sensible ways
to verify things like the yield call? (Mocking doesn''t catch that)
Thanks,
Matt
--
Matt Patterson | Design & Code
<matt at reprocessed org> | http://www.reprocessed.org/
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 =>