Skip to content

Instantly share code, notes, and snippets.

@meriy100
Created September 17, 2018 08:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save meriy100/1d4266c275c0ff39c0b679867f5e2e27 to your computer and use it in GitHub Desktop.
Save meriy100/1d4266c275c0ff39c0b679867f5e2e27 to your computer and use it in GitHub Desktop.
# spec/features/exam.feature
# encoding: utf-8
Feature: テスト管理
@teachers
@exams
Scenario: 学習スケジュールが無い小テストを編集できる
Given 先生がログインする
Given 1-1 クラスを用意
Given 2018-07-01 に小テストを用意
When サイドバーのスケージュール管理からクラス一覧に移動
When 1-1 クラスのスケージュールをクリック
When 2018-07-01 の 1 ~ 20 をクリックする
Then 学習日が0日と表示されている
When 編集をクリックする
When 試験日に 2018-07-01 を入力して更新をクリック
Then 詳細パネルに 2018-07-01 が日本語表記で表示されている
Then 学習日が0日と表示されている
# spec/steps/exam_steps.rb
steps_for :exams do
step ':class_name クラスのスケージュールをクリック' do |class_name|
school_class = SchoolClass.find_by!(name: class_name)
within "#cy-school-class-#{school_class.id}" do
click_on 'スケジュール'
end
end
step ':date の :start ~ :end をクリックする' do |date, start, _end|
within "#cy-schedule-#{date}" do
click_on "#{start} ~ #{_end}"
end
end
step '学習日が0日と表示されている' do
within '#cy-study-schedules' do
expect(page).to have_content 'テストまでの学習日(0日)'
end
end
step '編集をクリックする' do
within '.content-wrapper' do
click_on '編集'
end
end
step '試験日に :date を入力して更新をクリック' do |date|
fill_in_date_picker('試験日', Time.zone.parse(date).to_date)
click_on '更新'
end
step '詳細パネルに :date が日本語表記で表示されている' do |date|
within '#cy-exam-detail' do
expect(page).to have_content Time.zone.parse(date).to_date.strftime('%Y年%m月%d日')
end
end
end
# steps/teacher_steps.rb
When /^先生がログインする$/ do
fill_in "Email", with: @user.email
fill_in "Password", with: @user.password
click_button "Sign in"
end
# language: ja
フィーチャ: ユーザ一覧画面
シナリオ: ユーザ一覧画面を表示
前提 ユーザ数が 3 件登録されている
もし ユーザ一覧画面を表示する
ならば 1 件のユーザ情報が表示されること
$ cucumber --i18n-language # 使用できる言語表
$ cucumber --i18n-keywords ja # その言語での予約語の対応表
require 'turnip'
require 'turnip/rspec'
require 'turnip/capybara'
require 'rails_helper'
Dir[Rails.root.join('spec/steps/**/*_steps.rb')].each { |f| require f }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment