Sha256: 1be12a92fa7c77ed0638a5a01af12584b4c25909fdfbf7b52a90721117fda8f7

Contents?: true

Size: 1.27 KB

Versions: 2

Compression:

Stored size: 1.27 KB

Contents

require 'spec_helper'
require 'middleman-blog-similar/algorithm/levenshtein'

describe 'Middleman::Blog::Similar::Algorithm::Levenshtein' do
  let(:app)     {
    middleman_app('test-app') {
      activate :similar, :algorithm => :levenshtein
    }
  }
  let(:article) { app.sitemap.find_resource_by_destination_path '/2014/05/08/article0.html' }
  let(:algorithm)  { article.similarity_algorithm }
  describe(:app) {
    describe(:similarity_algorithm) {
      subject { app.similarity_algorithm }
      it { should be ::Middleman::Blog::Similar::Algorithm::Levenshtein  }
    }
  }
  describe(:similarity_algorithm) {
    subject { algorithm }
    it { should be_a_kind_of ::Middleman::Blog::Similar::Algorithm::Levenshtein }
    describe(:similar_articles) {
      subject { algorithm.similar_articles.map(&:url) }
      it {
        should eq [
          "/2014/05/13/article5.html",
          "/2014/05/09/article1.html",
          "/2014/05/12/article4.html",
          "/2014/05/14/article6.html",
          "/2014/05/10/article2.html",
          "/2014/05/11/article3.html"
        ]
      }
    }
  }
  describe(:article) {
    describe(:similarity_algorithm) {
      subject { algorithm }
      it { should be_a_kind_of ::Middleman::Blog::Similar::Algorithm::Levenshtein }
    }
  }

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
middleman-blog-similar-1.1.1 spec/middleman-blog-similar/algorithm/levenshtein_spec.rb
middleman-blog-similar-1.1.0 spec/middleman-blog-similar/algorithm/levenshtein_spec.rb