Sha256: 5c65f3caf47f761de21c7ef88303627e2dac2ecaed02ef45892f4a54a0d1f69f

Contents?: true

Size: 1007 Bytes

Versions: 6

Compression:

Stored size: 1007 Bytes

Contents

require_relative "snowglobe"

class RailsApplicationWithShouldaContext < Snowglobe::RailsApplication
  ROOT_DIRECTORY = Pathname.new("../../..").expand_path(__FILE__)

  def create
    super

    bundle.updating do
      bundle.add_gem(test_framework_gem_name, group: :test)
      bundle.add_gem("shoulda-context", path: ROOT_DIRECTORY, group: :test)
    end
  end

  def test_framework_require_path
    if TEST_FRAMEWORK == "test_unit"
      "test-unit"
    else
      "minitest/autorun"
    end
  end

  def create_gem_with_macro(module_name:, location:, macro_name:)
    fs.write_file("#{location}/shoulda_macros/macros.rb", <<~FILE)
      module #{module_name}
        def #{macro_name}
          puts "#{macro_name} is available"
        end
      end

      Shoulda::Context.configure do |config|
        config.extend(#{module_name})
      end
    FILE
  end

  private

  def test_framework_gem_name
    if TEST_FRAMEWORK == "test_unit"
      "test-unit"
    else
      "minitest"
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
shoulda-context-3.0.0.rc1 test/support/rails_application_with_shoulda_context.rb
shoulda-context-2.0.0 test/support/rails_application_with_shoulda_context.rb
shoulda-context-2.0.0.rc4 test/support/rails_application_with_shoulda_context.rb
shoulda-context-2.0.0.rc3 test/support/rails_application_with_shoulda_context.rb
shoulda-context-2.0.0.rc2 test/support/rails_application_with_shoulda_context.rb
shoulda-context-2.0.0.rc1 test/support/rails_application_with_shoulda_context.rb