Rspec setup for testing application:-
rails new Demo -T
You can utilize any application name you need, the — T flag is used to tell Rails not to utilize MiniTest. By default, Rails will use a test system called ‘MiniTest’ on the off chance that we didn’t indicate — T flag, we need to use Rspec as the test framework rather than MiniTest.
RSpec-rails is the RSpec testing framework, in addition to a few takes on Rail’s magic. For example, when you run rails to produce model User to make user, it will also consequently create a model test record for that client: user_spec.rb.
group :development, :test do
require ‘web drivers’
Now create a file named “static_spec.rb” , and place it in “spec/static_spec.rb”
RSpec.describe ‘Static content’, type: :system do
it ‘shows the static text’ do
expect(page).to have_content(‘Hello world’)
You should see your default Browser open and it will load the page briefly and close, and a succeeded test :
Congratulation! You have written your first Rspec test!!!