<commit_before>ENV['RAILS_ENV'] = 'test'
ENV["LIB_NAME"] = 'solidus_backend'

require 'spree_backend'

require 'teaspoon'
require 'teaspoon-mocha'

unless defined?(DummyApp)
  require 'spree/testing_support/dummy_app'

  DummyApp.setup(
    gem_root: File.expand_path('../../', __FILE__),
    lib_name: 'solidus_backend'
  )
end

Teaspoon.configure do |config|
  config.mount_at = "/teaspoon"
  config.root = Spree::Backend::Engine.root
  config.asset_paths = ["spec/javascripts", "spec/javascripts/stylesheets"]
  config.fixture_paths = ["spec/javascripts/fixtures"]

  config.suite do |suite|
    suite.use_framework :mocha, "2.3.3"
    suite.matcher = "{spec/javascripts,app/assets}/**/*_spec.{js,js.coffee,coffee}"
    suite.helper = "spec_helper"
    suite.boot_partial = "/boot"
    suite.expand_assets = true
  end
end<commit_msg>Make teaspoon configuration more reliable<commit_after>ENV['RAILS_ENV'] = 'test'

# Similar to setup described in
# https://github.com/jejacks0n/teaspoon/wiki/Micro-Applications

if defined?(DummyApp)
  require 'teaspoon-mocha'

  Teaspoon.configure do |config|
    config.mount_at = "/teaspoon"
    config.root = Spree::Backend::Engine.root
    config.asset_paths = ["spec/javascripts", "spec/javascripts/stylesheets"]
    config.fixture_paths = ["spec/javascripts/fixtures"]

    config.suite do |suite|
      suite.use_framework :mocha, "2.3.3"
      suite.matcher = "{spec/javascripts,app/assets}/**/*_spec.{js,js.coffee,coffee}"
      suite.helper = "spec_helper"
      suite.boot_partial = "/boot"
      suite.expand_assets = true
    end
  end
else
  require 'solidus_backend'

  require 'teaspoon'

  require 'spree/testing_support/dummy_app'

  DummyApp.setup(
    gem_root: File.expand_path('../../', __FILE__),
    lib_name: 'solidus_backend'
  )
end
{'fraction_non_alphanumeric': 0.14349276974416017, 'fraction_numerical': 0.00389321468298109, 'mean_word_length': 4.14, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4506016', 'n_tokens_mistral': 653, 'n_tokens_neox': 635, 'n_words': 106}