Given(/^I am logged in$/) do
  ENV['PDS_HANDLE'] = 'PDS_HANDLE'
end

Given(/^I am not logged in$/) do
  ENV['PDS_HANDLE'] = nil
end

Then(/^I should a login link$/) do
  expect(page).to have_css('.nyu-login i.icons-famfamfam-lock_open')
  expect(page).to have_css('.nyu-login a.login')
end

Then(/^I should see "(.*?)" as the text of the login link$/) do |text|
  login_link = find(:css, '.nyu-login a.login')
  expect(login_link).to have_text text
end

Then(/^I should a logout link$/) do
  expect(page).to have_css('.nyu-login i.icons-famfamfam-lock')
  expect(page).to have_css('.nyu-login a.logout')
end

Then(/^I should see "(.*?)" as the text of the logout link$/) do |text|
  logout_link = find(:css, '.nyu-login a.logout')
  expect(logout_link).to have_text text
end

Then(/^I should see the login page in the current window$/) do
  expect(current_host).to match /^https:\/\/login(dev)?\.library\.nyu\.edu$/
end

Given(/^I am logged in$/) do
  ENV['PDS_HANDLE'] = 'PDS_HANDLE'
end

Given(/^I am not logged in$/) do
  ENV['PDS_HANDLE'] = nil
end

Then(/^I should a login link$/) do
  expect(page).to have_css('.nyu-login i.icons-famfamfam-lock_open')
  expect(page).to have_css('.nyu-login a.login')
end

Then(/^I should see "(.*?)" as the text of the login link$/) do |text|
  login_link = find(:css, '.nyu-login a.login')
  expect(login_link).to have_text text
end

Then(/^I should a logout link$/) do
  expect(page).to have_css('.nyu-login i.icons-famfamfam-lock')
  expect(page).to have_css('.nyu-login a.logout')
end

Then(/^I should see "(.*?)" as the text of the logout link$/) do |text|
  logout_link = find(:css, '.nyu-login a.logout')
  expect(logout_link).to have_text text
end

Then(/^I should see the login page in the current window$/) do
  expect(page).to have_text 'Login with an NYU NetID'
end

Update login check to check the page for expected text rather than the URL in order to let the page render
Update login check to check the page for expected text rather than the URL in order to let the page render
