Displaying 8 results from an estimated 8 matches for "application_helper_spec".
2007 Jul 24
4
spec''ing helpers that use controller
...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
Running ./script/spec spec/helpers/application_helper_spec.rb produces:
F
1)
NameError in ''ApplicationHelper hmmmm''
undefined local variable or method `controller'' for [RSpec
example]:#<Class:0xb70de334>
/path/trunk/config/../app/helpers/application_helper.rb:21:in...
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
2007 Jul 31
11
helper spec not finding rails core helpers
...in the spec test.
I boiled my question down to a simple (not too useful) example. I''m
not sure what I''m missing.
# application_helper.rb
module ApplicationHelper
def app_foo
t = Time.now
distance_of_time_in_words( t, t + 50.minutes)
return true
end
end
# application_helper_spec.rb
require File.dirname(__FILE__) + ''/../spec_helper''
describe ApplicationHelper do
it "should find app_foo in application_helpers.rb" do
app_foo.should be_true
end
end
# error output
NoMethodError in ''ApplicationHelper should find app_foo in
appl...
2007 Aug 27
2
issue with edge rails and urls
...#39;'ApplicationHelper home_link should generate a valid
home link when User.current and Profile.current is not set''
You have a nil object when you didn''t expect it!
You might have expected an instance of Array.
The error occurred while evaluating nil.<<
./spec/helpers/application_helper_spec.rb:17
Here''s the relevant spec:
describe ApplicationHelper, "home_link" do
before(:each) do
User.current = nil
Profile.current = nil
end
it "should generate a valid home link when User.current and
Profile.current is not set" do
home_link.should =~ /#{new_p...
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 "should display flash" do
for name in [:notice, :warning, :error]
flash[name]= "flash #{name.to_s} message"...
2007 Oct 02
0
Rails 2.0 & rspec edge - not protected_against_forgery?
...?'' for #<#<Class:0x3219118>:
0x34e1f94>
/Users/jcf/dev/work/sim/vendor/plugins/rspec_on_rails/lib/spec/rails/
dsl/behaviour/rails_example.rb:41:in `method_missing''
/Users/jcf/dev/work/sim/app/helpers/application_helper.rb:8:in
`login_logout''
./spec/helpers/application_helper_spec.rb:28:
I have looked into patching rspec to include the
"protect_against_forgery?" helper, but it''s included dynamically via
a "helper_method :protect_against_forgery?" call in
request_forgery_protection.rb
I have forged the forgery_protection by adding this to...
2010 Nov 29
0
[TDD] [Rails] - Rspec test for application_helper.rb fails when trying to access application_controller method.
...ionHelper#logo image tag should point to logo.png
Failure/Error: helper.logo.should =~ /logo.png/i
undefined local variable or method `current_account'' for #<ActionView::Base:0x105645108>
# ./app/helpers/application_helper.rb:13:in `logo''
# ./spec/helpers/application_helper_spec.rb:21
Current Versions:
Rspec Version 2.1.0
Rails Version 3.0.1
I''ve created a gist that shows how my code is setup, and how the helper is calling the controller method:
https://gist.github.com/720757
Does anyone know why this setup works fine outside of rspec (when I test in the brows...
2007 May 29
12
questions rspec on rails
...to test named routes?
- Could I get an example how to test an ajax request
(link_to_remote)? would that go in view? and/or in controller spec?
- Can you assert which layout template is rendered in a controller spec?
- How to test application_helper.rb helpers?
(creating a file spec/helpers/application_helper_spec.rb like other
helper_spec files gives an error
no such file to load -- ./spec/helpers/../application_helper (LoadError)
- How to write a test (uh, i mean spec) for helpers that take blocks?
for example:
def link_block_to_remote( options = {}, html_options = {}, &block)
concat(link_t...