Reputation: 43
I have an issue with my controller test, when running it in the terminal it return:
Error:
StoriesControllerTest#test_show_story:
ArgumentError: wrong number of arguments (given 0, expected 1..2)
test/controllers/stories_controller_test.rb:45:in `block in
<class:StoriesControllerTest>'
my test in stories_controller_test is:
test "show story" do
get story_path(stories(:one))
assert_response :success
assert_response.body.include?(stories(:one).name) #line 45
end
and in my stories.yml file I have:
one:
name: Bitcoin Reddit
link: https://www.reddit.com/r/Bitcoin/
If more is necessary please ask and the whole project is here.
Still beginning with unit testing and could not find a solution to this issue.
Upvotes: 3
Views: 848
Reputation: 33420
I guess what you're trying to use there is assert
,
which would eventually fail if the argument isn't true. And as you're trying to check the body, then you must access response.body.
Edit your test adding the assert and pasing the include? on response.body asking whether it includes or not the stories(:one).name:
test "show story" do
get story_path(stories(:one))
assert_response :success
assert response.body.include?(stories(:one).name)
end
Upvotes: 2