0
votes

Edit: I am now using a .simplecov file in the root of my directory as per the SimpleCov directions. I have also added some groups including "app/views". However, Cucumber tests are still not being logged into SimpleCov. I even used the launchy gem to see if the code is executing and it is... I am a bit stumped at this point.

I am trying to integrate Cucumber into my Rails 5 app for the first time. I am also using RSpec and SimpleCov. I am using Cucumber to test a simple user registration and user sign in feature. The tests pass with Cucumber and I am told that a Coverage report was generated for Cucumber. However, the Coverage report doesn't actually show any "Log In" or "Sign Up" feature was covered.

user.feature File:

# /features/user.feature

Feature: User Features
As a user I want to be able to Sign Up or Log In when I visit the home page so that I can use the website.

Scenario: Create a user account
When I go to the index
Then I should see "Sign Up"

Scenario: Sign In as a user
When I go to the index
Then I should see "Sign In"

user_steps.rb file:

# /features/step_definitions/user_steps.rb
When(/^I go to the index$/) do
  visit root_path
end

Then(/^I should see "([^"]*)"$/) do |arg1|
  click_on "Sign Up"
  fill_in "Email", with: "[email protected]"
  fill_in "Password", with: "password1"
  fill_in "Password confirmation", with: "password1"
  click_button "Sign up"

  expect(page).to have_content("Welcome! You have signed up successfully.")
end

Terminal output from running $ cucumber to show it's passing:

ANTONIOs-MacBook-Pro:reddit_clone Tony$ cucumber
Using the default profile...
Feature: Create User
As a user I want to be able to sign up when I visit the home page so that they can use the website.

  Scenario: Create a user account # features/user.feature:4
    When I go to the index        #  features/step_definitions/user_steps.rb:1
    Then I should see "Sign Up"   # features/step_definitions/user_steps.rb:5

  Scenario: Sign In as a user   # features/user.feature:8
    When I go to the index      # features/step_definitions/user_steps.rb:1
    Then I should see "Sign In" # features/step_definitions/user_steps.rb:5

2 scenarios (2 passed)
4 steps (4 passed)
0m0.897s
Coverage report generated for Cucumber Features to     /Users/Tony/Documents/projects/rails/reddit_clone/coverage. 18 / 185 LOC (9.73%) covered.

My Coverage Report:

SimpleCov index

# /spec/spec_helper.rb top of the file. 
require 'simplecov'
SimpleCov.start
require 'database_cleaner'
RSpec.configure do |config|
  config.before(:suite) do
    DatabaseCleaner.strategy = :transaction
    DatabaseCleaner.clean_with(:truncation)
  end

  config.around(:each) do |example|
    DatabaseCleaner.cleaning do
      example.run
    end
  end

  ...

end

Cucumber env.rb file:

# /features/support/env.rb
require 'simplecov'

SimpleCov.start 'rails'

require 'cucumber/rails'

What steps do I need to take to show the cucumber test coverage in the coverage report?

1

1 Answers