similar to: how to spec views

Displaying 20 results from an estimated 1000 matches similar to: "how to spec views"

2007 Oct 06
4
spec''ing views, mock_model associations
I writing a spec that returns the count of how many players in a game: it "should how many players in a link to all players" do render :partial =>"games/game", :object => @game response.should have_tag(''a'',"(2) Players") end I''m not sure how to do the mock model, I think it would be done two ways but unsure of the syntax: 1: add
2007 Feb 11
1
Specing Rails Views
Hello - I''m currently trying to write some specs for my rails views. My views depend upon the restful authentication plugin method logged_in? Like so, <% if logged_in? %> <ul id="product-admin-nav"> <dd><%= link_to "create a new product", new_product_url %></dd> </ul> <% end %> However, when I have the following
2008 Aug 08
2
template.expect_render fails when partial is rendered from a helper
My spec; describe ''subnav rendering while logged in'' do before do template.stub!(:logged_in?).and_return(true) template.stub! (:current_profile).at_least(:once).and_return(mock_profile) end def do_render render "/homepages/show.html.erb" end it "should render the logged in partial for homepages" do
2007 Jul 06
3
stubbing helper methods for View specs
Hi there I have several view specs, that include the following snippet in their "before" block to stub the methods by acts_as_authenticated before :each do @u = mock_model(User) @u.should_receive(:name).and_return("Hans Muster") template.should_receive(:logged_in?).and_return(true) template.should_receive(:current_user).and_return(@u) end this
2007 Sep 16
4
"Not Implemented" doesn''t show
I''m going through Peepcode''s Rspec Basics for an overview. He''s just doing a simple spec: class PeepCode end describe PeepCode do it "should be awsome" do end end So running spec spec/simple_spec.rb should produce according to his screen cast: 1 example, 0 failures, 1 not implemented but I only recieve: 1 example, 0 failures Also spec
2008 Jan 30
2
Stubbing controller methods vs model methods
I had an error that I couldn''t figure out, then when writing up a question for the forum I figured it out. The thing is I don''t understand why the change that was made works and why what existed before didn''t. Here is the initial post when I had the error: ---------------------------------- In the controllers/application.rb file I have a method that finds the account
2007 Oct 12
6
locals in partials
hiya, in specing a partial, how can i assign a local var that is normally passed via :locals ? i tried adding :locals => to the render call but that doesnt seem to take linoj -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20071012/fd0acd92/attachment.html
2007 Oct 05
13
spec''ing view render partial collection, local variable not found
I''m trying to spec out a render partial collection but I get the following error 2) NoMethodError in ''/games/_game.rhtml should show game name'' undefined method `body'' for #<#<Class:0x316580c>:0x2f1154c> /Volumes/EXTERNAL/web/omenking.ca/vendor/plugins/rspec_on_rails/lib/spec/rails/matchers/have_text.rb:12:in `matches?''
2007 May 29
5
Trouble defining a stub method for a controller
Hello, Not sure if I am doing something really wrong (let''s not say stupid for now), but I haven''t been able to stub a controller method like: controller.stub!(:logged_in?).and_return(true) Please help, this is driving me nuts ;-) -- An?bal Rojas http://www.rubycorner.com http://www.hasmanydevelopers.com
2008 Mar 05
3
having trouble specing an ajax request
Do I need to spec an AR. If yes, what is the best way to spec this. here is the code - def index @deals = Deal.paginate(:all, :conditions => prepare_search_conditions, :order => ''created_at DESC'', :page => params[:page] ) if request.xhr? render :update do |page| page.replace_html "table", :partial =>
2007 May 21
9
Ordering in view specs using have_tag and with_tag
When writing view specs is there any way to test not only for the presence of tags (have_tag) and nested tags (with_tag), but also test that they appear in a given order? For example, consider the following: it ''should display the login names, display names and email address in alternating rows'' do response.should have_tag(''div.odd>div'') do
2007 Oct 05
7
Easy AR association stubbing
I''ve added a method to the mock class that makes it pretty easy to stub associations in rails. I''ve been using it for awhile and it seems to cut down on a lot of setup code for the controller and model specs that use associations. #before @person = mock_model(Person) posts = mock(''post_proxy'') posts.stub!(:build).and_return(mock_model(Post, :save => true))
2008 May 03
4
silly partial qu
hi all, i''m just trying to check a partial has been rendered, by using: response.template.should_receive(:render).with(:partial => "tasks/list") this passes, even if I put something bogus in the partial name, such as: response.template.should_receive(:render).with(:partial => "___tassdfsdfks/list") does anyone know why this doesn''t fail? is this the
2007 Dec 29
15
Do you think it would look cleaner?
I was looking over some of my specs. I was thinking that the following: @game.should_receive(:name).and_return(''The Battle for Blaze'') @game.should_receive(:people).and_return(5000000) @game.should_receive(:activated).and_return(true) Would it look cleaner if I could do this instead? @game.should_recieve_and_return( :name => ''The Battle for Blaze''
2007 Feb 13
16
Error against latest trunk while testing via spec for model
Hi I just did an update to lates trunk ================= context "Given a generated venue_spec.rb with fixtures loaded" do fixtures :venues specify "fixtures should load two Venues" do Venue.should have(2).records end end ================== gives me ========== 1) TypeError in ''Given a generated venue_spec.rb with fixtures loaded fixtures should load two
2007 Aug 17
11
[rspec] looking for a simple refresher
I''ve been off the rspec for a few months and I''m trying to get back on it. 1) Spec::Mocks::MockExpectationError in ''TicketsController handling POST /tickets should create a new ticket'' Mock ''Ticket_1001'' expected :new with ({}) once, but received it 0 times ./spec/controllers/tickets_controller_spec.rb:16: script/spec:4: class
2007 Feb 04
10
Spec''ing ActionMailer
Good morning (Pacific Time). I have a controller action that, as a side-effect, sends an email to an administrator. I want it to do something like this: specify "when someone successfully signs up, an email should be sent to the administrator with the person''s contact page" do post :signup, {...lots o'' params} response should_be success #
2007 Oct 26
2
Examples of writing controller specs that use authentication
Hello, I''m working on specs for a controller that handles authentication using the restful_authentication plugin. I''m trying to find a resource (tutorial or examples, if possible) about the best way to go about writing mocks and specs to make sure that things like my before_filters are working correctly. Does anyone know of any good resources for this? Thanks, Les
2007 Oct 09
23
Testing layouts with RSpec on Rails
Hey guys, Does anyone have any wisdom to share on the subject of speccing Rails layouts? Most of it''s plain old view specs stuff, but are there sensible ways to verify things like the yield call? (Mocking doesn''t catch that) Thanks, Matt -- Matt Patterson | Design & Code <matt at reprocessed org> | http://www.reprocessed.org/
2007 Oct 08
6
spec''in controllers request for nested routes
describe PlayersController, "handling GET /saltmines/games/1/players" do before do @game = mock_model(Game, :to_param => "1") @game.stub_association!(:players, :find => mock_model(Player)) end def do_get get :index, :game_id => @game end it "should be successful" do do_get response.should be_success end it "should