0

In controller I have got this:

def output
  if params[:find]
    result
  elsif params[:print_db]
    print_db
  end
end

And the test doesn't want to enter in params[:find] condition.

Test controller:

test "should get 5 5 1 for view with 5 5 1 3 3" do
  get :output, {str: "5 5 1 3 3 5"}, :params => 'find'
  assert_equal assigns[:result], "5, 5, 1"
end

Please, help me!

1
  • 2
    You need to send a find param, e.g., find: true or something. Put a pry/etc in your controller and actually look at your params. Commented Nov 26, 2015 at 17:06

2 Answers 2

1

It seems like you want to have both: A params[:str] and a params[:find] parameter.

Change:

get :output, {str: "5 5 1 3 3 5"}, :params => 'find'

to:

get :output, str: '5 5 1 3 3 5', find: true

Because your version passes the :params => 'find' part into the session variable not into the params. You might want to read in the Rails' guide about what parameters the get method accepts.

Sign up to request clarification or add additional context in comments.

Comments

1

Try this:

get :output, { str: "5 5 1 3 3 5", find: true }

In your request you send only the str with the value "5 5 1 3 3 5" and no find parameter. You have to put all parameters into the first hash.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.