<commit_before># loads and runs all tests for the omega project
#
# Copyright (C) 2010-2012 <NAME> <<EMAIL>>
# Licensed under the AGPLv3+ http://www.gnu.org/licenses/agpl.txt

require 'rubygems'
require 'factory_girl'

CURRENT_DIR=File.dirname(__FILE__)
$: << File.expand_path(CURRENT_DIR + "/../lib")

CLOSE_ENOUGH=0.000001

require 'motel'
require 'cosmos'
require 'manufactured'
require 'users'
require 'omega'

FactoryGirl.find_definitions

RSpec.configure do |config|
  config.before(:all) {
  }
  config.before(:each) {
    Motel::RJRAdapter.init
    Users::RJRAdapter.init
    Cosmos::RJRAdapter.init
    Manufactured::RJRAdapter.init

    TestUser.create.clear_privileges

    Omega::Client::Node.client_username = 'omega-test'
    Omega::Client::Node.client_password = '<PASSWORD>'
    Omega::Client::Node.node = RJR::LocalNode.new :node_id => 'omega-test'

    Omega::Client::Node.clear

    # preload all server entities
    FactoryGirl.factories.each { |k,v|
      p = k.instance_variable_get(:@parent)
      FactoryGirl.build(k.name) if p =~ /server_.*/
    }
  }

  config.after(:each) {
    Motel::Runner.instance.clear
  }
  config.after(:all) {
  }
end

class TestUser
  def self.create
    @@test_user = FactoryGirl.build(:test_user)
    return self
  end

  def self.clear_privileges
    @@test_user.roles.first.clear_privileges
    return self
  end

  def self.add_privilege(privilege_id, entity_id = nil)
    @@test_user.roles.first.add_privilege \
      Users::Privilege.new(:id => privilege_id, :entity_id => entity_id)
    return self
  end

  def self.add_role(role_id)
    Omega::Roles::ROLES[role_id].each { |pe|
      self.add_privilege pe[0], pe[1]<commit_msg>small fix to spec suite<commit_after># loads and runs all tests for the omega project
#
# Copyright (C) 2010-2012 <NAME> <<EMAIL>>
# Licensed under the AGPLv3+ http://www.gnu.org/licenses/agpl.txt

require 'rubygems'
require 'factory_girl'

CURRENT_DIR=File.dirname(__FILE__)
$: << File.expand_path(CURRENT_DIR + "/../lib")

CLOSE_ENOUGH=0.000001

require 'motel'
require 'cosmos'
require 'manufactured'
require 'users'
require 'omega'

FactoryGirl.find_definitions

RSpec.configure do |config|
  config.before(:all) {
  }
  config.before(:each) {
    Motel::RJRAdapter.init
    Users::RJRAdapter.init
    Cosmos::RJRAdapter.init
    Manufactured::RJRAdapter.init

    TestUser.create.clear_privileges

    Omega::Client::Node.client_username = 'omega-test'
    Omega::Client::Node.client_password = '<PASSWORD>'
    Omega::Client::Node.node = RJR::LocalNode.new :node_id => 'omega-test'

    Omega::Client::Node.clear

    # preload all server entities
    FactoryGirl.factories.each { |k,v|
      p = k.instance_variable_get(:@parent)
      FactoryGirl.build(k.name) if p =~ /server_.*/
    }
  }

  config.after(:each) {
    Manufactured::Registry.instance.init
    Cosmos::Registry.instance.init
    Motel::Runner.instance.clear
    Users::Registry.instance.init
  }
  config.after(:all) {
  }
end

class TestUser
  def self.create
    @@test_user = FactoryGirl.build(:test_user)
    return self
  end

  def self.clear_privileges
    @@test_user.roles.first.clear_privileges
    return self
  end

  def self.add_privilege(privilege_id, entity_id = nil)
    @@test_user.roles.first.add_privilege \
      Users::Privilege.new(:id => privilege_id, :entity_id => entity_id)
    return self
  end

  def self.add_role(role_id)
    Omega::Roles::ROLES[role_id].each { |pe|
      self.add_privilege pe[0], pe[1]
{'fraction_non_alphanumeric': 0.13142857142857142, 'fraction_numerical': 0.010285714285714285, 'mean_word_length': 3.903361344537815, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '5244662', 'n_tokens_mistral': 1299, 'n_tokens_neox': 1223, 'n_words': 222}