Displaying 20 results from an estimated 1000 matches similar to: "Edge, link_to and mocks"
2007 May 04
11
spec template for CRUD?
Hello,
Has anyone already come up with a set of shared behaviours that
someone could leverage when adhering to a CRUD concept, with respect
to controllers?
Relatedly, it would be nice if there were a way to share generalized
behaviour specs.
-Chris
2006 Jun 14
3
In memory IndexReader bug?
Hi All,
Hope all is going well.
I''m having trouble with the following code creating an in memory index
reader - it seems to be attempting to read from a file regardless.
Here''s the simple code:
require ''rubygems''
require ''ferret''
a = Ferret::Index::Index.new
r = Ferret::Index::IndexReader.new(nil)
Running the code on my OS X machine
2006 Jun 13
5
Grep style output?
Hi All,
Hope all is going well. Was just wondering if anyone has implemented a
grep style output page of hits using Ferret as the index/query engine?
Any thoughts about how best to implement it? The previous thread
discussess highlighting - would that be the best approach to follow or
is there a better way?
Cheers,
Marcus
--
Posted via http://www.ruby-forum.com/.
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,
2007 Jul 26
2
rspec_resource error
First of all hi, I''m new to the list, and rather new to rspec as will
probably show in myquestion.
I have tried installing rspec and rspec_on_rails as plugs both using
"script/install" and
"piston import" commands using the "current release install instructions"
here [1]. However,
there doesn''t seem to be any mention of the rspec_resource
2009 Jun 11
4
Using view helpers and route helpers in a model
Hi there,
I am trying to get something working and its driving me crazy. I have
been looking around for solutions to getting view helpers working in
models and for the most part I find this solution.
Add the following in the model you want to use them in
include ActionView::Helpers::UrlHelper
include ActionController::UrlWriter
However, when I try something like
2007 Sep 18
2
rSpec / Nested Routes / Mocks
I''m having a terrible time trying to test a nested route with rSpec.
I can''t seem to tell rSpec to expect the call @item.user. The
following error message plagues me not matter how I try to fuss with
the mock:
Spec::Mocks::MockExpectationError in ''ItemsController handling POST /
items should redirect to the new course on successful save''
Mock
2010 Sep 11
10
Having difficulty with threaded comments, using acts_as_tree
I''ve been having problems making threaded comments for the last few
days. Mainly with creating children and displaying the children.
Currently, I have comments shown at the bottom of my articles show view.
The top level comments work, but I do not really know how to implement a
way for users to "reply" to the top level comments and take them to a
form (the comment
2007 Jun 24
6
mocking errors
What is the correct way to mock out the errors on a Rails model?
I''m assuming i need to say
@mock_thing = mock_model(Thing)
@mock_thing_errors = mock("errors")
@mock_thing_errors.should_receive(:full_messages).and_return("An error")
@mock_thing.should_receive(:errors).and_return(@mock_thing_errors)
Just wanted to check the best practice on this kind of thing and how
2007 Jul 05
6
mocking methods in the controller.
Hi,
I''m very new to rspec so please be patient with me.
I''ve tried to take some of my tests out of the controller specs to check for
things that are rendered.
This has not worked so well, since my views have the controller method
current_user
in quite a few places.
Is there any way that I can define this so that my views will be executed?
Will this same thing occur for all
2007 Sep 14
2
Mocks in StoryRunner
Hi,
I''m trying to get up and running with StoryRunner. I have a story that
looks something like the following, but the call to mock_model
produces the exception listed below. Am I just misunderstanding the
concept? Are mocks not meant to be used in stories like this? Or is
this a bug? Changing @user to be an actual AR object makes things run
without error.
ENV["RAILS_ENV"] =
2007 Apr 19
5
Best practice thoughts: Model helpers, mocks
Hello! I''m pretty new to unit testing, and have only been using RSpec
for a few weeks. I found that for my controller specs, my setup
methods were getting very long building mocks/stubs for all the model
objects I needed to work with.
I''ve started creating helpers like the following for each of my
models. The "min_" methods are short for "minimum", and
2007 Dec 03
18
Need help mocking this out
Let''s say you''re using the restful_authentication plugin.
You have a model called articles. On the index action of the
articlescontroller you simply want to spec out that it''ll scope the results
to the ownership of the current_user.
It should NOT include any articles other than the articles that user owns.
How would you properly spec this out?
Thanks for the help!
2007 Sep 04
3
Model Specs: Fixtures vs Mocks + Stubs?
What is the general opinion about fixtures versus mocking and stubbing
in model specs? I heard from agile on IRC that they save the database
testing for integration testing, but I also see that the caboose
sample applicaiton uses fixtures. I also noticed that on the rspec
site, it says "Ironically (for the traditional TDD''er) these are the
only specs that we feel should actually
2007 Aug 27
2
issue with edge rails and urls
I just switched our project over to Edge Rails, and I''m running into
this problem with all of my helper methods that call _url methods:
NoMethodError in ''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
2007 Apr 20
1
getting controller specs to work on edge
I''m using edge spec, edge rspec_on_rails, edge rails. I just switched to
edge and ran the translator tool and I''m trying to get everything to pass
again. One of my issues is getting render back up and working for my
controller specs, here''s an example:
describe "Requesting /users using GET" do
controller_name :users
setup do
@user = mock_model(User)
2012 Aug 07
9
How do I force link_to/form helpers to use the superclass name in the path instead subclass?
I want my helpers to generate paths using a superclass instead of the
subclasses. Assuming I have Owner and Member that both inherit from User,
rails will use the current objects class name when generating paths:
Let''s say current_user is a mod: <%= link_to current_user.name,
current_user %> will generate "/mod/:id". I want to force it to generate
2007 Jul 18
5
Mocking Rails association collections
Rails model association collections allow you to do nifty things like:
article.comments.find(:all, :conditions => {:created_at > 1.day.ago})
Has anyone found a good way to mock this up? I''m currently doing this:
@comment1 = mock_model(Comment)
comments = mock(Array)
comments.stub!(:find).and_return([@comment1])
@article = mock_model(Article)
2010 Sep 09
17
formtastic issue
Hello,
I will try to explain it step by step :-)
I just created a new rails 3 app, then I created a new controller...
rails generate controller admin::users
I didn''t forget to add the resources in the routes.rb file like this.
namespace :admin do
resources :users
end
Now I try to use formtastic to create the form but I get erorr that my
users_path doesn''t exist?
2009 Feb 25
2
How to properly mock a complex object "comment.initiator.group.name"?
I am wondering what is the best way to mock such expression:
"comment.initiator.group.name"
What I do now is:
===========================
comment = mock_model(Comment)
initiator = mock_model(User)
group = mock_model(Group, :name => "Admin")
initiator.stub!(:group).and_return(group)
comment.stub!(:initiator).and_return(initiator)
===========================
So it becomes