taza 0.9.2.1 → 1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +13 -5
- data/.gitignore +3 -1
- data/.ruby-gemset +1 -0
- data/.ruby-version +1 -0
- data/.travis.yml +2 -1
- data/Gemfile +1 -1
- data/History.txt +4 -0
- data/README.md +6 -1
- data/lib/formatters/failing_examples_formatter.rb +1 -1
- data/lib/taza.rb +0 -1
- data/lib/taza/browser.rb +2 -2
- data/lib/taza/fixture.rb +1 -1
- data/lib/taza/settings.rb +1 -1
- data/lib/taza/site.rb +2 -2
- data/lib/taza/version.rb +1 -1
- data/spec/generators/flow_generator_spec.rb +1 -1
- data/spec/generators/page_generator_spec.rb +3 -3
- data/spec/generators/partial_generator_spec.rb +1 -1
- data/spec/generators/project_generator_spec.rb +13 -13
- data/spec/generators/site_generator_spec.rb +9 -9
- data/spec/generators/taza_bin_spec.rb +6 -10
- data/spec/platform/windows/browser_win.rb +17 -18
- data/spec/spec_helper.rb +1 -1
- data/spec/taza/array_spec.rb +4 -4
- data/spec/taza/browser_spec.rb +4 -4
- data/spec/taza/entity_spec.rb +6 -6
- data/spec/taza/fixture_spec.rb +9 -9
- data/spec/taza/fixtures_spec.rb +10 -10
- data/spec/taza/hash_spec.rb +2 -2
- data/spec/taza/page_module_spec.rb +32 -24
- data/spec/taza/page_spec.rb +16 -16
- data/spec/taza/settings_spec.rb +13 -13
- data/spec/taza/site_fixtures_spec.rb +2 -2
- data/spec/taza/site_spec.rb +62 -67
- data/spec/taza/string_spec.rb +2 -2
- data/taza.gemspec +4 -3
- metadata +53 -39
- data/.rvmrc +0 -49
- data/lib/taza.rb.backup +0 -24
data/spec/taza/entity_spec.rb
CHANGED
@@ -4,32 +4,32 @@ require 'taza/entity'
|
|
4
4
|
describe Taza::Entity do
|
5
5
|
it "should add methods for hash string keys" do
|
6
6
|
entity = Taza::Entity.new({'apple' => 'pie'},nil)
|
7
|
-
entity.
|
7
|
+
expect(entity).to respond_to :apple
|
8
8
|
end
|
9
9
|
|
10
10
|
it "should be accessible like a hash(foo[:bar])" do
|
11
11
|
entity = Taza::Entity.new({:apple => 'pie'},nil)
|
12
|
-
entity[:apple].
|
12
|
+
expect(entity[:apple]).to eql 'pie'
|
13
13
|
end
|
14
14
|
|
15
15
|
it "should be able to define methods for multiple levels" do
|
16
16
|
entity = Taza::Entity.new({:fruits => {:apple => 'pie'} },nil)
|
17
|
-
entity.fruits.apple.
|
17
|
+
expect(entity.fruits.apple).to eql 'pie'
|
18
18
|
end
|
19
19
|
|
20
20
|
it "should be able to return a hash object" do
|
21
21
|
entity = Taza::Entity.new({:apple => 'pie' },nil)
|
22
|
-
entity.to_hash[:apple].
|
22
|
+
expect(entity.to_hash[:apple]).to eql 'pie'
|
23
23
|
end
|
24
24
|
|
25
25
|
it "should be able to do string-to-symbol conversion for hash keys using to_hash" do
|
26
26
|
entity = Taza::Entity.new({'apple' => 'pie' },nil)
|
27
|
-
entity.to_hash[:apple].
|
27
|
+
expect(entity.to_hash[:apple]).to eql 'pie'
|
28
28
|
end
|
29
29
|
|
30
30
|
it "should be able to do string-to-symbol conversion for hash keys" do
|
31
31
|
entity = Taza::Entity.new({'fruits' => {'apple' => 'pie' }},nil)
|
32
|
-
entity.to_hash[:fruits][:apple].
|
32
|
+
expect(entity.to_hash[:fruits][:apple]).to eql 'pie'
|
33
33
|
end
|
34
34
|
|
35
35
|
end
|
data/spec/taza/fixture_spec.rb
CHANGED
@@ -12,33 +12,33 @@ describe Taza::Fixture do
|
|
12
12
|
fixture = Taza::Fixture.new
|
13
13
|
fixture.load_fixtures_from(@base_path)
|
14
14
|
example = fixture.get_fixture_entity(:examples,'first_example')
|
15
|
-
example.name.
|
16
|
-
example.price.
|
15
|
+
expect(example.name).to eql "first"
|
16
|
+
expect(example.price).to eql 1
|
17
17
|
end
|
18
18
|
|
19
19
|
it "should use the spec fixtures folder as the base path" do
|
20
|
-
Taza::Fixture.base_path.
|
20
|
+
expect(Taza::Fixture.base_path).to eql './spec/fixtures/'
|
21
21
|
end
|
22
22
|
|
23
23
|
it "should know if a pluralized fixture of that name exists" do
|
24
24
|
fixture = Taza::Fixture.new
|
25
25
|
fixture.load_fixtures_from(@base_path)
|
26
|
-
fixture.pluralized_fixture_exists?('example').
|
27
|
-
fixture.pluralized_fixture_exists?('boo').
|
26
|
+
expect(fixture.pluralized_fixture_exists?('example')).to be true
|
27
|
+
expect(fixture.pluralized_fixture_exists?('boo')).to be false
|
28
28
|
end
|
29
29
|
|
30
30
|
it "should be able to get all fixtures loaded excluding sub-folder fixtures" do
|
31
31
|
fixture = Taza::Fixture.new
|
32
32
|
fixture.load_fixtures_from(@base_path)
|
33
|
-
fixture.fixture_names.
|
33
|
+
expect(fixture.fixture_names).to be_equivalent [:examples,:users,:foos]
|
34
34
|
end
|
35
35
|
|
36
36
|
it "should be able to get specific fixture entities" do
|
37
37
|
fixture = Taza::Fixture.new
|
38
38
|
fixture.load_fixtures_from(@base_path)
|
39
39
|
examples = fixture.specific_fixture_entities(:examples, ['third_example'])
|
40
|
-
examples.length.
|
41
|
-
examples['third_example'].name.
|
40
|
+
expect(examples.length).to eql 1
|
41
|
+
expect(examples['third_example'].name).to eql 'third'
|
42
42
|
end
|
43
43
|
|
44
44
|
it "should not modified the fixtures when you get specific entities off a fixture" do
|
@@ -46,7 +46,7 @@ describe Taza::Fixture do
|
|
46
46
|
fixture.load_fixtures_from(@base_path)
|
47
47
|
previous_count = fixture.get_fixture(:examples).length
|
48
48
|
examples = fixture.specific_fixture_entities(:examples, ['third_example'])
|
49
|
-
fixture.get_fixture(:examples).length.
|
49
|
+
expect(fixture.get_fixture(:examples).length).to eql previous_count
|
50
50
|
end
|
51
51
|
|
52
52
|
end
|
data/spec/taza/fixtures_spec.rb
CHANGED
@@ -8,41 +8,41 @@ describe "Taza::Fixtures" do
|
|
8
8
|
include Taza::Fixtures
|
9
9
|
|
10
10
|
it "should be able to look up a fixture entity off fixture_methods module" do
|
11
|
-
examples(:first_example).name.
|
11
|
+
expect(examples(:first_example).name).to eql 'first'
|
12
12
|
end
|
13
13
|
|
14
14
|
it "should still raise method missing error" do
|
15
|
-
lambda{zomgwtf(:first_example)}.
|
15
|
+
expect(lambda{zomgwtf(:first_example)}).to raise_error(NoMethodError)
|
16
16
|
end
|
17
17
|
|
18
18
|
#TODO: this test tests what is in entity's instance eval not happy with it being here
|
19
19
|
it "should be able to look up a fixture entity off fixture_methods module" do
|
20
|
-
examples(:first_example).user.name.
|
20
|
+
expect(examples(:first_example).user.name).to eql users(:shatner).name
|
21
21
|
end
|
22
22
|
|
23
23
|
it "should be able to resolve one to many relationships" do
|
24
|
-
foos(:gap).examples.length.
|
24
|
+
expect(foos(:gap).examples.length).to eql 2
|
25
25
|
end
|
26
26
|
|
27
27
|
it "should be able to get one to many entities" do
|
28
|
-
foos(:gap).examples['first_example'].name.
|
29
|
-
foos(:gap).examples['second_example'].name.
|
28
|
+
expect(foos(:gap).examples['first_example'].name).to eql 'first'
|
29
|
+
expect(foos(:gap).examples['second_example'].name).to eql 'second'
|
30
30
|
end
|
31
31
|
|
32
32
|
it "should not be able to access fixtures in sub-folders if not included" do
|
33
|
-
lambda{bars(:foo)}.
|
33
|
+
expect(lambda{bars(:foo)}).to raise_error(NoMethodError)
|
34
34
|
end
|
35
35
|
|
36
36
|
it "should template fixture files" do
|
37
|
-
users(:shatner).age.
|
37
|
+
expect(users(:shatner).age).to eql 66
|
38
38
|
end
|
39
39
|
|
40
40
|
it "should be able to get one to many entities for hash[key] style" do
|
41
|
-
foos(:gap)['examples']['first_example']['name'].
|
41
|
+
expect(foos(:gap)['examples']['first_example']['name']).to eql 'first'
|
42
42
|
end
|
43
43
|
|
44
44
|
it "should be able to access multiple levels inside fixtures" do
|
45
|
-
examples(:forth_example).something.user.name.
|
45
|
+
expect(examples(:forth_example).something.user.name).to eql 'William Shatner'
|
46
46
|
end
|
47
47
|
|
48
48
|
end
|
data/spec/taza/hash_spec.rb
CHANGED
@@ -6,10 +6,10 @@ require 'extensions/hash'
|
|
6
6
|
describe 'Hash Extensions' do
|
7
7
|
it "should add methods for hash keys to some instance" do
|
8
8
|
entity = {'apple' => 'pie'}.convert_hash_keys_to_methods(nil)
|
9
|
-
entity.
|
9
|
+
expect(entity).to respond_to :apple
|
10
10
|
end
|
11
11
|
it "should not add the methods to a hash" do
|
12
12
|
entity = {'apple' => 'pie'}.convert_hash_keys_to_methods(nil)
|
13
|
-
entity.
|
13
|
+
expect(entity).to_not be_a_instance_of Hash
|
14
14
|
end
|
15
15
|
end
|
@@ -14,7 +14,7 @@ describe "Taza Page Module" do
|
|
14
14
|
it "should execute elements in the context of their page module" do
|
15
15
|
page = PageWithModule.new(:module)
|
16
16
|
page.browser = :something
|
17
|
-
page.module_element.
|
17
|
+
expect(page.module_element).to eql :something
|
18
18
|
end
|
19
19
|
|
20
20
|
class AnotherPageWithModule < ::Taza::Page
|
@@ -27,13 +27,13 @@ describe "Taza Page Module" do
|
|
27
27
|
|
28
28
|
|
29
29
|
it "should not execute elements that belong to a page module but accessed without it" do
|
30
|
-
lambda { AnotherPageWithModule.new.another_module_element }.
|
30
|
+
expect(lambda { AnotherPageWithModule.new.another_module_element }).to raise_error(NoMethodError)
|
31
31
|
end
|
32
32
|
|
33
33
|
it "should execute elements in the context of their page module when accessed with it" do
|
34
34
|
page = AnotherPageWithModule.new(:other_module)
|
35
35
|
page.browser = :another_thing
|
36
|
-
page.another_module_element.
|
36
|
+
expect(page.another_module_element).to eql :another_thing
|
37
37
|
end
|
38
38
|
|
39
39
|
|
@@ -52,8 +52,8 @@ describe "Taza Page Module" do
|
|
52
52
|
it "should execute elements with the same name but different page modules" do
|
53
53
|
module_one = TestPageWithModules.new(:module_one)
|
54
54
|
module_two = TestPageWithModules.new(:module_two)
|
55
|
-
module_one.some_module_element.
|
56
|
-
module_two.some_module_element.
|
55
|
+
expect(module_one.some_module_element).to eql :something
|
56
|
+
expect(module_two.some_module_element).to eql :nothing
|
57
57
|
end
|
58
58
|
|
59
59
|
class PageWithMultipleModuleElements < ::Taza::Page
|
@@ -67,15 +67,16 @@ describe "Taza Page Module" do
|
|
67
67
|
|
68
68
|
it "should execute elements with the same name but different page modules" do
|
69
69
|
page_module = PageWithMultipleModuleElements.new(:module)
|
70
|
-
page_module.module_element.
|
71
|
-
page_module.another_module_element.
|
70
|
+
expect(page_module.module_element).to eql :something
|
71
|
+
expect(page_module.another_module_element).to eql :nothing
|
72
72
|
end
|
73
73
|
|
74
74
|
class PageWithFilterAndModule < ::Taza::Page
|
75
75
|
page_module :module do
|
76
|
-
element(:sample_element) {:something}
|
76
|
+
element(:sample_element) { :something }
|
77
77
|
end
|
78
78
|
filter :sample_filter, :module
|
79
|
+
|
79
80
|
def sample_filter
|
80
81
|
true
|
81
82
|
end
|
@@ -83,14 +84,15 @@ describe "Taza Page Module" do
|
|
83
84
|
|
84
85
|
it "should execute filters for page modules" do
|
85
86
|
page = PageWithFilterAndModule.new(:module)
|
86
|
-
page.sample_element.
|
87
|
+
expect(page.sample_element).to eql :something
|
87
88
|
end
|
88
89
|
|
89
|
-
|
90
|
+
class PageWithFalseFilterAndModule < ::Taza::Page
|
90
91
|
page_module :module do
|
91
|
-
element(:sample_element) {:something}
|
92
|
+
element(:sample_element) { :something }
|
92
93
|
end
|
93
94
|
filter :false_filter, :module
|
95
|
+
|
94
96
|
def false_filter
|
95
97
|
false
|
96
98
|
end
|
@@ -98,14 +100,15 @@ describe "Taza Page Module" do
|
|
98
100
|
|
99
101
|
it "should raise an error for page-module filters that return false" do
|
100
102
|
page = PageWithFalseFilterAndModule.new(:module)
|
101
|
-
lambda { page.sample_element }.
|
103
|
+
expect(lambda { page.sample_element }).to raise_error(Taza::FilterError)
|
102
104
|
end
|
103
105
|
|
104
106
|
class PageWithFilterAndModuleElements < ::Taza::Page
|
105
107
|
page_module :module do
|
106
|
-
element(:sample_element) {:something}
|
108
|
+
element(:sample_element) { :something }
|
107
109
|
end
|
108
110
|
page_module_filter :sample_filter, :module, :sample_element
|
111
|
+
|
109
112
|
def sample_filter
|
110
113
|
false
|
111
114
|
end
|
@@ -113,19 +116,22 @@ describe "Taza Page Module" do
|
|
113
116
|
|
114
117
|
it "should execute filters for elements inside page modules" do
|
115
118
|
page = PageWithFilterAndModuleElements.new(:module)
|
116
|
-
lambda { page.sample_element }.
|
119
|
+
expect(lambda { page.sample_element }).to raise_error(Taza::FilterError)
|
117
120
|
end
|
118
121
|
|
119
122
|
class PageWithFiltersAndModuleElements < ::Taza::Page
|
120
123
|
page_module :module do
|
121
|
-
element(:sample_element) {:something}
|
122
|
-
element(:another_sample_element) {:something}
|
124
|
+
element(:sample_element) { :something }
|
125
|
+
element(:another_sample_element) { :something }
|
123
126
|
end
|
124
127
|
page_module_filter :sample_filter, :module
|
128
|
+
|
125
129
|
def sample_filter
|
126
130
|
true
|
127
131
|
end
|
132
|
+
|
128
133
|
page_module_filter :another_sample_filter, :module, :sample_element
|
134
|
+
|
129
135
|
def another_sample_filter
|
130
136
|
false
|
131
137
|
end
|
@@ -133,22 +139,25 @@ describe "Taza Page Module" do
|
|
133
139
|
|
134
140
|
it "should execute filters for specific and all elements inside page modules" do
|
135
141
|
page = PageWithFiltersAndModuleElements.new(:module)
|
136
|
-
lambda { page.sample_element }.
|
137
|
-
page.another_sample_element.
|
142
|
+
expect(lambda { page.sample_element }).to raise_error(Taza::FilterError)
|
143
|
+
expect(page.another_sample_element).to eql :something
|
138
144
|
end
|
139
145
|
|
140
146
|
class PageWithFiltersAndModulesAndElements < ::Taza::Page
|
141
147
|
page_module :foo_module do
|
142
|
-
element(:sample_element) {:something}
|
148
|
+
element(:sample_element) { :something }
|
143
149
|
end
|
144
150
|
page_module_filter :foo_filter, :foo_module
|
151
|
+
|
145
152
|
def foo_filter
|
146
153
|
true
|
147
154
|
end
|
155
|
+
|
148
156
|
page_module :bar_module do
|
149
|
-
element(:sample_element) {:nothing}
|
157
|
+
element(:sample_element) { :nothing }
|
150
158
|
end
|
151
159
|
page_module_filter :bar_filter, :bar_module
|
160
|
+
|
152
161
|
def bar_filter
|
153
162
|
false
|
154
163
|
end
|
@@ -156,10 +165,9 @@ describe "Taza Page Module" do
|
|
156
165
|
|
157
166
|
it "should execute page module filters for identical element names appropriately" do
|
158
167
|
foo = PageWithFiltersAndModulesAndElements.new(:foo_module)
|
159
|
-
foo.sample_element.
|
168
|
+
expect(foo.sample_element).to eql :something
|
160
169
|
bar = PageWithFiltersAndModulesAndElements.new(:bar_module)
|
161
|
-
lambda { bar.sample_element }.
|
162
|
-
|
163
|
-
|
170
|
+
expect(lambda { bar.sample_element }).to raise_error(Taza::FilterError)
|
171
|
+
end
|
164
172
|
|
165
173
|
end
|
data/spec/taza/page_spec.rb
CHANGED
@@ -22,12 +22,12 @@ describe Taza::Page do
|
|
22
22
|
|
23
23
|
it "should not enter a infinite loop if you call a filtered element inside of a filter" do
|
24
24
|
page = RecursiveFilterExample.new
|
25
|
-
lambda { page.foo }.
|
25
|
+
expect(lambda { page.foo }).to_not raise_error
|
26
26
|
end
|
27
27
|
|
28
28
|
it "should execute an element's block with the params provided for its method" do
|
29
29
|
Taza::Page.element(:boo){|baz| baz}
|
30
|
-
Taza::Page.new.boo("rofl").
|
30
|
+
expect(Taza::Page.new.boo("rofl")).to eql 'rofl'
|
31
31
|
end
|
32
32
|
|
33
33
|
it "element's name can not be nil" do
|
@@ -37,18 +37,18 @@ describe Taza::Page do
|
|
37
37
|
it "should execute elements and filters in the context of the page instance" do
|
38
38
|
page = ElementAndFilterContextExample.new
|
39
39
|
page.browser = :something
|
40
|
-
page.sample_element.
|
40
|
+
expect(page.sample_element).to eql :something
|
41
41
|
end
|
42
42
|
|
43
43
|
it "should add a filter to the classes filters" do
|
44
|
-
ElementAndFilterContextExample.filters.size.
|
44
|
+
expect(ElementAndFilterContextExample.filters.size).to eql 1
|
45
45
|
end
|
46
46
|
|
47
47
|
it "should store the block given to the element method in a method with the name of the parameter" do
|
48
48
|
Taza::Page.element(:foo) do
|
49
49
|
"bar"
|
50
50
|
end
|
51
|
-
Taza::Page.new.foo.
|
51
|
+
expect(Taza::Page.new.foo).to eql 'bar'
|
52
52
|
end
|
53
53
|
|
54
54
|
class FilterAllElements < Taza::Page
|
@@ -62,20 +62,20 @@ describe Taza::Page do
|
|
62
62
|
end
|
63
63
|
|
64
64
|
it "should filter all elements if element argument is not provided" do
|
65
|
-
lambda { FilterAllElements.new.apple }.
|
66
|
-
lambda { FilterAllElements.new.foo }.
|
65
|
+
expect(lambda { FilterAllElements.new.apple }).to raise_error(Taza::FilterError)
|
66
|
+
expect(lambda { FilterAllElements.new.foo }).to raise_error(Taza::FilterError)
|
67
67
|
end
|
68
68
|
|
69
69
|
it "should have empty elements on a new class" do
|
70
70
|
foo = Class::new(superclass=Taza::Page)
|
71
|
-
foo.elements.
|
72
|
-
foo.elements.
|
71
|
+
expect(foo.elements).to_not be_nil
|
72
|
+
expect(foo.elements).to be_empty
|
73
73
|
end
|
74
74
|
|
75
75
|
it "should have empty filters on a new class" do
|
76
76
|
foo = Class::new(superclass=Taza::Page)
|
77
|
-
foo.filters.
|
78
|
-
foo.filters.
|
77
|
+
expect(foo.filters).to_not be_nil
|
78
|
+
expect(foo.filters).to be_empty
|
79
79
|
end
|
80
80
|
|
81
81
|
class FilterAnElement < Taza::Page
|
@@ -89,21 +89,21 @@ describe Taza::Page do
|
|
89
89
|
end
|
90
90
|
|
91
91
|
it "should raise a error if an elements is called and its filter returns false" do
|
92
|
-
lambda { FilterAnElement.new.false_item }.
|
92
|
+
expect(lambda { FilterAnElement.new.false_item }).to raise_error(Taza::FilterError)
|
93
93
|
end
|
94
94
|
|
95
95
|
it "should not call element block if filters fail" do
|
96
96
|
page = FilterAnElement.new
|
97
|
-
lambda { page.false_item }.
|
98
|
-
page.called_element_method.
|
97
|
+
expect(lambda { page.false_item }).to raise_error(Taza::FilterError)
|
98
|
+
expect(page.called_element_method).to_not be true
|
99
99
|
end
|
100
100
|
|
101
101
|
it "should not allow more than one element descriptor with the same element name" do
|
102
|
-
lambda{
|
102
|
+
expect(lambda{
|
103
103
|
class DuplicateElements < Taza::Page
|
104
104
|
element(:foo) { true }
|
105
105
|
element(:foo) { false }
|
106
106
|
end
|
107
|
-
}.
|
107
|
+
}).to raise_error(Taza::ElementError)
|
108
108
|
end
|
109
109
|
end
|
data/spec/taza/settings_spec.rb
CHANGED
@@ -20,44 +20,44 @@ describe Taza::Settings do
|
|
20
20
|
it "should use environment variable for browser settings" do
|
21
21
|
Taza::Settings.stubs(:path).returns("#{@original_directory}/spec/sandbox")
|
22
22
|
ENV['BROWSER'] = 'foo'
|
23
|
-
Taza::Settings.config(@site_name)[:browser].
|
23
|
+
expect(Taza::Settings.config(@site_name)[:browser]).to eql 'foo'
|
24
24
|
end
|
25
25
|
|
26
26
|
it "should provide default values if no config file or environment settings provided" do
|
27
27
|
Taza::Settings.stubs(:path).returns("#{@original_directory}/spec/sandbox")
|
28
|
-
Taza::Settings.config(@site_name)[:driver].
|
29
|
-
Taza::Settings.config(@site_name)[:browser].
|
30
|
-
Taza::Settings.config(@site_name)[:attach].
|
28
|
+
expect(Taza::Settings.config(@site_name)[:driver]).to eql 'selenium'
|
29
|
+
expect(Taza::Settings.config(@site_name)[:browser]).to eql 'firefox'
|
30
|
+
expect(Taza::Settings.config(@site_name)[:attach]).to eql false
|
31
31
|
end
|
32
32
|
|
33
33
|
it "should use environment variable for driver settings" do
|
34
34
|
Taza::Settings.stubs(:path).returns("#{@original_directory}/spec/sandbox")
|
35
35
|
ENV['DRIVER'] = 'bar'
|
36
|
-
Taza::Settings.config(@site_name)[:driver].
|
36
|
+
expect(Taza::Settings.config(@site_name)[:driver]).to eql 'bar'
|
37
37
|
end
|
38
38
|
|
39
39
|
it "should be able to load the site yml" do
|
40
40
|
Taza::Settings.stubs(:path).returns("#{@original_directory}/spec/sandbox")
|
41
|
-
Taza::Settings.config("SiteName")[:url].
|
41
|
+
expect(Taza::Settings.config("SiteName")[:url]).to eql 'http://google.com'
|
42
42
|
end
|
43
43
|
|
44
44
|
it "should be able to load a alternate site url" do
|
45
45
|
ENV['TAZA_ENV'] = 'clown_shoes'
|
46
46
|
Taza::Settings.stubs(:path).returns("#{@original_directory}/spec/sandbox")
|
47
|
-
Taza::Settings.config("SiteName")[:url].
|
47
|
+
expect(Taza::Settings.config("SiteName")[:url]).to eql 'http://clownshoes.com'
|
48
48
|
end
|
49
49
|
|
50
50
|
it "should use the config file's variable for browser settings if no environment variable is set" do
|
51
51
|
UserChoices::YamlConfigFileSource.any_instance.stubs(:format_specific_reading).returns({'browser' => 'fu'})
|
52
52
|
Taza::Settings.stubs(:path).returns("#{@original_directory}//spec/sandbox")
|
53
|
-
Taza::Settings.config(@site_name)[:browser].
|
53
|
+
expect(Taza::Settings.config(@site_name)[:browser]).to eql 'fu'
|
54
54
|
end
|
55
55
|
|
56
56
|
it "should use the ENV variables if specfied instead of config files" do
|
57
57
|
ENV['BROWSER'] = 'opera'
|
58
58
|
UserChoices::YamlConfigFileSource.any_instance.stubs(:format_specific_reading).returns({'browser' => 'fu'})
|
59
59
|
Taza::Settings.stubs(:path).returns("#{@original_directory}/spec/sandbox")
|
60
|
-
Taza::Settings.config(@site_name)[:browser].
|
60
|
+
expect(Taza::Settings.config(@site_name)[:browser]).to eql 'opera'
|
61
61
|
end
|
62
62
|
|
63
63
|
it "should use the correct config file to set defaults" do
|
@@ -67,17 +67,17 @@ describe Taza::Settings do
|
|
67
67
|
|
68
68
|
it "should raise error for a config file that doesnot exist" do
|
69
69
|
Taza::Settings.stubs(:path).returns("#{@original_directory}/spec/sandbox/file_not_exists.yml")
|
70
|
-
lambda {Taza::Settings.config}.
|
70
|
+
expect(lambda {Taza::Settings.config}).to raise_error(ArgumentError)
|
71
71
|
end
|
72
72
|
|
73
73
|
it "should path point at root directory" do
|
74
|
-
Taza::Settings.path.
|
74
|
+
expect(Taza::Settings.path).to eql '.'
|
75
75
|
end
|
76
76
|
|
77
77
|
it "should use the config file's variable for driver settings if no environment variable is set" do
|
78
78
|
UserChoices::YamlConfigFileSource.any_instance.stubs(:format_specific_reading).returns({'driver' => 'fun'})
|
79
79
|
Taza::Settings.stubs(:path).returns("#{@original_directory}/spec/sandbox")
|
80
|
-
Taza::Settings.config(@site_name)[:driver].
|
80
|
+
expect(Taza::Settings.config(@site_name)[:driver]).to eql 'fun'
|
81
81
|
end
|
82
82
|
|
83
83
|
class SiteName < Taza::Site
|
@@ -86,7 +86,7 @@ describe Taza::Settings do
|
|
86
86
|
|
87
87
|
it "a site should be able to load its settings" do
|
88
88
|
Taza::Settings.stubs(:path).returns("#{@original_directory}/spec/sandbox")
|
89
|
-
SiteName.settings[:url].
|
89
|
+
expect(SiteName.settings[:url]).to eql 'http://google.com'
|
90
90
|
end
|
91
91
|
|
92
92
|
end
|