Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Ruby

C:/Users/Desktop/project/test/controllers/statuses_controller _test.rb:96]: Expected: 321975000 Actual: 207281424

Everytime i do "rake test" but i get 2 Failure with the same failure.i don't know where i went wrong.

$ rake test

DL is deprecated, please use Fiddle

Run options: --seed 16633

# Running:

.....................F.....F....

Finished in 1.828169s, 17.5039 runs/s, 37.1957 assertions/s.

1) Failure:

StatusesControllerTest#test_should_update_status_for_the_cur rent_user_when_logged_in [C:/Users/Arvind/project/test/controllers/statuses_contr oller_test.rb:89]: Expected: 321975000 Actual: 207281424

2) Failure: StatusesControllerTest#test_should_not_update_the_status_if_ nothing_has_changed [C:/Users/Desktop/project/test/controllers/statuses_controller _test.rb:96]: Expected: 321975000 Actual: 207281424

32 runs, 68 assertions, 2 failures, 0 errors, 0 skips

Greatly appreciate any help. Thank you!

Maciej Czuchnowski
Maciej Czuchnowski
36,440 Points

Without seeing your code we can't do much. The best thing would be to upload the whole project to github and link it here.

My statuses_controller_test.rb file looklike this....

 require 'test_helper'

  class StatusesControllerTest < ActionController::TestCase

 setup do
   @status = statuses(:one)
  end

   test "should get index" do

    get :index

    assert_response :success

     assert_not_nil assigns(:statuses)

       end

            test "should be redirected when not logged in" do

               get :new

               assert_response :redirect

             assert_redirected_to new_user_session_path

       end

     test "should render the new page when logged in" do

       sign_in users(:sarah)

        get :new

      assert_response :success

       end

    test "should be logged in to post a status" do

     post :create, status: {context: "Hello"}

     assert_response :redirect

     assert_redirected_to new_user_session_path

     end

     test "should create status when logged in" do

      sign_in users(:sarah)

     assert_difference('Status.count') do

     post :create, status: {context: @status.context}

     end

     assert_redirected_to status_path(assigns(:status))

     end

       test "should create status for the current user when logged in" do

     sign_in users(:sarah)

     assert_difference('Status.count') do

      post :create, status: {context: @status.context, user_id: users(:ruby).id }

         end

      assert_redirected_to status_path(assigns(:status))

   assert_equal assigns(:status).user_id, users(:sarah).id

     end

     test "should show status" do

   get :show, id: @status

   assert_response :success

   end

    test "should get edit" do

   get :edit, id: @status

    assert_response :redirect

     end

    test "should redirect edit when not logged in" do

    get :edit, id: @status

    assert_response :redirect

    assert_redirected_to new_user_session_path

   end

    test "should get edit when logged in" do

     sign_in users(:sarah)

     get :edit, id: @status

     assert_response :success

    end

        test "should redirect status update when not logged in" do

       put :update, id: @status, status: {context: @status.context}

        assert_response :redirect

         assert_redirected_to new_user_session_path

          end

      test "should update status when logged in" do

      sign_in users(:sarah)

    put :update, id: @status, status: {context: @status.context}

     assert_redirected_to status_path(assigns(:status))

      end

    test "should update status for the current user when logged in" do

      sign_in users(:sarah)

     put :update, id: @status, status: {context: @status.context, user_id: users(:sarah).id }

     assert_redirected_to status_path(assigns(:status))

     assert_equal assigns(:status).user_id, users(:ruby).id

     end

     test "should not update the status if nothing has changed" do

    sign_in users(:sarah)

    put :update, id: @status

    assert_redirected_to status_path(assigns(:status))

   assert_equal assigns(:status).user_id, users(:ruby).id

   end


     test "should destroy status" do

     assert_difference('Status.count', -1) do

    delete :destroy, id: @status

     end

assert_redirected_to statuses_path

   end
 end
Maciej Czuchnowski
Maciej Czuchnowski
36,440 Points

In order to understand your errors we need full error messages and a lot of files inside your app, because the cause can be hiding anywhere. This code does not help us. Please publish the project on github.