<commit_before>require 'spec_helper'

describe ApplicationHelper do
  include ApplicationHelper
  attr_accessor :page_title

  describe "title" do
    it "should set @page_title" do
      expect(title_tag('hello')).to be_nil
      expect(page_title).to eql('hello')
    end

    it "should output container if set" do
      expect(title_tag('hello', :h2)).to have_selector('h2', :content => 'hello')
    end
  end

  describe "login_line" do
    before(:each) do
      @anonymous_user = mock_model(User, :roles => ["guest"], :anonymous? => true, :name => "guest")
      @admin_user = mock_model(User, :roles => ["admin"], :anonymous? => false, :name => "admin", :has_role? => true)
    end

    describe "as anonymous" do
      before(:each) do
        stub!(:current_visitor).and_return(@anonymous_user)
        @original_user = @anonymous_user
      end
      it "should display appropriate login messages" do
        expect(login_line).to match(/login/i)
        expect(login_line).not_to match(/welcome/i)
        expect(login_line(:guest => "guest")).to match(/welcome\s*guest/i)
        expect(login_line(:login => "Log In")).to match(/Log In/)
        expect(login_line(:signup => "Sign Up")).to match(/Sign Up/)
      end
    end

    describe "as admin" do
      before(:each) do
        stub!(:current_visitor).and_return(@admin_user)<commit_msg>Update stub usage for rspec 3 and correct syntax for capybara 2<commit_after>require 'spec_helper'

describe ApplicationHelper do
  include ApplicationHelper
  attr_accessor :page_title

  describe "title" do
    it "should set @page_title" do
      expect(title_tag('hello')).to be_nil
      expect(page_title).to eql('hello')
    end

    it "should output container if set" do
      expect(title_tag('hello', :h2)).to have_selector('h2', :text => 'hello')
    end
  end

  describe "login_line" do
    before(:each) do
      @anonymous_user = mock_model(User, :roles => ["guest"], :anonymous? => true, :name => "guest")
      @admin_user = mock_model(User, :roles => ["admin"], :anonymous? => false, :name => "admin", :has_role? => true)
    end

    describe "as anonymous" do
      before(:each) do
        allow(self).to receive(:current_visitor).and_return(@anonymous_user)
        @original_user = @anonymous_user
      end
      it "should display appropriate login messages" do
        expect(login_line).to match(/login/i)
        expect(login_line).not_to match(/welcome/i)
        expect(login_line(:guest => "guest")).to match(/welcome\s*guest/i)
        expect(login_line(:login => "Log In")).to match(/Log In/)
        expect(login_line(:signup => "Sign Up")).to match(/Sign Up/)
      end
    end

    describe "as admin" do
      before(:each) do
        allow(self).to receive(:current_visitor).and_return(@admin_user)
{'fraction_non_alphanumeric': 0.13820264948084496, 'fraction_numerical': 0.0021482277121374865, 'mean_word_length': 3.35202492211838, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 25, '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': '2125115', 'n_tokens_mistral': 897, 'n_tokens_neox': 885, 'n_words': 218}