[rspec-users] action_web_services error with rspec_on_rails

Scott Taylor mailing_lists at railsnewbie.com
Mon Mar 19 19:00:09 EDT 2007


I now have two specs in my rails project which correspond to one  
rails controller.  I can run them individually and they pass, but  
running them together (either with the rake task just putting both  
files on the command line):

euclid% spec spec/controllers/crud_resource_controller_spec.rb spec/ 
controllers/crud_resource_controller_with_join_models_spec.rb
/Users/smtlaissezfaire/Sites/rails/dictionary/vendor/rails/ 
actionwebservice/lib/action_web_service/container/ 
action_controller_container.rb:74:in `require_web_service_api':  
neither _api or _api found (NameError)
         from /Users/smtlaissezfaire/Sites/rails/dictionary/vendor/ 
rails/actionwebservice/lib/action_web_service/container/ 
action_controller_container.rb:48:in `web_service_api'
         from /Users/smtlaissezfaire/Sites/rails/dictionary/vendor/ 
rails/actionwebservice/lib/action_web_service/container/ 
action_controller_container.rb:85:in  
`inherited_without_action_controller'
         from /Users/smtlaissezfaire/Sites/rails/dictionary/vendor/ 
rails/actionwebservice/lib/action_web_service/dispatcher/ 
action_controller_dispatcher.rb:32:in `inherited'
         from ./spec/controllers/ 
crud_resource_controller_with_join_models_spec.rb:5:in `initialize'
         from ./spec/controllers/ 
crud_resource_controller_with_join_models_spec.rb:5:in `new'
         from ./spec/controllers/ 
crud_resource_controller_with_join_models_spec.rb:5:in  
`one_join_model_setup'
         from ./spec/controllers/ 
crud_resource_controller_with_join_models_spec.rb:13
         from /opt/local/lib/ruby/gems/1.8/gems/rspec-0.8.2/lib/spec/ 
runner/context.rb:14:in `class_eval'
          ... 11 levels...
         from /opt/local/lib/ruby/gems/1.8/gems/rspec-0.8.2/lib/spec/ 
runner/command_line.rb:18:in `run'
         from /opt/local/lib/ruby/gems/1.8/gems/rspec-0.8.2/bin/spec:4
         from /opt/local/bin/spec:16:in `load'
         from /opt/local/bin/spec:16


I'm not using webservices at all:  So can someone clue me into what  
is going on or point me in the right direction?  Here are the two specs:


#spec one
require File.dirname(__FILE__) + '/../spec_helper'

def one_join_model_setup
   unless defined? CommentController
     Object.const_set("CommentController", Class.new 
(CrudResourceController))
   end
   #CommentController.class_eval { join_models :post }
   controller_name 'comment'
end

context "join_model" do
   one_join_model_setup
end


## spec two

require File.dirname(__FILE__) + '/../spec_helper'

def testing_crud_setup
   unless defined? TestingCrudController
     Object.const_set("TestingCrudController", Class.new 
(CrudResourceController))
   end
   controller_name 'testing_crud'
end


context "An Inherited Controller" do
   testing_crud_setup

   specify "should subclass from CrudResourceController" do
     TestingCrudController.superclass.to_s.should == 
("CrudResourceController")
   end

   specify "should be an instance of TestingCrudController" do
     controller.should be_an_instance_of(TestingCrudController)
   end
end


# more contexts - I believe the revelent code stops here
context "model_name" do
   testing_crud_setup

   specify "should be a private method" do
     controller.private_methods.include?("model_name").should == true
   end

   specify "should be the controller name" do
     controller.send(:model_name).should == "TestingCrud"
   end
end

context "generic_variable" do
   testing_crud_setup

   specify "should be a private method" do
     controller.private_methods.include?("generic_variable").should  
== true
   end

   specify "should return the controller name in underscore case" do
     controller.send(:generic_variable).should == "testing_crud"
   end
end




Thanks for all of your help,

Scott Taylor






More information about the rspec-users mailing list