Displaying 20 results from an estimated 300 matches similar to: "rspec_on_rails: controller method not getting called"
2008 May 20
5
How to write a test for validates_uniqueness_of
Hi,
I have a spec
it "should have a unique username "
I have a code:
validates_uniqueness_of :user_name
Now, I don''t know how to test this code. In order to test this, do I
need to run `save`?
For example,
@user = User.create(:username => "mike")
@another = User.create(:username => "mike")
@another.save.should be_false
This messes up test
2007 Aug 04
5
reusable specs - almost there
I have a lot of controllers with virtually identical functionality for most
actions. I''ve been using shared behaviours to DRY things up a bit, but I
still have to create separate behaviours for each context before I can use
the shared behaviours
what I have now is a generic file which contains all the behaviours and
examples common to all the controllers, and that file gets loaded from
2007 Oct 16
6
Failure trying to test ApplicationController
I''m trying to write some tests for the ApplicationController as shared
tests that can be run in all of my other controller tests, but am getting
a nil.rewrite error. Below is what I have...
describe AccountController do
it_should_behave_like ''Application controller''
end
describe ''Application controller'', :shared => true do
it
2006 Apr 29
1
reloading include-modules inside controller not working
Hi guys,
I would expect an ActionController-derived class to reload _completely_ in
development mode.
class FooController < ApplicationController
include FancyStuffSupport
def index
# bla
end
# more actions here
end
However, the ''FancyStuffSupport'' is not reloaded, only the ''FooController''
itself. Can this behaviour be changed? I feel back
2006 Feb 03
4
(BUG in svn/trunk?) - superclass mismatch for any subclass of ApplicationController
I track svn/trunk of Rails using svn:externals
Some change to Rails committed in the last 1-2 days broke my subclass
of ApplicationController
The example, below, works with Rails 1.0, but in today''s svn, it dies
with the following error:
"superclass mismatch for class FooController"
class ApplicationController < ActionController::Base
end
class FooController <
2005 Dec 15
5
initialize called more than once?
Hi,
In my test case below, it seems that ''initialize'' is called everytime
''hello'' is called. Is this by design, a bug, or my pilot error?
class FooController < ApplicationController
def initialize
print "\n initialize \n"
end
def hello
print "\n hello \n"
end
end
I
2006 Mar 09
4
Stop users accessing methods.
Hello all.
Is there a way to stop users from being able to access a controllers
methods without affecting the ability of other controllers to use them?
i.e
FooController
def secret
#Stuff
end
end
BarController
def index
redirect_to :controller => ''foo'', action => ''secret'', :id => ''007''
end
end
But directly
2008 Apr 29
1
Spec''ing controller macros
Hi,
(This is my first post after months of appreciative lurking...)
I''m trying to spec the following conditional controller macro:
class ApplicationController < ActionController::Base
# turn off session management for robots
session :off, :if => lambda {|req| req.user_agent =~ /(Google|Slurp)/i }
# ...
end
My current attempt seems to be quite unsuccessful:
1) when I
2006 May 11
1
rendering in after_filter
Hi!
Is it possible to render the action within the after_filter method, or
is the rendering performed before?
I have something like this:
class FooController
after_filter :send
def a
@content=...
end
def b
@content=..
end
protected
def send
send_data(@content,...)
end
end
However, when calling the action a or b, the @content doesn''t get sent,
but instead
2005 Dec 20
2
printing/logging during tests
Hi all,
I''m trying to output some info to see what''s happening in a controller
during functional tests.
Problem: ''print'' only works in the test code, but not in the production
code that''s being called by the tests.
Example:
In FooControllerTest:
def test_list
print "1: starting" <<----- WORKS FINE
get
2005 Feb 15
1
Modules Beta Comments
I''m not sure but I think this is due to the ''modules'' support in the
latest beta gems.
In some controllers I include small utility classes that only make
sense for that controller. Something like this:
class SantasLittleHelper < Foo
end
class FooController < ApplicationController
end
Where Foo is defined in RAILS_ROOT/lib/foo.rb
What I am seeing now
2007 Nov 23
12
namespaced controllers
Out of curiosity, I''ve seen the following fail:
module Admin
describe MyController
...
end
end
But this works fine:
describe Admin::MyController
..
end
Why?
Scott
2008 Oct 18
4
Problems when programmatically defining examples
Hi,
I am trying to code an application that is based on Rspec; I am
programmatically building examples, and launching the runner with a custom
formatter. Here are the code snippets from my app:
Launching the runner:
example_groups =
test_expectation.example_groups_for(system_state)
@output = StringIO.new
options =
2007 Aug 31
2
Can module spec "behave like" controller spec?
Hello everyone:
Right now I am writing spec on modules, which are provided by my
colleagues. Some of the modules actually contain action methods. I tried
very hard to spec those action methods in modules. But it seems that the
rspec does not allow module spec to ''get'' action like controller does. After
I saw the documentation, I then used :behaviour_type=>:controller.
2006 Jul 24
1
All functional tests fail with RoutingError
All,
I''m using InstantRails 1.0 on Windows XP and all my functional
(controller) tests fail with ActionController::RoutingError, although
the actions work OK through a web server/browser. Here''s an example of
an error:
1) Error:
test_create(AdminControllerTest):
ActionController::RoutingError: No url can be generated for the hash
{:controlle
r=>"admin",
2001 Feb 11
2
splitting up optional args
Hi,
A question (& possible suggestion) about function calls.
Is there an R idiom to eliminate the redundancy in the
following common situation?
foo <- function(x, control=ComplicatedDefault) { etc. }
plotfoo <- function(x, foocontrol=ComplicatedDefault, ...) {
y <- foo(x, control=foocontrol)
lines(x,y,...) }
The idea is that there are MANY
2006 Apr 22
3
Making a separate admin zone
Hi, im building a little cms and i want to separate the admin zone
controllers in a subfolder(controllers/admin) if possible to all be
managed by one login module, i just have managed simple 3 or 4
controller apps so any help you can give me will be very apreciated.
;)
--
Posted via http://www.ruby-forum.com/.
2006 May 25
5
Setting a global before_filter action in application.rb
Can you set a global before_filter action in application.rb?
So, for example, you could control authentication for all of the
controllers in an app.?
Obviously, you would need a way to reference actions by controller
within this "global before-filter".
Thanks,
Wes
--
Posted via http://www.ruby-forum.com/.
2016 Sep 21
0
CentOS-6.8 PCI Hwdr issue?
I have begun to see these messages in my morning reports:
WARNING: Kernel Errors Present
pciehp 0000:00:1c.0:pcie04: Link Training Error occurs ...: 146
Time(s)
pciehp 0ng Error occurs ...: 1 Time(s)
pcieport 0000:00:1c.0: bridge window [mem 0xd0a000000.0 failed
with error -22 ...: 1 Time(s)
r8168: probe of 0000:01:00.0 failed with error -22 ...: 702 Time(s)
r8168:
2008 Jun 05
1
Using and_yield to pass multiple or no iterations
Hi, imagine there''s a class called Egg which has the following method
(which calls another method):
<CODE>
def do_thing
has_iterated = false
self.each_row do |row|
has_iterated = true unless has_iterated
end
has_iterated
end
</CODE>
Stupid code, I know.
I have two questions with it. The first is, would it be possible to set
it up to test the case when each_row