similar to: spec''in controllers request for nested routes

Displaying 20 results from an estimated 400 matches similar to: "spec''in controllers request for nested routes"

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))
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 Sep 29
1
mock_model named spaces not working
I have a namespace called saltmines The following will fail the spec @player = mock_model(Saltmines::Player) 1) ActionView::TemplateError in ''/saltmines/players/index.rhtml should render list of saltmines/players'' 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.each On line #9 of
2009 Dec 21
3
beginner problem
Hi, I´m starting using rails. I have one problem. I create a controller, the code is the next: class PlayersController < ApplicationController scaffold:player end I did all the things that I suppose to do, but a problem appears when try to open my webpage application. The error is the next NoMethodError in PlayersController#index undefined method `scaffold'' for
2005 Dec 14
5
inserting multiple rows
I have table which stores multiple entries. Each row has user_id, game_id and a pick_id. On a page the user has to make load of choices. All this gets submitted. the html looks like so: <input type="hidden" name="game_id" value="3"> <input type="hidden" name="user_id" value="19"> <select name="pick[3]"> ....
2008 Apr 07
7
Saving attribute
Something is getting lost here. def create @home = Team.find_by_user_id(current_user.id) for player in @home.players player.update_attribute(:game_id, @game.id) end end def show @players = Player.find_all_by_game_id(params[:id]) end view <%= @players.size %> # mistakenly equals zero Played with the console and everything should be working fine...
2013 Apr 03
1
validates uniqueness scope allow_blank/allow_nil -> validation error
I have this in a model: class GenreBadge < ActiveRecord::Base belongs_to :game, counter_cache: :genre_badges_count, touch: true belongs_to :genre validates :game_id, uniqueness: {scope: :genre_id}, allow_blank: true end When I get one existing genre badge genre_badge = game.genre_badges.first genre_badge.game_id = nil genre_badge.save! It creates an validation exception:
2007 Jun 02
7
I''m really bad at controllers, help please.
Hey, Sorry for so many questions - I''m really bad at this right now. I''m trying to cover the following code w/ rspec def index if params[:user_id] @user = User.find(params[:user_id]) @messages = @user.messages end end So basically what I''m doing is listing all the messages for a user, provided there is an id parameter. describe
2007 Nov 21
7
describe AddressesController, "handling GET /addresses" do
Hello, I''m working with scaffold generated controller test code for handling GET requests. Address is the model being tested. Address belongs_to Company, Company has_many addresses. In my addresses_controller I have: before_filter :get_company def index @addresses = @company.addresses.find(:all) respond_to do |format| format.html # index.html.erb format.xml {
2007 Oct 26
3
Specing with Subdomains as Account Keys
How do you go about implementing and rspecing subdomains as account keys? I''m sure that this must be an issues for others as well. So I have an app using subdomains as account keys. The Application Controller sets up @current_company in a before filter. Everything is done within the context of the @current_company. After reading about Demeter''s Revenge
2007 Nov 13
2
More Rails Pattern Examples?
Hi, I have been reading the documentation and examples on the rspec site. There are two "patterns" from Rails that I am not clear how to implement that are kind of related, and so I am not sure how to start. Does anyone have any examples of how to write rspecs for these? 1/ Nested resources. 2/ Resources that are specific to the current_user. In other words, I only want to
2008 Jun 07
2
When to send "post" and "get" in blocks.
Hi, I''m new to RSpec. I have a question about how to write controller specs. Here''s a code generated by scaffolding (with Rspec). def do_get get :index end it "should be successful" do do_get response.should be_success end it "should render index template" do do_get response.should
2007 Sep 30
9
Problems with testing nested routes using mocking
Hello forum I have there to files #----- virtual_host_controller.rb class VirtualHostsController < ApplicationController before_filter :capture_domain # GET /domain/1/virtual_hosts/1 def show @virtual_host = @domain.virtual_hosts.find(params[:id]) respond_to do |format| format.html # show.rhtml end end private def capture_domain if
2008 Jan 30
3
Order of the get call and xxx.should
Just out of curiosity, why is that the following .should calls have to differ to work? The first is a normal check on the if the user is redirected if not logged in ========= it "should redirect the user to the login screen" do do_get response.should redirect_to(new_session_url) end The second is checking to ensure that the proper user validation method is called ========= it
2007 Oct 16
3
Controller iterating through returned records and appending to each
I have a controller that gets a list of employees (which has an "include => [:salaries, :incentives, :billablegoals, :reviews]"). I then need it to iterate through each employee and determine their current active goal based on the "effective date." After playing around with it a bunch, I got the following to work. Only problem is that if I remove the "@employees.each {
2006 Apr 07
5
Confusion about has_many / belongs_to ...
I have a table called players and its model Player, and I have a table called games and its model Game. In the games table I have: player1_id int(11) player2_id int(11) I want the tables to be associated so that I can access the player objects using table.player1 and table.player2 rather than having to lookup the objects based on the ids. I am not sure how to go about this but I suspect I
2007 Feb 15
4
defining context(s) dynamically
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type"> <title></title> </head> <body bgcolor="#ffffff" text="#000000"> Q. Why does code which defines a context work in the
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)
2007 Oct 11
2
Login testing ideas
I''ve been going through Pat''s example story and noticed that there was no checking for a bad login. I assume this is because that would have made the article bigger and more complicated than it needed to be. So the question that comes of of this is: How do folks normally handle the negative case? My plan was to just use another scenario, but as a new person to BDD/TDD,
2007 Sep 14
2
Testing a nested controller
Hey everyone. I really stuck on testing a nested controller. I''m trying to make a request using get and afterwards checking the response by response.should ... My routes.rb looks like this: map.resources :writers do |writers| writers.resources :notes end In my notes_controller_spec.rb def do_get writer_id = 1 note_id = 1 get note_path(writer_id, note_id) end it "should show