/
config_spec.rb
87 lines (71 loc) · 2.85 KB
/
config_spec.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
require 'spec_helper'
describe Pickle::Config do
subject { Pickle::Config.new }
describe "new" do
its(:adapters) { should == [:machinist, :factory_girl, :orm] }
its(:adapter_classes) { should == [Pickle::Adapter::Machinist, Pickle::Adapter::FactoryGirl, Pickle::Adapter::Orm] }
its(:predicates) { should be_empty }
its(:mappings) { should be_empty }
its(:factories) { should be_empty }
its(:aliases) { should be_empty }
its(:label_map) { should be_empty }
end
describe "setting adapters to [:machinist, <adapter_class>]" do
let(:adapter_class) { Class.new(Object) }
before { subject.adapters = [:machinist, adapter_class] }
it "should have :adapter_classes [Pickle::Adapter::Machinist, <adapter_class>]" do
subject.adapter_classes.should == [Pickle::Adapter::Machinist, adapter_class]
end
end
describe "#map 'foo', :to => 'faz'" do
before { subject.map 'foo', :to => 'faz' }
it "should create Mapping('foo', 'faz') mapping" do
subject.mappings.first.tap do |mapping|
mapping.should be_kind_of Pickle::Config::Mapping
mapping.search.should == 'foo'
mapping.replacement.should == 'faz'
end
end
end
describe "#map 'foo', 'bar' :to => 'faz'" do
before { subject.map 'foo', 'bar', :to => 'faz' }
it "should create 2 mappings" do
subject.mappings.first.should == Pickle::Config::Mapping.new('foo', 'faz')
subject.mappings.last.should == Pickle::Config::Mapping.new('bar', 'faz')
end
end
it "#configure(&block) should execiute on self" do
subject.should_receive(:foo).with(:bar)
subject.configure do |c|
c.foo :bar
end
end
describe "map_label_for" do
let(:config) {Pickle::Config.new}
subject { config }
describe "'user', :to => 'name'" do
before { config.map_label_for('user', :to => 'name') }
its(:label_map) {should include('user' => 'name')}
end
describe "'user', 'admin', 'supplier', :to => 'name'" do
before { config.map_label_for 'user','admin','supplier', :to => 'name' }
its(:label_map) {should include('user' => 'name')}
its(:label_map) {should include('admin' => 'name')}
its(:label_map) {should include('supplier' => 'name')}
end
end
describe "alias" do
let(:config) {Pickle::Config.new}
subject { config }
describe "user, :to => 'name'" do
before { config.alias('admin', :to => 'admin user') }
its(:aliases) {should include('admin' => 'admin user')}
end
describe "customer, supplier, reseller :to => 'trade user'" do
before { config.alias 'customer','supplier','reseller', :to => 'trade user' }
its(:aliases) {should include('customer' => 'trade user')}
its(:aliases) {should include('supplier' => 'trade user')}
its(:aliases) {should include('reseller' => 'trade user')}
end
end
end