Write functional test cases for an rails app having no model


I have a rails application that has a Application controller that
exposes REST API. And for the data I am using a third party module
instead of rails Model.


  match "/plugins" => "plugins#get_plugins", :via => "get"

My controller has following method:
  def get_plugins
    render :text=> third_party_module.get_plugins()

third_party_module.get_plugins() is the third party module that returns

Functional test file: plugins_controller_test.rb has the following test
  test "should get plugins" do
    get :get_plugins
    assert_response :success

When I am trying to run functional test, it gives following error:
"db/schema.rb doesn't exist yet. Run "rake db:migrate" to create it then
try again"

As I am not using any database.

Please help.


I can reproduce your problem.

On rails 3.1.3, when installing the “standard” way, I get this:

peterv@ASUS:~/b/rails-apps/apps/temp/with_AR$ rails new with_AR --skip-bundle

add gem ‘therubyracer’ to Gemfile and run bundle install

peterv@ASUS:~/b/rails-apps/apps/temp/with_AR$ rake environment

peterv@ASUS:~/b/rails-apps/apps/temp/with_AR$ rake test:functionals

/home/peterv/data/backed_up/rails-apps/apps/temp/with_AR/db/schema.rb doesn’t exist yet. Run “rake db:migrate” to create it then try again. If you do not intend to use a database, you should instead alter /home/peterv/data/backed_up/rails-apps/apps/temp/with_AR/config/application.rb to limit the frameworks that will be loaded

So, to me this is quite clear about the issue …

As easy solution, I then installed without ActiveRecord (read rails help to find out):

peterv@ASUS:~/b/rails-apps/apps/temp$ rails new without_AR --skip-bundle --skip-active-record

add gem ‘therubyracer’ to Gemfile and run bundle install

peterv@ASUS:~/b/rails-apps/apps/temp/without_AR$ rake environment

peterv@ASUS:~/b/rails-apps/apps/temp/without_AR$ rake test:functionals

#=> OK

The difference is this:

peterv@ASUS:~/b/rails-apps/apps/temp/without_AR$ diff …/with_AR/config/application.rb config/application.rb


< require ‘rails/all’