<commit_before># encoding: UTF-8
require "#{File.dirname(__FILE__)}/spec_helper"
include SpecHelper

describe "routes" do
  describe "home route" do
    before do
      @u = FactoryGirl.create :user
    end

    it "returns the homepage for unsigned user" do
      get '/'
      last_response.body.must_include 'Farhang'
    end

    it "returns a 302, ie redirect to search upon false address" do
      get '/ferf'
      last_response.status.must_equal 302
    end

    it "returns the dashboard for signed user" do
      post '/user/login', :email => @u.email, :password => '<PASSWORD>'
      get '/'
      last_response.body.must_include 'Einträge'
    end
  end

  describe "search routes" do
    before do
      FactoryGirl.create :lemma, :lemma  => 'Apfel'
    end

    it "gets and finds a url search" do
      get '/search/Apfel'
      last_response.body.must_include 'Apfel'
      last_response.body.wont_include 'Augapfel'
      get '/search/apfel'
      last_response.body.must_include 'Apfel'
      last_response.body.wont_include 'Augapfel'
    end

    it "gets and finds a params search" do
      get '/app/search', :term => 'Apfel'
      follow_redirect!
      get '/app/search', :term => 'apfel'
      follow_redirect!
      last_response.body.must_include 'Apfel'
      last_response.body.wont_include 'Augapfel'
    end

    it "can find a search term with parens in it" do
      FactoryGirl.create :lemma, :lemma => 'ca (*:cirka)'
      get '/app/search', :term => 'ca%20(*:cirka)'
      follow_redirect!
      last_response.body.must_include 'cirka'
    end

    it "returns a valid json file for autocomplete" do
      get '/search/autocomplete.json?term=ap'
      last_response.body.must_equal '["Apfel"]'
    end

    after do
      Lemma.delete_all
    end
  end

  describe "ping route" do
    it "returns a 200 on /app/ping" do
      get '/app/ping'
      last_response.status.must_equal 200
    end

    it "returns a sitemap" do
      get '/app/sitemap.txt'
      last_response['Content-Type'].must_equal 'text/html;charset=utf-8'
    end
  end
end
<commit_msg>add spec for description metadata<commit_after># encoding: UTF-8
require "#{File.dirname(__FILE__)}/spec_helper"
include SpecHelper

describe "routes" do
  describe "home route" do
    before do
      @u = FactoryGirl.create :user
    end

    it "returns the homepage for unsigned user" do
      get '/'
      last_response.body.must_include 'Farhang'
    end

    it "returns a 302, ie redirect to search upon false address" do
      get '/ferf'
      last_response.status.must_equal 302
    end

    it "returns the dashboard for signed user" do
      post '/user/login', :email => @u.email, :password => '<PASSWORD>'
      get '/'
      last_response.body.must_include 'Einträge'
    end
  end

  describe "search routes" do
    before do
      FactoryGirl.create :lemma, :lemma  => 'Apfel'
    end

    it "gets and finds a url search" do
      get '/search/Apfel'
      last_response.body.must_include 'Apfel'
      last_response.body.wont_include 'Augapfel'
      get '/search/apfel'
      last_response.body.must_include 'Apfel'
      last_response.body.wont_include 'Augapfel'
    end

    it "gets and finds a params search" do
      get '/app/search', :term => 'Apfel'
      follow_redirect!
      get '/app/search', :term => 'apfel'
      follow_redirect!
      last_response.body.must_include 'Apfel'
      last_response.body.wont_include 'Augapfel'
    end

    it "can find a search term with parens in it" do
      FactoryGirl.create :lemma, :lemma => 'ca (*:cirka)'
      get '/app/search', :term => 'ca%20(*:cirka)'
      follow_redirect!
      last_response.body.must_include 'cirka'
    end

    it "returns a valid json file for autocomplete" do
      get '/search/autocomplete.json?term=ap'
      last_response.body.must_equal '["Apfel"]'
    end

    after do
      Lemma.delete_all
    end
  end

  describe "ping route" do
    it "returns a 200 on /app/ping" do
      get '/app/ping'
      last_response.status.must_equal 200
    end
  end

  describe "sitemap" do
    it "returns a sitemap" do
      get '/app/sitemap.txt'
      last_response['Content-Type'].must_equal 'text/html;charset=utf-8'
    end
  end

  describe "meta data" do
    it "shows specific meta data for entries" do
      FactoryGirl.create :lemma, :lemma  => 'Apfel'
      get '/apfel'
      last_response.body.must_include 'content="Das offene deutsch-persische Lexikon: Lexikon'
    end

    after do
      Lemma.delete_all
    end
  end
end

{'fraction_non_alphanumeric': 0.10196424630324431, 'fraction_numerical': 0.007062458618406533, 'mean_word_length': 2.6169193934557065, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 20, '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': '1027652', 'n_tokens_mistral': 1521, 'n_tokens_neox': 1449, 'n_words': 426}