Running resources_controller specs

2 views
Skip to first unread message

tomtt

unread,
May 5, 2009, 2:32:58 PM5/5/09
to resources_controller
There is a patch that I would like contribute, but I have not been
able to get the specs that come with resources_controller to run. I
have installed the garlic, rdoc and hanna gems and have done a "garlic
all". Then in all targets there are 636 examples, 33 failures, all of
which are "super: no superclass method `stub'".

Full output is here: http://gist.github.com/107111

Am I not running it from the right location? Am I missing something?

Cheers, Tom.

Ian White

unread,
May 5, 2009, 2:39:30 PM5/5/09
to resources_...@googlegroups.com
Hi Tom,

Thanks for taking the time to write.

Hmmm - looks like an rspec issue, this is an advertisement for having
a ci server, mine failed about 2 weeks ago and I haven't got around to
getting it back up again...

I'll look into this.

In the meantime, if you want to contribute your patch I can take a
look at it.

btw. I find that working within one of the garlic work targets (a
rails app), or a dummy, or real, rails app to be the best way of
developing new features. I then push those changes to the top level
plugin for garlic checkin across the other targets,.

Cheers,
Ian

tomtt

unread,
May 5, 2009, 3:03:45 PM5/5/09
to resources_controller

> In the meantime, if you want to contribute your patch I can take a  
> look at it.

Our situation is that we need a route that can have dynamic segments
without a corresponding static segment. (say /jmcnulty/posts/1 in
stead of /users/jmcnulty/posts/1). The way we implement this in the
routing is like so:
map.user ':id', :controller => 'users', :action => 'show'
map.with_options :path_prefix => ":user_id", :name_prefix => "user_"
do |user|
user.resources :posts, :only => [:index, :show]
end

The problem was in route_enclosing_names which assumes that when it
encounters a dynamic segment, that before that it will have
encountered a corresponding static segment. This assumption is not
true in our case, hence the following hack which checks if the
previous segment was a static one and only modifies the last element
if so, otherwise it adds a new one. The patch only does something
different in the case which originally just broke, therefore I am
confident it does not break anything else.

---
.../lib/ardes/resources_controller.rb | 15 ++++++++++++
+--
1 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/vendor/plugins/resources_controller/lib/ardes/
resources_controller.rb b/vendor/plugins/resources_controller/lib/
ardes/resources_controller.rb
index 06affe6..e6caa99 100644
--- a/vendor/plugins/resources_controller/lib/ardes/
resources_controller.rb
+++ b/vendor/plugins/resources_controller/lib/ardes/
resources_controller.rb
@@ -725,11 +725,22 @@ module Ardes#:nodoc:
#
# This is used to map resources and automatically load
resources.
def route_enclosing_names
+ last_segment_type = nil
@route_enclosing_names ||= returning(Array.new) do |req|
enclosing_segments.each do |segment|
unless segment.is_optional or segment.is_a?
(::ActionController::Routing::DividerSegment)
- req << [segment.value, true] if segment.is_a?
(::ActionController::Routing::StaticSegment)
- req.last[1] = false if segment.is_a?
(::ActionController::Routing::DynamicSegment)
+ if segment.is_a?
(::ActionController::Routing::StaticSegment)
+ req << [segment.value, true]
+ last_segment_type = :static
+ end
+ if segment.is_a?
(::ActionController::Routing::DynamicSegment)
+ if last_segment_type == :static
+ req.last[1] = false
+ else
+ req << [segment.key.to_s.sub('_id','').pluralize,
false]
+ end
+ last_segment_type = :dynamic
+ end
end
end
end
--
1.5.4.4

Ian White

unread,
May 5, 2009, 3:07:29 PM5/5/09
to resources_...@googlegroups.com
How does the garlic run go when the patch is applied? (does it result
in any extra errors?)

tomtt

unread,
May 5, 2009, 3:13:19 PM5/5/09
to resources_controller
On May 5, 8:07 pm, Ian White <ian.w.wh...@gmail.com> wrote:
> How does the garlic run go when the patch is applied? (does it result  
> in any extra errors?)

I have not written to rspec tests yet, just the code. I wanted to have
the specs running so that I could ensure sanity and then figure out
from there how to write specs.

Tom

tomtt

unread,
May 5, 2009, 3:20:20 PM5/5/09
to resources_controller
>> How does the garlic run go when the patch is applied? (does it result in any extra errors?)

Sorry, I should have though a bit harder and longer before writing my
previous reply :). After the patch is applied, there are still 636
examples, 33 failures.

Tom

Ian White

unread,
May 5, 2009, 3:27:08 PM5/5/09
to resources_...@googlegroups.com
> After the patch is applied, there are still 636
> examples, 33 failures.

that's a good start :) Given you;ve got the spec suite runnnig, you
can just ignore those 33 error for now, and get specing.

I prefer patches that have specs, because they help me (and others)
understand the patch. If you can write some that describe the
intended behaviour that would be great. The specs in rc are now over
2 years old, and spec style has changed a lot since then, so feel free
to depart from the style.

Cheers,
Ian

Reply all
Reply to author
Forward
0 new messages