Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4064040
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T15:48:14+00:00 2026-05-20T15:48:14+00:00

I can run my tests by just running parts of my code via RubyMine

  • 0

I can run my tests by just running parts of my code via RubyMine (rightklick into _spec.rb file and run). But, by running “rake spec” I get an error. The table is removed and not rebuilt bevore each test. I know it makes sence, but not if it’s not rebuilt again.
Things like db:test:load, db:test:prepare, db:test:clone_sturcture also don’t work.When i just run “rake spec” I get this errors:

C:\RubyStack\ruby\bin\ruby.exe -e $stdout.sync=true;$stderr.sync=true;load($0=ARGV.shift) C:\RubyStack\ruby\bin\rake spec
Testing started at 14:11 ...
(in E:/idun/ComServer_v0.0/source)
C:/RubyStack/ruby/bin/ruby.exe -S bundle exec rspec ./spec/controllers/customer_controller_spec.rb
Empty test suite.

ActiveRecord::StatementInvalid: Mysql2::Error: Table 'comserver_test.customers' doesn't exist: DELETE FROM `customers`
C:/RubyStack/ruby/lib/ruby/gems/1.9.1/gems/activerecord-3.0.5/lib/active_record/connection_adapters/abstract_adapter.rb:207:in `rescue in log'
C:/RubyStack/ruby/lib/ruby/gems/1.9.1/gems/activerecord-3.0.5/lib/active_record/connection_adapters/abstract_adapter.rb:199:in `log'
C:/RubyStack/ruby/lib/ruby/gems/1.9.1/gems/mysql2-0.2.6-x86-mingw32/lib/active_record/connection_adapters/mysql2_adapter.rb:314:in `execute'
C:/RubyStack/ruby/lib/ruby/gems/1.9.1/gems/activerecord-3.0.5/lib/active_record/connection_adapters/abstract/database_statements.rb:288:in `update_sql'
C:/RubyStack/ruby/lib/ruby/gems/1.9.1/gems/mysql2-0.2.6-x86-mingw32/lib/active_record/connection_adapters/mysql2_adapter.rb:331:in `update_sql'
C:/RubyStack/ruby/lib/ruby/gems/1.9.1/gems/activerecord-3.0.5/lib/active_record/connection_adapters/abstract/database_statements.rb:293:in `delete_sql'
C:/RubyStack/ruby/lib/ruby/gems/1.9.1/gems/activerecord-3.0.5/lib/active_record/connection_adapters/abstract/database_statements.rb:54:in `delete'
C:/RubyStack/ruby/lib/ruby/gems/1.9.1/gems/activerecord-3.0.5/lib/active_record/connection_adapters/abstract/query_cache.rb:16:in `delete'
C:/RubyStack/ruby/lib/ruby/gems/1.9.1/gems/arel-2.0.9/lib/arel/crud.rb:34:in `delete'
C:/RubyStack/ruby/lib/ruby/gems/1.9.1/gems/activerecord-3.0.5/lib/active_record/relation.rb:273:in `delete_all'
C:in `delete_all'
E:/idun/ComServer_v0.0/source/spec/controllers/customer_controller_spec.rb:20:in `block (2 levels) in <top (required)>'
C:/RubyStack/ruby/lib/ruby/gems/1.9.1/gems/rspec-core-2.5.1/lib/rspec/core/hooks.rb:29:in `instance_eval'

*_spec.rb:

require 'spec_helper'
require 'customer'
require 'rack/test'
require 'rspec'
require 'logger'

RSpec.configure do |conf|
  conf.include Rack::Test::Methods
end

def app
  Rails::Application
end

describe "customers" do

  render_views

  before(:each) do
    Customer.delete_all
  end

  describe "GET on /customers/:id" do
    before(:each) do
      Customer.create(
        :gmsid => 1,
        :online => true,
        :pinged_at => DateTime.now
      )
    end

    it "should return a customer by id" do
      @response = get("/customers/1")
      @response.status.should eq(200)
      attributes = ActiveSupport::JSON.decode(@response.body)
      attributes['customer']["online"].should be_true
    end

    it "should return \"null\" if customer not found" do
      @response = get('/customers/2')
      @response.body.to_s.should eq("null")
    end
  end

  describe "should POST on /customers" do
    it "should create a user" do
      customer =  Customer.new(
        :gmsid => 2,
        :online => false,
        :pinged_at => DateTime.now
      )
      puts customer
      json = ActiveSupport::JSON.encode(customer)
      @response = post('/customers', json)
      @response.status.should eq(200)
      @response = get('/customers/2')
      attributes = ActiveSupport::JSON.decode(@response.body)
      attributes['customer']['gmsid'].should eq(2)
      attributes['customer']['online'].should be_false
    end
  end

  describe "should PUT on /customers/:id" do
     before(:each) do
      Customer.create(
        :gmsid => 1,
        :online => false,
        :pinged_at => DateTime.now
      )
    end

    it "should update a user to status true" do
      @response = put('/customers/1', ActiveSupport::JSON.encode(Customer.new(
          :online => true
      )))
      @response.status.should eq(200)
      @response = get('/customers/1')
      attributes = ActiveSupport::JSON.decode(@response.body)
      attributes['customer']['online'].should be_true

    end

    it "when user doesn't exist should return null" do
      @response = put('/customers/2', ActiveSupport::JSON.encode(Customer.new(
          :online => true
      )))
      @response.status.should eq(200)
      @response.body.to_s.should eq("null")
    end
  end

  describe "should DELETE on /customers/:id" do
    it "should delete a existing user" do
      Customer.create(
          :gmsid => 1,
          :online => true,
          :pinged_at => DateTime.now
      )
      @response = get('/customers/1')
      #test if customer with gmsid 1 is in database
      @response.status.should eq(200)
      attributes = ActiveSupport::JSON.decode(@response.body)
      attributes['customer']['gmsid'].should eq(1)
      #delete customer with gmsid 1
      @response = delete ('/customers/1')
      @response.status.should eq(200)
      #check if customer with gmsid 1 is not in database anymore
      @response = get ('/customers/1')
      @response.status.should eq(200)
      @response.body.to_s.should eq("null")
    end
  end
end
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T15:48:15+00:00Added an answer on May 20, 2026 at 3:48 pm

    Ok, I solved the problem.

    It was the “libmysql.dll problem” discussed here.

    Problem is the mysql 5.0 Version. It should be higher than 5.1. So, I just changed the “libmysql.dll” to one from a newer mysql version. It worked.
    You need this to create a proper dump from your development environment (db:schema:dump).
    This command creates a schema.rb in your project.
    This schema is used by “db:test:prepare”, which is invoked everytime when executing “rake spec”, before testing. This schema.rb was empty, so no tables habe been created.
    Sounds logically to me.

    Please correct me if I’m wrong.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I can run tasks as part of our functional tests just fine using this
I want to write a CMakeLists.txt so that I can run my tests normally
Can I run nUnit tests in Visual Studio (for instance)?
In TestDriven.Net I can set the following from the TestDriven.Net Options Pane Run tests
From Eclipse I can easily run all the JUnit tests in my application. I
what behaviour can I expect when I run this code: do while(testA) { //
I'm trying to run the sample unit tests for the sample code that ships
After always running monolithic blocks of code from within my AppController object, I've just
I just hit the behaviour where nose will not run tests marked as executable
How can you run AsUnit test runner from Ant? I'm on the Mac OS

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.