Sha256: 6ca08f4d927f814db3911985afc84b7a6c22714ac3aa0f7a750cf5b698601eb8

Contents?: true

Size: 1.39 KB

Versions: 6

Compression:

Stored size: 1.39 KB

Contents

require 'rspec'
require 'opal/rspec/sprockets_environment'
require_relative 'temp_dir_helper'

describe Opal::RSpec::SprocketsEnvironment do
  include_context :temp_dir
  let(:args) { [] }
  subject(:env) { Opal::RSpec::SprocketsEnvironment.new *args }

  RSpec::Matchers.define :have_pathnames do |expected|
    expected = expected.map { |p| File.expand_path(p) }

    match do |actual|
      actual == expected
    end
  end

  describe '#cached' do
    subject { env.cached }

    it { is_expected.to be_a ::Opal::RSpec::CachedEnvironment }
  end

  describe '#add_spec_paths_to_sprockets' do
    let(:args) { [pattern, nil, nil, default_path] }
    let(:default_path) { nil }

    subject do
      # in subject to allow contexts to execute before logic
      env.add_spec_paths_to_sprockets
      env.paths.sort
    end

    context 'default path not set' do
      before do
        create_dummy_spec_files 'spec/foobar/dummy_spec.rb', 'spec/foobar/ignored_spec.opal'
      end

      let(:pattern) { 'spec/foobar/**/*_spec.rb' }

      it { is_expected.to have_pathnames ['spec'] }
    end

    context 'default path set' do
      before do
        create_dummy_spec_files 'spec/foobar/dummy_spec.rb', 'spec/foobar/ignored_spec.opal'
      end

      let(:pattern) { 'spec/foobar/**/*_spec.rb' }
      let(:default_path) { 'spec/foobar' }

      it { is_expected.to have_pathnames ['spec/foobar'] }
    end
  end
end

Version data entries

6 entries across 6 versions & 2 rubygems

Version Path
opal-rspec-0.6.2 spec/mri/unit/opal/rspec/sprockets_environment_spec.rb
opal-rspec-0.6.1 spec/mri/unit/opal/rspec/sprockets_environment_spec.rb
opal-rspec-0.6.0 spec/mri/unit/opal/rspec/sprockets_environment_spec.rb
opal-rspec-0.6.0.beta1 spec/mri/unit/opal/rspec/sprockets_environment_spec.rb
opal-connect-rspec-0.5.0 spec/mri/unit/opal/rspec/sprockets_environment_spec.rb
opal-rspec-0.5.0 spec/mri/unit/opal/rspec/sprockets_environment_spec.rb