0

My guard file is edited for executing the test cases written inside the spec/features so if there is any change inside the controller or model it will execute all spec/features tests:

  watch(%r{^app/controllers/(.+)_(controller)\.rb$}) { "spec/features" } ## any change made in controller it will run all tests under specs/features
  watch(%r{^app/models/(.+)\.rb$}) { "spec/features" } ## any change made in model it will run all tests under specs/features

added the required gemfiles

group :development, :test do
  # Call 'byebug' anywhere in the code to stop execution and get a debugger console
  gem 'byebug', platforms: [:mri, :mingw, :x64_mingw]
  gem 'rspec-rails', '~> 3.8.3'
  gem 'faker', '~> 2.13.0'
  gem 'rubocop-faker'
  gem 'guard', '~> 2.16.2'   ## To automatialy run test cases
  gem 'guard-rspec', '~> 4.7.3'
  gem 'guard-cucumber'
  gem 'capybara', '~> 3.32.2'
end

My file is as:

    require 'rails_helper'
    
    RSpec.feature "Create Article" do
      scenario "A user create a new article" do
        visit "/"
        click.link 'New Article'
        fill_in :Title, with: Faker::Book.title
        fill_in :Body, with: Faker::Lorem.paragraph_by_chars(number: 256)
        click_button 'Create Article'
    
        assert page.has_content? "Article was successfully created"
        # expect(:page).to have_content("Article was successfully created")
        # expect(page.current_path).to eq('/articles/*')
        assert page.current_path.match(/articles\/*/)
      end
   end

but while running guard it do not detects any written test case and give result as:

17:42:01 - INFO - Running: spec/features
No examples found.
Finished in 0.00035 seconds (files took 0.10616 seconds to load)
0 examples, 0 failures
vidur punj
  • 5,019
  • 4
  • 46
  • 65

1 Answers1

0

The name the features .rb file should end with spec.rb only then spec will start executing automatically using guard.

enter image description here

vidur punj
  • 5,019
  • 4
  • 46
  • 65