<commit_before>require File.expand_path(File.dirname(__FILE__) + '/spec_helper')

ActiveResource::Base.register_configuration(:prefix_with_bar, { :prefix => '/bar' })
ActiveResource::Base.register_configuration(:configurable, { :prefix => '/baz', :timeout => 10 })

class Configurable < ActiveResource::Base
  include ActiveResource::More

  self.site   = 'http://localhost:3000'
  self.prefix = '/foo'
end

describe ActiveResource::Base, '.register_configuration' do
  it 'should assign configuration hash' do
    key    = 'foobar'
    config = { :timeout => 60 }

    ActiveResource::Base.configurations.should_not have_key(key)

    lambda {
      ActiveResource::Base.register_configuration(key, config)
    }.should change { ActiveResource::Base.configurations[key] }.from(nil).to(config)
  end
end

describe ActiveResource::More::Configurations, '.load_config' do
  before { Configurable.prefix = '/foo' }

  it 'should load configuration under specified key' do
    lambda {
      Configurable.load_config :prefix_with_bar
    }.should change(Configurable, :prefix).from('/foo').to('/bar')
  end

  it 'should load configuration with default model name key when key is not specified' do
    lambda {
      Configurable.load_config
    }.should change(Configurable, :prefix).from('/foo').to('/baz')

    Configurable.timeout.should == 10
  end
end
<commit_msg>changed prefix value to avoid the effect on other tests<commit_after>require File.expand_path(File.dirname(__FILE__) + '/spec_helper')

ActiveResource::Base.register_configuration(:prefix_with_bar, { :prefix => '/bar' })
ActiveResource::Base.register_configuration(:configurable, { :prefix => '/baz', :timeout => 10 })

class Configurable < ActiveResource::Base
  include ActiveResource::More

  self.site   = 'http://localhost:3000'
  self.prefix = '/foo'
end

describe ActiveResource::Base, '.register_configuration' do
  it 'should assign configuration hash' do
    key    = 'register_configuration_testing_key'
    config = { :timeout => 60 }

    ActiveResource::Base.configurations.should_not have_key(key)

    lambda {
      ActiveResource::Base.register_configuration(key, config)
    }.should change { ActiveResource::Base.configurations[key] }.from(nil).to(config)
  end
end

describe ActiveResource::More::Configurations, '.load_config' do
  before { Configurable.prefix = '/foo' }

  it 'should load configuration under specified key' do
    lambda {
      Configurable.load_config :prefix_with_bar
    }.should change(Configurable, :prefix).from('/foo').to('/bar')
  end

  it 'should load configuration with default model name key when key is not specified' do
    lambda {
      Configurable.load_config
    }.should change(Configurable, :prefix).from('/foo').to('/baz')

    Configurable.timeout.should == 10
  end
end

{'fraction_non_alphanumeric': 0.12419700214132762, 'fraction_numerical': 0.007137758743754461, 'mean_word_length': 4.561507936507937, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 11, 'https://': 0, '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': '4092898', 'n_tokens_mistral': 822, 'n_tokens_neox': 776, 'n_words': 195}