Displaying 20 results from an estimated 90000 matches similar to: "How to test helpers in a Sinatra app?"
2010 Mar 13
1
Testing file upload (Sinatra, RSpec, Rack-Test)
Hi.
I have a simple application and I want to add a file upload
functionality. How can I write a spec?
Here''s my try.
# directory structure
app:
- controller.rb
- controller.spec.rb
- files: []
- fixtures: [test_file.png]
# controller.spec.rb
require ''rack/test''
require ''controller''
module MyHelpers
def app
Sinatra::Application
end
end
2007 Jul 24
4
spec''ing helpers that use controller
Hi all,
I''m in the process of creating rspecs for my helpers. One of the
helpers in app/helpers/application_helper.rb looks like this:
def page_name
@page_name || "Define @page_name in
#{controller.controller_name}::#{controller.action_name}"
end
The rspec is simply:
it "should something" do
page_name
end
2010 Nov 29
0
[TDD] [Rails] - Rspec test for application_helper.rb fails when trying to access application_controller method.
In a method named logo in my application helper, I reference an application controller method (current_account) that has been marked as a helper method with the following syntax:
helper_method :current_account
When I test out the setup in the browser (without rspec), rails is happy with this setup.
However, when I run the spec, the spec won''t pass and gives me the following error:
2007 Oct 10
2
RSpec seems to be having a hard time loading Helper classes
I am getting the error when I run the command: rake spec
This is a new project with not current test written besides the ones
auto-created for me.
+++++++++
$ rake spec
(in /Users/chrisolsen/Projects/Rails/chrisolsen/trunk)
/usr/local/lib/ruby/gems/1.8/gems/activesupport-1.4.2/lib/active_support/dependencies.rb:266:in
`load_missing_constant'': uninitialized constant ProjectsHelper
2007 Nov 01
5
Can''t delete app/helpers
I would like to remove some unused helpers from the app/helpers dir, but
when I do so my specs fail.
Why is this? I don''t see where those helpers are referenced within the
tests. Is there a way to delete these unused files?
Thanks
--
Posted via http://www.ruby-forum.com/.
2007 Dec 09
0
Writing Specifications for Custom Form Builders (and Helpers)
Hello all,
Long time reader, first time poster!
I am a relative newcomer (no idea what on earth I am doing) to Ruby,
Rails and Rspec and have a feeling I am probably trying to run before
I know how to walk.
I had imagined a cool way of outputting a div around some form stuff
which would have a class on it if the related field had errors,
something a bit like:
<%
2008 Jul 03
0
Testing HAML in helper rspec
Thought I''d post this under its own heading so others can find it.
Thanks to David for the pointers to solve this.
Here is the incantation needed to use HAML 2.0 under RSpec 1.1.5 (Needs the .5 for a fix)
# application_helper_spec.rb under spec/helpers
...
before :each do
helper.extend Haml
helper.extend Haml::Helpers
helper.send :init_haml_helpers
end
it
2011 Jan 22
1
uninitialized constant ActionView::Helpers::TagHelper::ERB (NameError)
I am a new to ruby and rails and am trying to refactor some code with
rspec and have run into a problem that has stumped me for a few days and
I have searched google and ruby/rails forums to no avail so I really
hope somebody can help me out with this problem which I think may be
caused by a rails config problem. Anyway, I used ''rails new myapp'' to
make a new rails project and
2008 Feb 22
7
Testing misc methods in ApplicationController
I''m already successfully testing before_filters in application_controller
courtesy of this blog post:
http://www.movesonrails.com/articles/2008/01/23/spec-ing-your-application-controller
However, i can;''t work out how to test the sort of method that is added to
application_controller so that all controllers can use it. It must be
something simple that i''m doing
2007 Mar 15
0
Rails Helpers
Hi,
Just trying to spec out my helpers and so far its been working well enough.
I now have a helper as follows
FooHelper
def a
b
end
def b
end
end
But for some reason, probably something really simple, I cant work out how
to spec that a calls b.
Ive looked at all the variables that get set up and tried playing with them,
but no luck.
Maybe someone can shed some light on this
2007 Nov 02
2
Test that controller includes helpers?
Is there an easy way to spec that a controller should include helpers
other than its own? I was thinking I could just spec responds_to for
methods I''m interested in in the view, but that seems like crossing a
separation boundary, that the controller maybe doesn''t need to know about?
Thanks,
Steve
2006 Nov 16
0
helpers not rendered in views?
https://rubyforge.org/tracker/index.php?
func=detail&aid=6713&group_id=797&atid=3150
I''m not sure if this is true of all helper methods but it is for the
following. In this case the forn_remote_tag is rendered as an empty
line.
Apprently helpers are not rendered in view tests...
template _xyz:
<div>
<% form_remote_tag :update => "some_div", :url
2011 Dec 05
1
How to extend common helper methods to view specs?
Hi, there,
I have some methods which I have written as helpers.
They are in spec/support/controller_macros.rb (yes, I will change the
name soon).
The 2 methods, login_user and login_admin_user works in the
controller specs BUT fail to work in the view specs when I call them
in the view specs.
---------- spec/spec_helper.rb start --------------------------
# This file is copied to spec/
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
2006 Dec 08
2
UJS plugin incompatible with RSpec?
Hi all,
Anyone using UJS with RSpec? I have the following view spec:
---- edit_spec.rb
context "accounts/edit" do
fixtures :users
setup do
assigns[:user] = users(:consumer)
end
specify "should display the user info to edit" do
render ''/accounts/edit''
end
end
---- end
that causes this exception:
---- exception
ActionView::TemplateError
2007 Jun 13
3
standard location for spec helpers
Is there a standard location for spec helpers (as in bits of code that help
write specs)?
I''m mocking/stubing-out portions of ActiveSalesforce, a remote-database
abstraction layer so my specs won''t have to rely on a remote connection, but I''m
not sure where I should be putting this helper lib. I was thinking of just
sticking it in spec/ but I was curious if
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 Jan 18
2
Rspec problem in testing RoR application
Hello.
I install gems rspec and rspec_on_rails
I have this Error when try to run Rspec tests on my RoR application:
/var/lib/gems/1.8/gems/activesupport-2.0.2/lib/active_support/dependencies.rb:263:in
`load_missing_constant'': uninitialized constant
ActionView::Helpers::JavaScriptMacrosHelper (NameError)
And I follow recipes wich are placed in
2007 Nov 03
1
Specs for Helpers that call render
The helper spec I am writing tests a helper method that calls render.
##
module HelperHelper
def render_partial
render :partial => ''partial''
end
end
##
The helper spec.
##
describe HelperHelper do
it "should render partial" do
render_partial.should_not == nil
end
end
##
The output generated
##
$ spec spec/helpers/home_helper_spec.rb
.F
1)
2010 Nov 17
3
How to use request helpers outside of controller specs?
I asked this questions on some other places before, but have found no
solution yet. I''d like to include the request helper (from
ActionDispatch::Integration::RequestHelpers, like post and xhr
methods) also in some specs outside of my controller specs. The
problem is that these request helpers are only included in spec/
controller and when a controller is described.
What do I have to