<commit_before>require 'spec_helper'
#devise tests must be in features directory (not requests) to use Capybara methods

describe "Authentication" do
  let(:base_title) { "Solario" }
  let(:user) { FactoryGirl.create(:user) }
  subject { page }

  shared_examples_for "all authentication pages" do
    it { should have_selector('h1', text: heading) }
    #cannot access helpers without calling 'ApplicationController...'
    it { should have_title(ApplicationController.helpers.full_title(heading)) }
  end
  describe 'admin login page' do# <<<
    let(:heading) { 'Sign in' }
    let(:submit) { "Sign in" }
    before do
      user.admin = true
      visit new_user_session_path
    end

    it_should_behave_like 'all authentication pages'
    it { should have_button(submit) }

    describe 'with invalid inputs' do
      before { click_button submit }
      it "should not log the user in" do
        pending
      end

      describe "should have error message" do
        it_should_behave_like 'all authentication pages'
        it { should have_selector("div.alert", text: "Invalid") }
      end
    end

    describe 'with valid inputs' do
      before do
        fill_in 'Username', with: user.username
        fill_in 'Password', with: <PASSWORD>
        click_button submit
      end
      it { should have_selector("div.alert-success", text: "signed in") }
      it { should have_link 'Logout', href: destroy_user_session_path }

      #describe "log the user in" do
      #end
    end

  end# >>>
end<commit_msg>clean up authentication tests<commit_after>require 'spec_helper'
#devise tests must be in features directory (not requests) to use Capybara methods

describe "Authentication" do
  let(:base_title) { "Solario" }
  let(:user) { FactoryGirl.create(:user) }
  subject { page }

  shared_examples_for "all authentication pages" do
    it { should have_selector('h1', text: heading) }
    #cannot access helpers without calling 'ApplicationController...'
    it { should have_title(ApplicationController.helpers.full_title(heading)) }
  end
  describe 'admin login page' do# <<<
    let(:heading) { 'Sign in' }
    let(:submit) { "Sign in" }
    before do
      user.admin = true
      visit new_user_session_path
    end

    it_should_behave_like 'all authentication pages'
    it { should have_button(submit) }

    describe 'with invalid inputs' do
      before { click_button submit }
      describe "should have error message" do
        it_should_behave_like 'all authentication pages'
        it { should have_selector("div.alert", text: "Invalid") }
      end
    end

    describe 'with valid inputs' do
      before do
        fill_in 'Username', with: user.username
        fill_in 'Password', with: <PASSWORD>
        click_button submit
      end
      it { should have_selector("div.alert-notice", text: "Signed in") }
      it { should have_link 'Logout', href: destroy_user_session_path }

      #describe "log the user in" do
      #end
    end

  end# >>>
end
{'fraction_non_alphanumeric': 0.09275942609275943, 'fraction_numerical': 0.000667334000667334, 'mean_word_length': 3.0789115646258503, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2223479', 'n_tokens_mistral': 880, 'n_tokens_neox': 856, 'n_words': 282}