Sha256: 63426d2d788d0a0c8a31cc952e186012b01f1be3e834628322d56379c62916bd

Contents?: true

Size: 1.87 KB

Versions: 3

Compression:

Stored size: 1.87 KB

Contents

require 'jekyll'
require 'fileutils'
require_relative '../lib/jekyll_from_to_until'

RSpec.describe(FromToUntil) do
  include described_class

  let(:lines) do
    <<~END_OF_LINES
      line 1
      line 2
      line 3
      line 4
      line 5
    END_OF_LINES
  end

  let(:gitignore) do
    <<~END_OF_LINES
      .bsp/
      project/
      target/
      *.gz
      *.sublime*
      *.swp
      *.out
      *.Identifier
      *.log
      .idea*
      *.iml
      *.tmp
      *~
      ~*
      .DS_Store
      .idea
      .jekyll-cache/
      .jekyll-metadata
      .makeAwsBucketAndDistribution.log
      .sass-cache/
      .yardoc/
      __pycache__/
      __MACOSX
      _build/
      _package/
      _site/
      bin/*.class
      doc/
      jekyll/doc/
      node_modules/
      Notepad++/
      out/
      package/
      instances.json
      rescue_ubuntu2010
      rescue_ubuntu2010.b64
      landingPageShortName.md
      test.html
      RUNNING_PID
      mslinn_jekyll_plugins.zip
      cloud9.tar
      cloud9.zip
      mslinn_aws.tar
    END_OF_LINES
  end

  it 'verifies from' do
    expect(from(lines, '3')).to eq("line 3\nline 4\nline 5\n")
    expect(from(gitignore, 'PID')).to eq("RUNNING_PID\nmslinn_jekyll_plugins.zip\ncloud9.tar\ncloud9.zip\nmslinn_aws.tar\n")
  end

  it 'verifies to' do
    expect(to(lines, '3')).to eq("line 1\nline 2\nline 3\n")
    expect(to(gitignore, 'idea')).to eq(".bsp/\nproject/\ntarget/\n*.gz\n*.sublime*\n*.swp\n*.out\n*.Identifier\n*.log\n.idea*\n")
  end

  it 'verifies until' do
    # until is a Ruby keyword
    expect(method(:until).call(lines, '3')).to eq("line 1\nline 2\n")
    expect(method(:until).call(gitignore, 'idea')).to eq(".bsp/\nproject/\ntarget/\n*.gz\n*.sublime*\n*.swp\n*.out\n*.Identifier\n*.log\n")
  end

  it 'verifies from regex' do
    expect(from(gitignore, '^(cloud|sun)')).to eq("cloud9.tar\ncloud9.zip\nmslinn_aws.tar\n")
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
jekyll_from_to_until-1.0.6 spec/jekyll_from_to_until_spec.rb
jekyll_from_to_until-1.0.5 spec/jekyll_from_to_until_spec.rb
jekyll_from_to_until-1.0.4 spec/jekyll_from_to_until_spec.rb