Last active
August 29, 2015 13:57
-
-
Save robzolkos/9541271 to your computer and use it in GitHub Desktop.
This file contains 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
Failures: | |
1) User List Administrator viewing list of users | |
Failure/Error: case type | |
NameError: | |
undefined local variable or method `type' for #<RSpec::Core::ExampleGroup::Nested_1:0x0000010169fe40> | |
# ./spec/features/users/user_list_spec.rb:23:in `block (2 levels) in <top (required)>' | |
# -e:1:in `<main>' | |
2) User List Normal user viewing list of users | |
Failure/Error: case type | |
NameError: | |
undefined local variable or method `type' for #<RSpec::Core::ExampleGroup::Nested_1:0x007fbf65a9d5b8> | |
# ./spec/features/users/user_list_spec.rb:58:in `block (2 levels) in <top (required)>' | |
# -e:1:in `<main>' |
This file contains 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 "spec_helper" | |
feature "User List" do | |
include UserHelper | |
#As a Site Admin | |
#I need to see a list of users | |
#So I can perform actions against their accounts | |
# | |
#commands for terminal | |
# | |
#vim spec/features/users/sign_in_spec.rb | |
#phoenix:ReCEnT ianmcgee$ time bundle exec ./bin/rspec -f doc spec//features/users/user_list_spec.rb | |
["training_providers", "practices", "users", "round_management", "qualifications"].each do |section| | |
scenario "Administrator viewing list of users in #{section}" do | |
setup_test | |
#Given I am signed in as an admin | |
@authenticated_user = UserHelper.generate :"Site Admin" | |
UserHelper.create @authenticated_user, :"Site Admin" | |
sign_in @authenticated_user | |
page.should have_content "Signed in successfully" | |
#When I view the list of users | |
visit '/#{section}' | |
#Then I should see a form titled "Manage Users" | |
page.should have_content form_title | |
end | |
scenario "Normal user viewing list of users" do | |
setup_test | |
#Given I am a registered user | |
@general_user = UserHelper.generate :general_user | |
UserHelper.create @general_user | |
#And I am signed in | |
@authenticated_user = UserHelper.generate :general_user | |
sign_in @authenticated_user | |
page.should have_content "Signed in successfully" | |
#When I view the list of users | |
case type | |
when 'providers' | |
visit '/training_providers' | |
when 'practices' | |
visit '/practices' | |
when 'users' | |
visit '/users' | |
when 'terms' | |
visit '/round_management' | |
when 'qualifications' | |
visit '/qualifications' | |
end | |
#Then I should see the message "Not authorized as an administrator." on the page | |
page.should have_content message_text | |
end | |
end | |
private | |
def setup_test | |
# Create Default Roles | |
FactoryGirl.create(:data_coder_role) | |
FactoryGirl.create(:admin_support_role) | |
FactoryGirl.create(:project_manager_role) | |
# Create Default RTPs | |
FactoryGirl.create(:training_provider_1) | |
FactoryGirl.create(:training_provider_2) | |
FactoryGirl.create(:training_provider_3) | |
FactoryGirl.create(:training_provider_4) | |
# Setup the default terms | |
1.upto(4).each{|n| RoundTerm.create :number => n} | |
# Generate some rounds | |
semester = 2 | |
year = 2009 | |
1.upto(8).each do |round| | |
Round.create! :number => round, :year => year, :semester => semester | |
if semester.eql? 2 | |
semester = 1 | |
year = year + 1 | |
else | |
semester = 2 | |
end | |
end | |
# Import the medicare items numbers | |
MedicareItemNumber.populate(Rails.root.join("data_to_import","historical", "medicare.csv")) | |
MedicareItemNumber.update_all(:excluded => false) | |
MedicareItemNumber.update_all({:excluded => true}, ["code IN (?)", %w(4 20 24 35 37 43 47 51 58 59 60 65)]) | |
%w(4 43 47 51 58 59 60 65).each {|code| MedicareItemNumber.create! code: code, active: "true", excluded: true } | |
# Generate some countries | |
RegistrarCountry.populate | |
# Generate some languages | |
Language.populate | |
# Generate some Psychiatry Roles | |
PsychiatryRole.populate | |
# Generate some Psychiatry Context | |
PsychiatryContext.populate | |
# Generate some Sexual Health Experiences | |
SexualHealthExperience.populate | |
# Generate the Referral Kinds | |
ReferralKind.populate | |
# Generate the Follow Up Kinds | |
FollowUpKind.populate | |
# Generate the Follow Up Kinds | |
InformationSourceKind.populate | |
# Import some ATCs | |
atc_count = 0 | |
CSV.foreach(Rails.root.join("data_to_import", "atc.csv"), {headers: true, header_converters: :symbol}) do |row| | |
roa = RouteOfAdmin.find_by_name(row[:route_of_admin]) | |
roa = RouteOfAdmin.create! :name => row[:route_of_admin] if roa.nil? | |
GenericDrug.create! :atc_code => row[:code], :name => row[:name], :route_of_admin_id => roa.id | |
atc_count += 1 | |
break if atc_count.eql? 300 | |
end | |
# Populate the raw data models from the CSV | |
RawIcpcTerm.import_csv(Rails.root.join("data_to_import", "icpc", "ICPC2TRM.CSV"), %w{term_id term nalan icpc_code term_code status replacement}) | |
RawIcpcKeyword.import_csv(Rails.root.join("data_to_import", "icpc", "ICPC2KEY.CSV"), %w{key_id keyword}) | |
RawIcpcTermKeyword.import_csv(Rails.root.join("data_to_import", "icpc", "ICPC2LNK.CSV"), %w{key_id term_id}) | |
# Sync the ICPC models with the raw data models | |
IcpcTerm.sync | |
IcpcKeyword.sync | |
IcpcTermKeyword.sync | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Not sure if this is right but to get the spec running I had to put an end for the scenario:
["training_providers", "practices", "users", "round_management", "qualifications"].each do |section|
scenario "Administrator viewing list of users in #{section}" do
setup_test
#Given I am signed in as an admin
@authenticated_user = UserHelper.generate :"Site Admin"
UserHelper.create @authenticated_user, :"Site Admin"
sign_in @authenticated_user
page.should have_content "Signed in successfully"
#When I view the list of users
visit '/#{section}'
#Then I should see a form titled "Manage Users"
page.should have_content form_title
end
end
Failures:
Failure/Error: visit '/#{section}'
URI::InvalidURIError:
bad URI(is not URI?): /#{section}
./spec/features/users/user_list_spec.rb:24:in `block (3 levels) in <top (required)>'
-e:1:in`'
repeat for all 5