RoR error, issue with my Gemfile or test configuration

Question

I am fully aware that I asked a similar question before, but this time I have a lot more details about the situation.

it seems like I cant test my application because there is something wrong with my Gemfile or test configuration.

Apparently this is also known as an RoR error.

I am using the cloud9 development environment, and my workspace is running ruby 2.3.0p0 (2015-12-25 revision 53290) [x86_64-linux].

the following is my Gemfile:

source 'https://rubygems.org'

gem 'devise'

gem 'bootstrap-sass'
#modernizr
gem 'modernizr-rails'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'

# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.2.6'
# Use sqlite3 as the database for Active Record
gem 'sqlite3'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 5.0'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# Use CoffeeScript for .coffee assets and views
gem 'coffee-rails', '~> 4.1.0'
# See https://github.com/rails/execjs#readme for more supported runtimes
# gem 'therubyracer', platforms: :ruby

# Use jquery as the JavaScript library
gem 'jquery-rails'
# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
gem 'turbolinks'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.0'
# bundle exec rake doc:rails generates the API under doc/api.
gem 'sdoc', '~> 0.4.0', group: :doc

# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'

# Use Unicorn as the app server
# gem 'unicorn'

# Use Capistrano for deployment
# gem 'capistrano-rails', group: :development

group :development, :test do
  # Call 'byebug' anywhere in the code to stop execution and get a debugger console
  gem 'byebug'

  # Access an IRB console on exception pages or by using <%= console %> in views
  gem 'web-console', '~> 2.0'

  # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
  gem 'spring'
end

gem 'haml-rails'

When I run rake test I get the following error:

> [NOTE]
>
> You may have encountered a bug in the Ruby interpreter or extension libraries.
>
> Bug reports are welcome.
> For details: http://www.ruby-lang.org/bugreport.html
>
> Aborted

I got 3 controllers in my application and two of them are models. The 3rd controller is just a controller I made to handle the main views (the main interface) its not a model.

I generated the 3rd model as a standalone controller but the other two controllers are part of scaffolds that I generated. (Client and Project)

This is my clients controller test:

require 'test_helper'

class ClientsControllerTest < ActionController::TestCase
  setup do
    @client = clients(:one)
  end

  test "should get index" do
    get :index
    assert_response :success
    assert_not_nil assigns(:clients)
  end

  test "should get new" do
    get :new
    assert_response :success
  end

  test "should create client" do
    assert_difference('Client.count') do
      post :create, client: { name: @client.name, email: @client.email + "create" }
    end

    assert_redirected_to client_path(assigns(:client))
  end

  test "should show client" do
    get :show, id: @client
    assert_response :success
  end

  test "should get edit" do
    get :edit, id: @client
    assert_response :success
  end

  test "should update client" do
    patch :update, id: @client, client: { name: @client.name }
    assert_redirected_to client_path(assigns(:client))
  end

  test "should destroy client" do
    assert_difference('Client.count', -1) do
      delete :destroy, id: @client
    end

    assert_redirected_to clients_path
  end
end

project controller tests:

require 'test_helper'

class ProjectsControllerTest < ActionController::TestCase
  setup do
    @project = projects(:one)
    @client = clients(:one)
  end

  test "should get index" do
    get :index
    assert_response :success
    assert_not_nil assigns(:projects)
  end

  test "should get new" do
    get :new
    assert_response :success
  end

  test "should create project" do
    assert_difference('Project.count') do
      post :create, project: { client_id: @client, project_description: @project.project_description, project_timescale: @project.project_timescale, title: @project.title }
    end

    assert_redirected_to project_path(assigns(:project))
  end

  test "should show project" do
    get :show, id: @project
    assert_response :success
  end

  test "should get edit" do
    get :edit, id: @project
    assert_response :success
  end

  test "should update project" do
    patch :update, id: @project, project: { client_id: @project.client_id, project_description: @project.project_description, project_timescale: @project.project_timescale }
    assert_redirected_to project_path(assigns(:project))
  end

  test "should destroy project" do
    assert_difference('Project.count', -1) do
      delete :destroy, id: @project
    end

    assert_redirected_to projects_path
  end
end

Index controller test:

require 'test_helper'

class IndexControllerTest < ActionController::TestCase
  test "should get index" do
    get :index
    assert_response :success
  end

  test "should get contact"  do 
    get :contact 
    assert_response:success

    assert_template layout: 'application'

    assert_select'title', 'My Notes'
    assert_select'h1', 'Contact Us' 
    assert_select 'p', 'Complete the following form to get in touch with us.' 
    end

end

client model test:

require 'test_helper'

class ClientTest < ActiveSupport::TestCase
  # test "the truth" do
  #   assert true
  # end

  #tests to see if an empty client can be created
  test "no empty clients!" do
    client = Client.new
    client.save

    refute client.valid?
  end

  #checks if a valid client can be created
  test "should save valid clients" do
    client = Client.new

    client.name = "David"
    client.email = "example@gmail.com"

    client.save
    assert client.valid?
  end

  test "no duplicate emails" do

    client1 = Client.new
    client1.name = "David"
    client1.email = "example@gmail.com"
    client1.save
    assert client.valid?

    client2 = Client.new
    client2.name = "David"
    client2.email = "example@gmail.com"
    client2.save
    refute client.valid?
  end

end

project model test:

require 'test_helper'

class ProjectTest < ActiveSupport::TestCase
  # test "the truth" do
  #   assert true
  # end

  setup do
    @client = clients(:one)
  end

  test "no empty projects" do 
    project = Project.new
    project.save

    refute project.valid?
  end


  test "make valid projects" do
    project = Project.new

    project.title = "first project"
    project.project_description = "building a forum for a game clan"
    project.project_timescale = "1 month"

    project.save
    assert project.valid?
  end
end

clients.yml :

# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html

one:
  name: MyString
  email: MyText1

two:
  name: MyString
  email: MyText2

projects.yml:

# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html

one:
  client: one
  project_description: MyText
  project_timescale: MyString
  title: MyString

two:
  client: two
  project_description: MyText
  project_timescale: MyString
  title: MyString

Show source
| ruby   | rubygems   | ruby-on-rails   | ruby-on-rails-4   | ruby-on-rails-3   2017-01-03 14:01 0 Answers

Answers to RoR error, issue with my Gemfile or test configuration ( 0 )

Leave a reply to - RoR error, issue with my Gemfile or test configuration

◀ Go back