Displaying 20 results from an estimated 4000 matches similar to: "shared behaviour for all views"
2007 Oct 22
1
View spec response has no content?
I have been messing with this all night, and can''t figure out what''s going
wrong here. I have a test that renders the view, and then a shared
behavior checks "response" for the various tags from a rails layout. The
problem is matching. If I run in the browser the page renders
fine. Is there a way to output what the response contains? Here are my
tests:
describe
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 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
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
2007 Nov 06
2
Why is this view spec failing?
I can''t figure out why I am getting a failure. It renders out fine in
the browser.
<h1>New member</h1>
<%= error_messages_for :member %>
<% form_for(:member, :url => members_path) do |f| %>
<fieldset>
<legend>Member Info</legend>
<p><label for="member[first_name]">First Name:</label> <%=
2010 Jun 28
1
have_tag matcher in rspec 2?
I always assumed have_tag was part of rspec, but it''s not in rspec 2,
and looking now I don''t see it in rspec 1 either. Webrat defines it, but
that seems like a coincidence (I tried requiring webrat/core/matchers to
no avail).
Is it depricated, not yet implemented, or does it work for everyone
else?
My project is from scratch, rspec-rails 2b13, using generated
spec_helper.
2008 Aug 08
2
template.expect_render fails when partial is rendered from a helper
My spec;
describe ''subnav rendering while logged in'' do
before do
template.stub!(:logged_in?).and_return(true)
template.stub!
(:current_profile).at_least(:once).and_return(mock_profile)
end
def do_render
render "/homepages/show.html.erb"
end
it "should render the logged in partial for homepages" do
2007 Aug 06
2
used the described Class in a shared behavior
Is it possible to access the described class in a shared behavior? I''m
trying to do something like this:
describe "Siberian feline", :shared => true do
described_class_instance_as :feline, :name => "fluffy", :breed =>
"Siberian"
# or maybe
before(:all) do
@feline = described_class.new(:name => "fluffy", :breed =>
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 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
2007 Sep 14
0
using #include in shared behaviours
Hi folks,
Is there any way I can call #include from within a shared behaviour
without it blowing up?:
> vendor/plugins/rspec/lib/spec/dsl/shared_behaviour.rb:48:in
> `included'': private method `include'' called for #<Class:0x3047484>
> (NoMethodError)
More detail: I have a spec/concerns directory which contains specs
corresponding to mixins in
2007 Jul 09
0
Is it bad to use a shared example in rspec_helper.rb?
I want to extract the method for logging in so that I don''t have to include
it in each before call.
Is it bad to use a describe block within the rspec_helper in a rails project
for controller tests?
I have in my spec_helper.rb
describe "an authenticated request", :shared => true do
before( :each ) do
@u = mock_model( User )
mock_login( @u )
end
def
2007 Jul 16
4
Accessing content_for html in view specs?
Hi All,
Hope all is going well.
I''ve got a few views that create some content using ''content_for'' blocks
<% content_for :blah do %>
.....
<% end %>
Has anyone worked out a way to be able to access the html that''s
generated inside those blocks?
Since they''re not part of the view, have_tag('''') seems to miss them,
2011 Nov 05
1
Newbie Question/Feature Request
Hi,
I'm working on a plugin for qpsmtpd (a perl smtp frontend) that delivers mail via dovecot's LDA. I can only get mail delivered by writing the email to file, then calling 'deliver -d someone -f someone-else < /path/to/temp/email' All good, expected behavior. A perl snippet:
local $/=undef;
open FH, "< ./demo.mail";
my $stringified = <FH>;
# this is
2001 Feb 28
1
Spider diagrams
Hi, I am trying to create what are called "spider diagrams" in the geochemical
literature using R. A spider diagram is basically a plot of the atomic number
versus the concentration on a log scale. Lines are drawn from each atomic
number for each sample.
Right now, my data frame looks like:
SAMPLE SITE V3 LA.NASC LAATNUM CE.NASC CEATMNUM
1 1A:001
2007 Oct 06
4
spec''ing views, mock_model associations
I writing a spec that returns the count of how many players in a game:
it "should how many players in a link to all players" do
render :partial =>"games/game", :object => @game
response.should have_tag(''a'',"(2) Players")
end
I''m not sure how to do the mock model, I think it would be done two ways but
unsure of the syntax:
1: add
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
2007 Oct 01
1
have_tag and line numbers
When I''ve got a view example like this:
1: response.should have_tag "fieldset#children" do
2: with_tag "child"
3: end
If it can''t find ''child'', the error seems to come back as my_spec.rb:1
instead of my_spec.rb:2.
Has anyone else experienced this? I just spent a while tracking down what I
assumed was a problem in my have_tag only to
2007 Dec 07
4
strange error on mock proxy
I''m banging my head over this really strange error in a view test when
I run "rake spec". The weird thing is that I don''t get the error when
I run the spec file by itself.
Here is the spec (I know, fixtures are the devil):
describe "/units/new.html.erb here" do
fixtures :units, :accounts, :groups
it_should_behave_like
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