Created
January 4, 2018 19:07
-
-
Save zeeshangulzar/615b49e93bf69ef277d66c0da37c7655 to your computer and use it in GitHub Desktop.
Rspec Sample Code
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rails_helper' | |
describe "S9 Study Detail", :type => :feature do | |
include PauseHelpers | |
include UiHelpers | |
include UserAccountHelpers | |
include AuditHelpers | |
include WaitForAjaxHelper | |
before :all do | |
Study.destroy_all | |
Token.delete_all | |
audit_clear | |
ua_create | |
end | |
after :all do | |
Study.destroy_all | |
Token.delete_all | |
audit_clear | |
ua_destroy | |
end | |
describe "Edit User", :type => :feature do | |
it "study version edit, tabs", js: true do | |
set_screen_size(800, 800) | |
login_editor | |
visit '/' | |
expect(page).to have_content 'Studies' | |
create_study("TEST", "A test study") | |
table_click_link("main", "TEST", "History") | |
expect(page).to have_content 'Study History: A test study' | |
table_click_link("main", "0.1.0", "Edit") | |
mini_study | |
detail_tab_click | |
expect(page).to have_content 'Study Detail' | |
click_logoff | |
end | |
end | |
end | |
####################### Helper Methods#################### | |
module StudyVersionHelpers | |
def create_study(identifier, label) | |
return Study.create(identifier: identifier, label: label) | |
end | |
def create_study_version(study_id, name, description, protocol_name, state, version, semantic_version) | |
return StudyVersion.create(study_id: study_id, name: name, description: description, protocol_name: protocol_name, | |
state: state, version: version, semantic_version: semantic_version) | |
end | |
def create_form(study_version_id, form_id, form_namespace, identifier, ordinal, label) | |
form = Form.create(study_version_id: study_version_id, ordinal: ordinal, form_id: form_id, | |
form_namespace: form_namespace, identifier: identifier, label: label) | |
return form | |
end | |
def create_visit(study_version_id, ordinal, short_name, long_name, timing) | |
return Visit.create(study_version_id: study_version_id, ordinal: ordinal, short_name: short_name, long_name: long_name, timing: timing) | |
end | |
def create_element(study_version_id, form_id, visit_id) | |
return Element.create(study_version_id: study_version_id, visit_id: visit_id, form_id: form_id) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment