Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to check if text appears on page in rails functional test?

I am currently writing functional tests for my controller, and I want to check if a line

This is a test line

appears on my page.

I tried using

assert_select "p" do
  assert_select "this is the test line"
end

but i think something is wrong with this line.

What is the best way to do this in rails version 3?

like image 411
DonDomicci Avatar asked Jul 01 '13 20:07

DonDomicci


People also ask

What is Minitest in Ruby on rails?

What is Minitest? Minitest is a testing suite for Ruby. It provides a complete suite of testing facilities supporting test-driven development (TDD), behavior-driven development (BDD), mocking, and benchmarking. It's small, fast, and it aims to make tests clean and readable.

What is Minitest?

What is Minitest? Minitest is a testing tool for Ruby that provides a complete suite of testing facilities. It also supports behaviour-driven development, mocking and benchmarking.

How do I run a test case in rails?

We can run all of our tests at once by using the bin/rails test command. Or we can run a single test file by passing the bin/rails test command the filename containing the test cases. This will run all test methods from the test case.


1 Answers

Without specifying a tag:

assert_match "this is the test line", response.body
like image 154
Is Ma Avatar answered Nov 14 '22 22:11

Is Ma