2016-10-13 22 views
0

編集:現在、SimpleCovの指示に従って、私のディレクトリのルートに.simplecovというファイルを使用しています。また、「app/views」を含むいくつかのグループを追加しました。しかし、キュウリ試験はまだSimpleCovにログインしていません。私はコードが実行されているかどうかを調べるためにlaunchyの宝石を使っていましたが、それは...私はこの時点でちょっと困惑しています。キュウリの試験結果がSimpleCovレポートに表示されない

初めてRails 5アプリにCucumberを統合しようとしています。私はRSpecとSimpleCovも使用しています。私は単純なユーザー登録とユーザーサインイン機能をテストするためにCucumberを使用しています。テストはキュウリと合格し、キュウリのカバレッジレポートが生成されたと言われます。ただし、カバレッジレポートには実際に「ログイン」または「サインアップ」機能は表示されませんでした。

user.featureファイル:

# /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ファイル:

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. 

マイカバレッジレポート:それは渡しています表示するには$ cucumberを実行しているから

# /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 

ターミナル出力

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 

キュウリenv.rbファイル:

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

SimpleCov.start 'rails' 

require 'cucumber/rails' 

どのような手順Iは、カバレッジレポートでキュウリのテストカバレッジを表示するために取る必要がありますか?

答えて

関連する問題