|
View:
New views
20 Messages
—
Rating Filter:
Alert me
|
| < Prev | 1 - 2 | Next > |
|
|
undefined method `route_forHi all,
I am writing scenarios for testing my routes but it is giving me error as undefined method `route_for and also for params_from. Did i miss something which i need to add in my controller My code is as follows: require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') describe HomeController, "routes" do describe "route generation" do it "should map { :controller => 'home', :action => 'index' } to /home" do route_for(:controller => 'home', :action => 'index').should == '/home' end it "should map { :controller => 'home' } RESTfully" do params_from( :get, '/home' ).should == { :controller => 'home', :action => 'index' } end end end -- Posted via http://www.ruby-forum.com/. _______________________________________________ rspec-users mailing list rspec-users@... http://rubyforge.org/mailman/listinfo/rspec-users |
|
|
Re: undefined method `route_forOn Tue, Nov 10, 2009 at 4:44 AM, Amit Kulkarni <lists@...> wrote:
Hi all, route_to, route_for and params_from are all available in controller specs, which are identified by: 1. spec/controllers in their path (i.e. spec/controllers/foo_controller_spec
2. describe "route generation", :type => :controller do If neither of those cases is true, then you won't have access to the right helpers and matchers. HTH, David _______________________________________________ rspec-users mailing list rspec-users@... http://rubyforge.org/mailman/listinfo/rspec-users |
|
|
Re: undefined method `route_forThanks David for the information but still i am getting the same error.
What i have done is: I have home controller. now i am writing route scenarios in home_controller_spec.rb which is under spec/controllers directory I tried your code which looks like as describe "route generation", :type => :HomeController do it "should map { :controller => 'home', :action => 'index' } to /home" do route_for(:controller => 'home', :action => 'index').should == '/home' end it "should map { :controller => 'home' } RESTfully" do params_from( :get, '/home' ).should == { :controller => 'home', :action => 'index' } end end But it is not working,i know i am missing something. Also can you explain the first point? Can you tell me up what i need to add to get it running atleast :-) -- Posted via http://www.ruby-forum.com/. _______________________________________________ rspec-users mailing list rspec-users@... http://rubyforge.org/mailman/listinfo/rspec-users |
|
|
Re: undefined method `route_forOn Wed, Nov 11, 2009 at 1:42 AM, Amit Kulkarni <lists@...> wrote:
Thanks David for the information but still i am getting the same error. If the spec is in spec/controllers/home_controller_spec.rb, you don't need the :type argument, so just get rid of that and you should be fine. If this still doesn't work, please post the command you are using as well.
For future reference, if you put a controller or routing spec in another directory, then you do need the :type argument, but :type means the type of spec, not the type of controller: describe "route generation", :type => :controller do HTH, David _______________________________________________ rspec-users mailing list rspec-users@... http://rubyforge.org/mailman/listinfo/rspec-users |
|
|
Re: undefined method `route_forHi David still no success.
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') describe HomeController, "routes" do describe "route generation" do it "should map { :controller => 'home', :action => 'index' } to /home" do route_for(:controller => 'home', :action => 'index').should == '/home' end it "should map { :controller => 'home' } RESTfully" do params_from( :get, '/home' ).should == { :controller => 'home', :action => 'index' } end end end I am using "spec home_controller_spec.rb" by going under spec/controllers/ directory. -- Posted via http://www.ruby-forum.com/. _______________________________________________ rspec-users mailing list rspec-users@... http://rubyforge.org/mailman/listinfo/rspec-users |
|
|
Re: undefined method `route_forOn Nov 11, 2009, at 5:58 AM, Amit Kulkarni <lists@...> wrote:
> Hi David still no success. > require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') > describe HomeController, "routes" do > describe "route generation" do > it "should map { :controller => 'home', :action => 'index' } to / > home" > do > route_for(:controller => 'home', :action => 'index').should == > '/home' > end > > it "should map { :controller => 'home' } RESTfully" do > params_from( :get, '/home' ).should == { :controller => 'home', > :action => 'index' } > end > end > end > > I am using "spec home_controller_spec.rb" by going under > spec/controllers/ directory. Don't do that :) Go to the project root directory and say "spec spec/controllers/ home_controller_spec.rb" > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > rspec-users mailing list > rspec-users@... > http://rubyforge.org/mailman/listinfo/rspec-users _______________________________________________ rspec-users mailing list rspec-users@... http://rubyforge.org/mailman/listinfo/rspec-users |
|
|
Re: undefined method `route_forDavid Chelimsky wrote:
> On Nov 11, 2009, at 5:58 AM, Amit Kulkarni <lists@...> wrote: > >> >> it "should map { :controller => 'home' } RESTfully" do >> params_from( :get, '/home' ).should == { :controller => 'home', >> :action => 'index' } >> end >> end >> end >> >> I am using "spec home_controller_spec.rb" by going under >> spec/controllers/ directory. > > Don't do that :) > > Go to the project root directory and say "spec spec/controllers/ > home_controller_spec.rb" Hi David, I tried to run from the above command. It gets executed but i am not able to see any results as in 2 examples 2 passed something like that as it comes normally. -- Posted via http://www.ruby-forum.com/. _______________________________________________ rspec-users mailing list rspec-users@... http://rubyforge.org/mailman/listinfo/rspec-users |
|
|
Re: undefined method `route_forOn Wed, Nov 11, 2009 at 11:19 PM, Amit Kulkarni <lists@...> wrote:
Then how do you know it gets executed? _______________________________________________ rspec-users mailing list rspec-users@... http://rubyforge.org/mailman/listinfo/rspec-users |
|
|
Re: undefined method `route_forDavid Chelimsky wrote:
> On Wed, Nov 11, 2009 at 11:19 PM, Amit Kulkarni > <lists@...>wrote: > >> >> >> It gets executed but i am not able to see any results as in 2 examples 2 >> passed something like that as it comes normally. >> > > Then how do you know it gets executed? I dont know,When i run the command no result is displayed. Also error is not displayed. But why is this happening?Also how can i run this to test my routes? -- Posted via http://www.ruby-forum.com/. _______________________________________________ rspec-users mailing list rspec-users@... http://rubyforge.org/mailman/listinfo/rspec-users |
|
|
Re: undefined method `route_forOn Thu, Nov 12, 2009 at 11:32 PM, Amit Kulkarni <lists@...> wrote:
That likely means nothing is actually happening. Please post your spec_helper.rb. Also, what versions of rspec, rspec-rails, and rails are you using?
But why is this happening?Also how can i run this to test my routes? _______________________________________________ rspec-users mailing list rspec-users@... http://rubyforge.org/mailman/listinfo/rspec-users |
|
|
Re: undefined method `route_forMY spec helper contains following code:
# This file is copied to ~/spec when you run 'ruby script/generate rspec' # from the project root directory. ENV["RAILS_ENV"] ||= 'test' require File.expand_path(File.join(File.dirname(__FILE__),'..','config','environment')) require 'spec' require 'webrat' require 'spec/autorun' require 'spec/rails' require File.join( Rails.root, 'spec', 'macros' ) # Uncomment the next line to use webrat's matchers #require 'webrat/integrations/rspec-rails' # Requires supporting files with custom matchers and macros, etc, # in ./support/ and its subdirectories. Dir[File.expand_path(File.join(File.dirname(__FILE__),'support','**','*.rb'))].each {|f| require f} Spec::Runner.configure do |config| config.include(ModelExampleGroupHelper, :type => :model) config.include(ControllerExampleGroupHelper, :type => :controller) # If you're not using ActiveRecord you should remove these # lines, delete config/database.yml and disable :active_record # in your config/boot.rb config.use_transactional_fixtures = true config.use_instantiated_fixtures = false config.fixture_path = RAILS_ROOT + '/spec/fixtures/' config.include Webrat::Matchers, :type => :views # == Fixtures # # You can declare fixtures for each example_group like this: # describe "...." do # fixtures :table_a, :table_b # # Alternatively, if you prefer to declare them only once, you can # do so right here. Just uncomment the next line and replace the fixture # names with your fixtures. # # config.global_fixtures = :table_a, :table_b # # If you declare global fixtures, be aware that they will be declared # for all of your examples, even those that don't use them. # # You can also declare which fixtures to use (for example fixtures for test/fixtures): # # config.fixture_path = RAILS_ROOT + '/spec/fixtures/' # # == Mock Framework # # RSpec uses it's own mocking framework by default. If you prefer to # use mocha, flexmock or RR, uncomment the appropriate line: # # config.mock_with :mocha # config.mock_with :flexmock # config.mock_with :rr # # == Notes # # For more information take a look at Spec::Runner::Configuration and Spec::Runner end def login controller.stub!( :logged_in? ).and_return( true ) controller.stub!( :login_required ).and_return( true ) @current_user = mock_model( User, :id => 1, :time_zone => 'Rome', :idiom => 'it', :login => 'quentin', :email => 'foo@...', :can_join? => true ) controller.stub!( :current_user ).and_return( @current_user ) end def login_as( name ) controller.stub!( :logged_in? ).and_return( true ) controller.stub!( :login_required ).and_return( true ) @current_user = users(name) controller.stub!( :current_user ).and_return( @current_user ) end def valid_channel_attributes { :brand_name => 'RspecChannel' } end def valid_user_attributes { :login => 'testtest', :password => '555555', :password_confirmation => '555555', :email => 'test@...', :idiom => 'it', :privacy => '1', } end def create_channel(args=nil) args ||= valid_channel_attributes Channel.create args end def create_user(args = nil) args ||= valid_user_attributes User.create args end #~ %w!User Contest Video Print Radio Banner Conceptl!.each do |model| #~ model.constantize.any_instance.stubs(:save_attached_files).returns(true) #~ end rspec = 1.2.9 rspec-rails - 1.2.9 rails = 2.1.2 -- Posted via http://www.ruby-forum.com/. _______________________________________________ rspec-users mailing list rspec-users@... http://rubyforge.org/mailman/listinfo/rspec-users |
|
|
Re: undefined method `route_forOn Fri, Nov 13, 2009 at 2:28 AM, Amit Kulkarni <lists@...> wrote: MY spec helper contains following code: There's your problem. The last version of rspec that supports rails 2.1.x is 1.1.12. See http://github.com/dchelimsky/rspec-rails/blob/master/History.rdoc.
_______________________________________________ rspec-users mailing list rspec-users@... http://rubyforge.org/mailman/listinfo/rspec-users |
|
|
Re: undefined method `route_forOh that means if i am using rails version 2.1.2 or more then i need to
have rspec version 1.1.12. In that case i need to remove the latest version and install rspec 1.1.12. I will do it and update you asap. Thanks a lot David. -- Posted via http://www.ruby-forum.com/. _______________________________________________ rspec-users mailing list rspec-users@... http://rubyforge.org/mailman/listinfo/rspec-users |
|
|
Re: undefined method `route_forAmit Kulkarni wrote:
> Oh that means if i am using rails version 2.1.2 or more then i need to > have rspec version 1.1.12. > In that case i need to remove the latest version and install rspec > 1.1.12. > I will do it and update you asap. > Thanks a lot David. Hi David, As per the doc i updated my gems.Version of my gems are : Rails : 2.1.2 Rspec : 1.1.12 Rspec-Rails : 1.1.12 But when i run my files same error is being displayed. I am working on Windows vista.Does this may impact running my spec? Please suggest. -- Posted via http://www.ruby-forum.com/. _______________________________________________ rspec-users mailing list rspec-users@... http://rubyforge.org/mailman/listinfo/rspec-users |
|
|
Re: undefined method `route_forOn Tue, Nov 17, 2009 at 4:53 AM, Amit Kulkarni <lists@...> wrote:
This back and forth is not productive. Please zip up the app and send it to me so I can see the whole thing in context. Thanks, David _______________________________________________ rspec-users mailing list rspec-users@... http://rubyforge.org/mailman/listinfo/rspec-users |
|
|
Re: undefined method `route_forOk Fine.That sounds to be a good idea.
Thanks -- Posted via http://www.ruby-forum.com/. _______________________________________________ rspec-users mailing list rspec-users@... http://rubyforge.org/mailman/listinfo/rspec-users |
|
|
Re: undefined method `route_forAmit Kulkarni wrote:
> Ok Fine.That sounds to be a good idea. > Thanks Hi David, Good news,My routing scenarios are working now. I dont know how but it did.I was going to mail you the app but it is working fine now. -- Posted via http://www.ruby-forum.com/. _______________________________________________ rspec-users mailing list rspec-users@... http://rubyforge.org/mailman/listinfo/rspec-users |
|
|
Re: undefined method `route_forOn Thu, Nov 26, 2009 at 1:21 AM, Amit Kulkarni <lists@...> wrote:
Excellent! _______________________________________________ rspec-users mailing list rspec-users@... http://rubyforge.org/mailman/listinfo/rspec-users |
|
|
Re: undefined method `route_forHi David,
I have some query regarding running spec command. When i tried to run normal testcase by command "spec test_controller_spec.rb" then that particular test case runs but the routing testcase fails. Now if i run through the command "spec spec/controllers/test_controller_spec.rb" then all the spec runs including the routing spec. Can you tell me why is this happening? -- Posted via http://www.ruby-forum.com/. _______________________________________________ rspec-users mailing list rspec-users@... http://rubyforge.org/mailman/listinfo/rspec-users |
|
|
Re: undefined method `route_forOn Mon, Dec 7, 2009 at 5:32 AM, Amit Kulkarni <lists@...> wrote:
Hi David, rspec-rails creates different ExampleGroup subclasses for each type of spec (model, view, controller, helper). It knows which type to create based on the presence of "spec/controllers" (in this case) in the file's runtime path, so you need to run specs from the project root in order for rspec to make this determination.
HTH, David _______________________________________________ rspec-users mailing list rspec-users@... http://rubyforge.org/mailman/listinfo/rspec-users |
| < Prev | 1 - 2 | Next > |
| Free embeddable forum powered by Nabble | Forum Help |