Sha256: 02baf993933de3b91ff7a2d0e08ae721486a1b0d9a6f9f7dff44e929a3b44bc5

Contents?: true

Size: 1.97 KB

Versions: 32

Compression:

Stored size: 1.97 KB

Contents

require 'spec_helper'

describe 'rake tasks' do
  include_context "rake"

  let(:doc_path)  { "user_specified_doc_path" }

  before do
    Apipie.configuration.doc_path = doc_path
    allow(Apipie).to receive(:reload_documentation)
    subject.invoke(*task_args)
  end

  describe 'static pages' do

    let(:apidoc_html) do
      File.read("#{doc_output}.html")
    end

    let(:doc_output) do
      File.join(::Rails.root, doc_path, 'apidoc')
    end

    after do
      Dir["#{doc_output}*"].each { |static_file| FileUtils.rm_rf(static_file) }
    end

    describe 'apipie:static' do
      it "generates static files for the default version of apipie docs" do
        expect(apidoc_html).to match(/Test app #{Apipie.configuration.default_version}/)
      end

      it "includes the stylesheets" do
        expect(apidoc_html).to include('./apidoc/stylesheets/bundled/bootstrap.min.css')
        expect(File).to exist(File.join(doc_output, 'stylesheets/bundled/bootstrap.min.css'))
      end
    end

    describe 'apipie:static[2.0]' do
      it "generates static files for the default version of apipie docs" do
        expect(apidoc_html).to match(/Test app 2.0/)
      end

      it "includes the stylesheets" do
        expect(apidoc_html).to include('./apidoc/stylesheets/bundled/bootstrap.min.css')
        expect(File).to exist(File.join(doc_output, 'stylesheets/bundled/bootstrap.min.css'))
      end
    end
  end

  describe 'apipie:cache' do
    let(:cache_output) do
      File.join(::Rails.root, 'public', 'apipie-cache')
    end

    let(:apidoc_html) do
      File.read("#{cache_output}.html")
    end

    after do
      Dir["#{cache_output}*"].each { |static_file| FileUtils.rm_rf(static_file) }
    end

    it "generates cache files" do
      expect(File).to exist(File.join(cache_output, 'apidoc.html'))
      expect(File).to exist(File.join(cache_output, 'apidoc/development.html'))
      expect(File).to exist(File.join(cache_output, 'apidoc/development/users.html'))

    end
  end
end

Version data entries

32 entries across 32 versions & 2 rubygems

Version Path
apipie-rails-0.8.2 spec/lib/rake_spec.rb
apipie-rails-0.8.1 spec/lib/rake_spec.rb
apipie-rails-0.8.0 spec/lib/rake_spec.rb
apipie-rails-0.7.2 spec/lib/rake_spec.rb
apipie-rails-0.7.1 spec/lib/rake_spec.rb
apipie-rails-0.7.0 spec/lib/rake_spec.rb
apipie-rails-0.6.0 spec/lib/rake_spec.rb
apipie-rails-0.5.20 spec/lib/rake_spec.rb
apipie-rails-0.5.19 spec/lib/rake_spec.rb
apipie-rails-0.5.18 spec/lib/rake_spec.rb
apipie-rails-0.5.17 spec/lib/rake_spec.rb
apipie-rails-0.5.16 spec/lib/rake_spec.rb
apipierails3-0.0.1 spec/lib/rake_spec.rb
apipie-rails-0.5.15 spec/lib/rake_spec.rb
apipie-rails-0.5.14 spec/lib/rake_spec.rb
apipie-rails-0.5.13 spec/lib/rake_spec.rb
apipie-rails-0.5.12 spec/lib/rake_spec.rb
apipie-rails-0.5.11 spec/lib/rake_spec.rb
apipie-rails-0.5.10 spec/lib/rake_spec.rb
apipie-rails-0.5.9 spec/lib/rake_spec.rb