ymdp 0.1.6 → 0.1.7

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,13 +1,41 @@
1
1
  require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
2
 
3
3
  describe "Configuration" do
4
+ before(:each) do
5
+ stub_screen_io
6
+ reset_constant(:YMDP_ENV, "test")
7
+ end
8
+
4
9
  describe "Config" do
5
10
  before(:each) do
11
+ # using strings for some boolean values to avoid false positives
12
+
6
13
  @config_yml = {
7
14
  "config" => {
8
15
  "username" => "captmal",
9
- "password" => "iluvinara",
10
- "growl" => true
16
+ "password" => "inara",
17
+ "growl" => 'growl',
18
+ "verbose" => 'verbose',
19
+ "compress" => {
20
+ "embedded_js" => "compress_embedded_js",
21
+ "js_assets" => "compress_js_assets",
22
+ "css" => "compress_css",
23
+ "obfuscate" => "obfuscate"
24
+ },
25
+ "validate" => {
26
+ "embedded_js" => {
27
+ "test" => "validate_embedded_js"
28
+ },
29
+ "js_assets" => {
30
+ "test" => "validate_js_assets"
31
+ },
32
+ "json_assets" => {
33
+ "test" => "validate_json_assets"
34
+ },
35
+ "html" => {
36
+ "test" => "validate_html"
37
+ }
38
+ }
11
39
  }
12
40
  }
13
41
  YAML.stub!(:load_file).and_return(@config_yml)
@@ -22,10 +50,60 @@ describe "Configuration" do
22
50
  @config.password.should == @config_yml["config"]["password"]
23
51
  end
24
52
 
25
- it "should return growl" do
53
+ it "should return growl?" do
26
54
  @config.growl?.should == @config_yml["config"]["growl"]
27
55
  end
28
56
 
57
+ it "should return verbose?" do
58
+ @config.verbose?.should == @config_yml["config"]["verbose"]
59
+ end
60
+
61
+ describe "compress settings" do
62
+
63
+ it "should return compress_embedded_js?" do
64
+ @config.compress_embedded_js?.should == @config_yml["config"]["compress"]["embedded_js"]
65
+ end
66
+
67
+ it "should return compress_js_assets?" do
68
+ @config.compress_js_assets?.should == @config_yml["config"]["compress"]["js_assets"]
69
+ end
70
+
71
+ it "should return compress_css?" do
72
+ @config.compress_css?.should == @config_yml["config"]["compress"]["css"]
73
+ end
74
+
75
+ it "should return obfuscate?" do
76
+ @config.obfuscate?.should == @config_yml["config"]["compress"]["obfuscate"]
77
+ end
78
+ end
79
+
80
+ describe "validate settings" do
81
+ it "should return validate_embedded_js?" do
82
+ @config.validate_embedded_js?.should == @config_yml["config"]["validate"]["embedded_js"][YMDP_ENV]
83
+ end
84
+
85
+ it "should return validate_js_assets?" do
86
+ @config.validate_js_assets?.should == @config_yml["config"]["validate"]["js_assets"][YMDP_ENV]
87
+ end
88
+
89
+ it "should return validate_json_assets?" do
90
+ @config.validate_json_assets?.should == @config_yml["config"]["validate"]["json_assets"][YMDP_ENV]
91
+ end
92
+
93
+ it "should return validate_html?" do
94
+ @config.validate_html?.should == @config_yml["config"]["validate"]["html"][YMDP_ENV]
95
+ end
96
+ end
97
+
98
+ describe "each" do
99
+ it "should go through each of the values" do
100
+ $stdout.should_receive(:puts).exactly(@config_yml["config"].keys.length).times
101
+ @config.each do |key, value|
102
+ $stdout.puts key
103
+ end
104
+ end
105
+ end
106
+
29
107
  describe "[]" do
30
108
  it "should return username" do
31
109
  @config["username"].should == @config_yml["config"]["username"]
@@ -35,5 +113,40 @@ describe "Configuration" do
35
113
  @config["password"].should == @config_yml["config"]["password"]
36
114
  end
37
115
  end
116
+
117
+ describe "file not found" do
118
+ before(:each) do
119
+ File.stub!(:exists?).and_return(false)
120
+ end
121
+
122
+ it "should raise an error" do
123
+ lambda {
124
+ @config = YMDP::Configuration::Config.new
125
+ }.should raise_error(/File not found/)
126
+ end
127
+
128
+ it "should output to the screen" do
129
+ $stdout.should_receive(:puts).with(/with the following command/)
130
+ lambda {
131
+ @config = YMDP::Configuration::Config.new
132
+ }.should raise_error(/File not found/)
133
+ end
134
+ end
135
+ end
136
+
137
+ describe "Server" do
138
+ before(:each) do
139
+ @servers_yml = {
140
+ "servers" => {
141
+ "server" => "staging"
142
+ }
143
+ }
144
+ YAML.stub!(:load_file).and_return(@servers_yml)
145
+ @servers = YMDP::Configuration::Servers.new
146
+ end
147
+
148
+ it "should return servers hash" do
149
+ @servers.servers.should == @servers_yml["servers"]
150
+ end
38
151
  end
39
152
  end
@@ -0,0 +1,103 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+
3
+ describe "F" do
4
+ before(:each) do
5
+ stub_file_io
6
+ end
7
+
8
+ describe "concat_files" do
9
+ before(:each) do
10
+ Dir.stub!(:[]).with("./dir/*").and_return(["./dir/first.html", "./dir/second.html"])
11
+ end
12
+
13
+ it "should get the directory" do
14
+ Dir.should_receive(:[]).with("./dir/*").and_return([])
15
+ F.concat_files("./dir/*", "destination")
16
+ end
17
+
18
+ it "should read each file in the directory" do
19
+ File.should_receive(:read).and_return("first", "second")
20
+ F.concat_files("./dir/*", "destination")
21
+ end
22
+
23
+ it "should write the contents of each file in the directory" do
24
+ File.stub!(:read).and_return("first", "second")
25
+ @file.should_receive(:puts).with("first")
26
+ @file.should_receive(:puts).with("second")
27
+ F.concat_files("./dir/*", "destination")
28
+ end
29
+
30
+ it "should write to the destination file" do
31
+ File.should_receive(:open).with("destination", "a").and_yield(@file)
32
+ F.concat_files("./dir/*", "destination")
33
+ end
34
+ end
35
+
36
+ describe "save_to_file" do
37
+ before(:each) do
38
+ @output = "output"
39
+ @destination_path = "@destination"
40
+ end
41
+
42
+ it "should check the existence of destination_path" do
43
+ File.should_receive(:exists?).with(@destination_path)
44
+ F.save_to_file(@output, @destination_path)
45
+ end
46
+
47
+ it "should return false if it exists" do
48
+ File.stub!(:exists?).with(@destination_path).and_return(true)
49
+ F.save_to_file(@output, @destination_path).should == false
50
+ end
51
+
52
+ it "should open the destination path" do
53
+ File.should_receive(:open).with(@destination_path, "w").and_return(@file)
54
+ F.save_to_file(@output, @destination_path)
55
+ end
56
+
57
+ it "should write to the destination file" do
58
+ @file.should_receive(:write).with(@output)
59
+ F.save_to_file(@output, @destination_path)
60
+ end
61
+
62
+ it "should return true" do
63
+ F.save_to_file(@output, @destination_path).should be_true
64
+ end
65
+ end
66
+
67
+ describe "get_line_from_file" do
68
+ before(:each) do
69
+ @path = "path"
70
+ @lines = ["first\n", "second\n", "third\n", "fourth\n", "fifth\n", "sixth\n", "seventh\n"]
71
+ File.stub!(:readlines).with(@path).and_return(@lines)
72
+ end
73
+
74
+ it "should read lines from file" do
75
+ File.should_receive(:readlines).and_return(@lines)
76
+ F.get_line_from_file(@path, 7)
77
+ end
78
+
79
+ it "should get the previous three lines" do
80
+ F.get_line_from_file(@path, 7).should == "\nfifth\nsixth\nseventh\n\n"
81
+ end
82
+ end
83
+
84
+ # I'm not sure how to test the ` method because it calls system calls that don't seem
85
+ # reachable.
86
+ #
87
+ describe "execute" do
88
+ it "should call system" do
89
+ Kernel.should_receive(:system).with("ls")
90
+ F.execute("ls")
91
+ end
92
+
93
+ it "should call system" do
94
+ Kernel.should_receive(:system).with("ls")
95
+ F.execute("ls", :reutrn => false)
96
+ end
97
+
98
+ it "should not call system" do
99
+ Kernel.should_not_receive(:system)
100
+ F.execute("ls", :return => true)
101
+ end
102
+ end
103
+ end
@@ -0,0 +1,53 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+
3
+ require 'compiler/git_helper'
4
+
5
+ describe "GitHelper" do
6
+ before(:each) do
7
+ stub_screen_io
8
+
9
+ @repo = mock('repo')
10
+ Repo.stub!(:new).and_return(@repo)
11
+
12
+ F.stub!(:execute).with("git status", :return => true).and_return("# On branch git-helper")
13
+ @commit = mock('commit', :id => "abcdefg")
14
+ @commits = mock('commits', :first => @commit)
15
+ @repo.stub!(:commits).with("git-helper").and_return(@commits)
16
+
17
+ @git = YMDP::GitHelper.new
18
+ end
19
+
20
+ it "should instantiate" do
21
+ @git.should_not be_nil
22
+ end
23
+
24
+ it "should get hash" do
25
+ @git.get_hash("branch").should == "abcdefg"
26
+ end
27
+
28
+ it "should get current branch" do
29
+ @git.get_current_branch.should == "git-helper"
30
+ end
31
+
32
+ describe "commit" do
33
+ before(:each) do
34
+ @repo.stub!(:add)
35
+ F.stub!(:execute).with(/git commit/, :return => true).and_return("Committed")
36
+ end
37
+
38
+ it "should add current directory" do
39
+ @repo.should_receive(:add).with(".")
40
+ @git.do_commit("message")
41
+ end
42
+
43
+ it "should commit with message" do
44
+ F.should_receive(:execute).with("git commit -am \"message\"", :return => true).and_return("Committed")
45
+ @git.do_commit("message")
46
+ end
47
+
48
+ it "should output results" do
49
+ $stdout.should_receive(:puts).with("Committed")
50
+ @git.do_commit("message")
51
+ end
52
+ end
53
+ end
@@ -6,7 +6,11 @@ CONFIG_PATH = "#{BASE_PATH}/config"
6
6
  SERVERS_PATH = "#{BASE_PATH}/servers"
7
7
  TMP_PATH = "#{BASE_PATH}/tmp"
8
8
 
9
+ YMDP_ENV = "test"
10
+
9
11
  require 'ymdp'
12
+ require 'g'
13
+ require 'active_support'
10
14
  require 'spec'
11
15
  require 'spec/autorun'
12
16
 
@@ -3,6 +3,7 @@ def stub_io
3
3
  stub_file_io
4
4
  stub_file_utils
5
5
  stub_yaml
6
+ stub_growl
6
7
  end
7
8
 
8
9
  def stub_screen_io
@@ -13,9 +14,14 @@ end
13
14
  def stub_file_io(unprocessed_file="")
14
15
  @file ||= mock('file').as_null_object
15
16
  @file.stub!(:read).and_return(unprocessed_file)
16
-
17
+ @file.stub!(:write)
18
+ @file.stub!(:puts)
19
+
20
+ File.stub!(:new).and_return(@file)
17
21
  File.stub!(:exists?).and_return(false)
18
22
  File.stub!(:open).and_yield(@file)
23
+ File.stub!(:read).and_return(unprocessed_file)
24
+ File.stub!(:readlines).and_return(["first\n", "second\n"])
19
25
  end
20
26
 
21
27
  def stub_file_utils
@@ -24,6 +30,10 @@ def stub_file_utils
24
30
  FileUtils.stub!(:cp_r)
25
31
  FileUtils.stub!(:mkdir_p)
26
32
  F.stub!(:concat_files)
33
+ F.stub!(:get_line_from_file).and_return("")
34
+ F.stub!(:save_to_file)
35
+ F.stub!(:save_to_tmp_file)
36
+ F.stub!(:execute).and_return("")
27
37
  end
28
38
 
29
39
  def stub_yaml(output_hash={})
@@ -36,9 +46,24 @@ def stub_erb(processed_file="")
36
46
  ERB.stub!(:new).and_return(@erb)
37
47
  end
38
48
 
49
+ def stub_haml_class
50
+ eval %(
51
+ module Haml
52
+ class Engine
53
+ end
54
+ end
55
+ )
56
+ end
57
+
58
+ def stub_haml(processed_file)
59
+ @haml = mock('haml').as_null_object
60
+ @haml.stub!(:render).and_return(processed_file)
61
+ Haml::Engine.stub!(:new).and_return(@haml)
62
+ end
63
+
39
64
  def stub_git_helper
40
65
  @git_helper = mock('git_helper').as_null_object
41
- GitHelper.stub!(:new).and_return(@git_helper)
66
+ YMDP::GitHelper.stub!(:new).and_return(@git_helper)
42
67
  end
43
68
 
44
69
  def stub_timer
@@ -47,7 +72,22 @@ def stub_timer
47
72
  Timer.stub!(:new).and_return(@timer)
48
73
  end
49
74
 
75
+ def stub_growl
76
+ @g = Object.new
77
+ Growl.stub(:new).and_return(@g)
78
+ @g.stub(:notify).as_null_object
79
+ end
80
+
50
81
  def reset_constant(constant, value)
51
82
  Object.send(:remove_const, constant)
52
83
  Object.const_set(constant, value)
84
+ end
85
+
86
+ def stub_config
87
+ @config = mock('config')
88
+ @config.stub!(:[]).with("doctype").and_return("HTML 4.0 Transitional")
89
+ @config.stub!(:validate_html?).and_return(false)
90
+ @config.stub!(:compress_embedded_js?).and_return(false)
91
+ @config.stub!(:verbose?).and_return(false)
92
+ reset_constant(:CONFIG, @config)
53
93
  end
@@ -3,4 +3,320 @@ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
3
3
  require 'translator/base'
4
4
 
5
5
  describe "Translator" do
6
- end
6
+ before(:each) do
7
+ stub_timer
8
+ stub_screen_io
9
+ end
10
+
11
+ describe "Yaml" do
12
+ before(:each) do
13
+ YAML.stub!(:load_file).and_return({"hi" => "what"})
14
+ @original_translations = ["application_en-US.yml", "sidebar_en-US.yml"]
15
+ Dir.stub!(:[]).with(/app\/assets\/yrb\/en-US\/\*\.yml/).and_return(@original_translations)
16
+ end
17
+
18
+ describe "class methods" do
19
+ it "should output a message for each file" do
20
+ File.stub!(:readlines).and_return([""])
21
+ @original_translations.each do |file|
22
+ $stdout.should_receive(:puts).with(/Processing /)
23
+ end
24
+ YMDP::Translator::Yaml.translate
25
+ end
26
+
27
+ it "should instantiate a new template" do
28
+ @original_translations.each do |file|
29
+ @yaml = mock('yaml', :copy => true)
30
+ YMDP::Translator::Yaml.should_receive(:new).with(file).and_return(@yaml)
31
+ end
32
+ YMDP::Translator::Yaml.translate
33
+ end
34
+
35
+ it "should copy the new template" do
36
+ @original_translations.each do |file|
37
+ @yaml = mock('yaml', :copy => true)
38
+ @yaml.should_receive(:copy)
39
+ YMDP::Translator::Yaml.stub!(:new).with(file).and_return(@yaml)
40
+ end
41
+ YMDP::Translator::Yaml.translate
42
+ end
43
+ end
44
+
45
+ describe "instance methods" do
46
+ before(:each) do
47
+ @path = "path_en-US.yml"
48
+ @yml = YMDP::Translator::Yaml.new(@path)
49
+ end
50
+
51
+ it "should instantiate" do
52
+ @yml.should_not be_nil
53
+ end
54
+
55
+ it "should copy keys" do
56
+ File.stub!(:readlines).with("path_en-US.yml").and_return(["key: value\n"])
57
+ #
58
+ @file = mock('file', :puts => true)
59
+ @file.should_receive(:puts).with(/key: translated value/)
60
+
61
+ File.stub!(:open).with(anything, "a").and_yield(@file)
62
+
63
+ size = YMDP::Translator::Yaml::LOCALES.size - 1
64
+
65
+ YMDP::Translator::Yaml::LOCALES.each do |lang, code|
66
+ unless lang == "en-US"
67
+ Dir.should_receive(:[]).with(/app\/assets\/yrb\/#{lang}\/\*\.yml/).and_return(["keys_#{lang}.yml"])
68
+ end
69
+ end
70
+
71
+ Translate.stub!(:t).with("value", "ENGLISH", anything).exactly(size).and_return("translated value")
72
+
73
+ @yml.copy
74
+ end
75
+
76
+ it "should not copy comments" do
77
+ File.stub!(:readlines).with("path_en-US.yml").and_return(["# comment\n"])
78
+
79
+ @file = mock('file', :puts => true)
80
+ @file.should_not_receive(:puts).with(/key: translated value/)
81
+
82
+ File.stub!(:open).with(anything, "a").and_yield(@file)
83
+
84
+ size = YMDP::Translator::Yaml::LOCALES.size - 1
85
+ Translate.stub!(:t).with("value", "ENGLISH", anything).exactly(size).and_return("translated value")
86
+
87
+ @yml.copy
88
+ end
89
+
90
+ it "should not copy empty keys" do
91
+ File.stub!(:readlines).with("path_en-US.yml").and_return(["KEY=\n"])
92
+
93
+ @file = mock('file', :puts => true)
94
+ @file.should_not_receive(:puts).with(/key: translated value/)
95
+
96
+ File.stub!(:open).with(anything, "a").and_yield(@file)
97
+
98
+ size = YMDP::Translator::Yaml::LOCALES.size - 1
99
+ Translate.stub!(:t).with("value", "ENGLISH", anything).exactly(size).and_return("translated value")
100
+
101
+ @yml.copy
102
+ end
103
+
104
+ it "should copy keys with variables" do
105
+ File.stub!(:readlines).with("path_en-US.yml").and_return(["key: value {0}\n"])
106
+
107
+ @file = mock('file', :puts => true)
108
+ @file.should_receive(:puts).with(/key: translated value {0}/)
109
+
110
+ File.stub!(:open).with(anything, "a").and_yield(@file)
111
+
112
+ size = YMDP::Translator::Yaml::LOCALES.size - 1
113
+
114
+ YMDP::Translator::Yaml::LOCALES.each do |lang, code|
115
+ unless lang == "en-US"
116
+ Dir.should_receive(:[]).with(/app\/assets\/yrb\/#{lang}\/\*\.yml/).and_return(["keys_#{lang}.yml"])
117
+ end
118
+ end
119
+
120
+ Translate.stub!(:t).with("value [0]", "ENGLISH", anything).exactly(size).and_return("translated value [0]")
121
+
122
+ @yml.copy
123
+ end
124
+ end
125
+ end
126
+
127
+ describe "YRB" do
128
+ before(:each) do
129
+ @original_translations = ["application_en-US.pres", "sidebar_en-US.pres"]
130
+ Dir.stub!(:[]).with(/app\/assets\/yrb\/en-US\/\*\.pres/).and_return(@original_translations)
131
+ end
132
+
133
+ describe "class methods" do
134
+ it "should output a message for each file" do
135
+ File.stub!(:readlines).and_return([""])
136
+ @original_translations.each do |file|
137
+ $stdout.should_receive(:puts).with(/Processing /)
138
+ end
139
+ YMDP::Translator::YRB.translate
140
+ end
141
+
142
+ it "should instantiate a new template" do
143
+ @original_translations.each do |file|
144
+ @yrb = mock('yrb', :copy => true)
145
+ YMDP::Translator::YRB.should_receive(:new).with(file).and_return(@yrb)
146
+ end
147
+ YMDP::Translator::YRB.translate
148
+ end
149
+
150
+ it "should copy the new template" do
151
+ @original_translations.each do |file|
152
+ @yrb = mock('yrb', :copy => true)
153
+ @yrb.should_receive(:copy)
154
+ YMDP::Translator::YRB.stub!(:new).with(file).and_return(@yrb)
155
+ end
156
+ YMDP::Translator::YRB.translate
157
+ end
158
+ end
159
+
160
+ describe "instance methods" do
161
+ before(:each) do
162
+ @path = "path_en-US.pres"
163
+ @yrb = YMDP::Translator::YRB.new(@path)
164
+ end
165
+
166
+ it "should instantiate" do
167
+ @yrb.should_not be_nil
168
+ end
169
+
170
+ it "should copy keys" do
171
+ File.stub!(:readlines).with("path_en-US.pres").and_return(["KEY=value\n"])
172
+
173
+ @file = mock('file', :puts => true)
174
+ @file.should_receive(:puts).with(/KEY=translated value/)
175
+
176
+ File.stub!(:open).with(anything, "a").and_yield(@file)
177
+
178
+ size = YMDP::Translator::YRB::LOCALES.size - 1
179
+
180
+ @template = mock('template', :to_hash => {"key" => "value"})
181
+ YMDP::Compiler::Template::YRB.stub!(:new).and_return(@template)
182
+
183
+ YMDP::Translator::YRB::LOCALES.each do |lang, code|
184
+ unless lang == "en-US"
185
+ Dir.should_receive(:[]).with(/app\/assets\/yrb\/#{lang}\/\*\.pres/).and_return(["keys_#{lang}.pres"])
186
+ end
187
+ end
188
+
189
+ Translate.stub!(:t).with("value", "ENGLISH", anything).exactly(size).and_return("translated value")
190
+
191
+ @yrb.copy
192
+ end
193
+
194
+ it "should not copy comments" do
195
+ File.stub!(:readlines).with("path_en-US.pres").and_return(["# comment\n"])
196
+
197
+ @file = mock('file', :puts => true)
198
+ @file.should_not_receive(:puts).with(/KEY=translated value/)
199
+
200
+ File.stub!(:open).with(anything, "a").and_yield(@file)
201
+
202
+ size = YMDP::Translator::YRB::LOCALES.size - 1
203
+ Translate.stub!(:t).with("value", "ENGLISH", anything).exactly(size).and_return("translated value")
204
+
205
+ @yrb.copy
206
+ end
207
+
208
+ it "should not copy empty keys" do
209
+ File.stub!(:readlines).with("path_en-US.pres").and_return(["KEY=\n"])
210
+
211
+ @file = mock('file', :puts => true)
212
+ @file.should_not_receive(:puts).with(/KEY=translated value/)
213
+
214
+ File.stub!(:open).with(anything, "a").and_yield(@file)
215
+
216
+ size = YMDP::Translator::YRB::LOCALES.size - 1
217
+ Translate.stub!(:t).with("value", "ENGLISH", anything).exactly(size).and_return("translated value")
218
+
219
+ @yrb.copy
220
+ end
221
+
222
+ it "should copy keys with variables" do
223
+ File.stub!(:readlines).with("path_en-US.pres").and_return(["KEY=value {0}\n"])
224
+
225
+ @file = mock('file', :puts => true)
226
+ @file.should_receive(:puts).with(/KEY=translated value {0}/)
227
+
228
+ File.stub!(:open).with(anything, "a").and_yield(@file)
229
+
230
+ size = YMDP::Translator::YRB::LOCALES.size - 1
231
+
232
+ @template = mock('template', :to_hash => {"key" => "value"})
233
+ YMDP::Compiler::Template::YRB.stub!(:new).and_return(@template)
234
+
235
+ YMDP::Translator::YRB::LOCALES.each do |lang, code|
236
+ unless lang == "en-US"
237
+ Dir.should_receive(:[]).with(/app\/assets\/yrb\/#{lang}\/\*\.pres/).and_return(["keys_#{lang}.pres"])
238
+ end
239
+ end
240
+
241
+ Translate.stub!(:t).with("value [0]", "ENGLISH", anything).exactly(size).and_return("translated value [0]")
242
+
243
+ @yrb.copy
244
+ end
245
+ end
246
+ end
247
+
248
+ describe "Base" do
249
+ describe "class methods" do
250
+ it "should raise error on original_translations" do
251
+ lambda {
252
+ YMDP::Translator::Base.original_translations
253
+ }.should raise_error("Define in child")
254
+ end
255
+
256
+ it "should raise error on all_source_files" do
257
+ lambda {
258
+ YMDP::Translator::Base.all_source_files
259
+ }.should raise_error("Define in child")
260
+ end
261
+
262
+ it "should raise error on template" do
263
+ lambda {
264
+ YMDP::Translator::Base.template
265
+ }.should raise_error("Define in child")
266
+ end
267
+
268
+ it "should raise error on translate" do
269
+ lambda {
270
+ YMDP::Translator::Base.translate
271
+ }.should raise_error("Define in child")
272
+ end
273
+ end
274
+
275
+ describe "instance methods" do
276
+ it "should raise an error on instantiation" do
277
+ lambda {
278
+ @base = YMDP::Translator::Base.new("path")
279
+ }.should raise_error("Define in child")
280
+ end
281
+ end
282
+
283
+ describe "raise in child" do
284
+ before(:each) do
285
+ class YMDPTranslatorBase < YMDP::Translator::Base
286
+ def language(path)
287
+ "en-US"
288
+ end
289
+
290
+ def base_filename(path)
291
+ path
292
+ end
293
+ end
294
+ @thing = YMDPTranslatorBase.new("path")
295
+ end
296
+
297
+ it "should raise an error calling parse_template" do
298
+ lambda {
299
+ @thing.parse_template("path")
300
+ }.should raise_error("Define in child")
301
+ end
302
+
303
+ it "should raise an error calling format" do
304
+ lambda {
305
+ @thing.format("a", "b")
306
+ }.should raise_error("Define in child")
307
+ end
308
+
309
+ it "should raise an error calling key_and_value_from_line" do
310
+ lambda {
311
+ @thing.key_and_value_from_line("line")
312
+ }.should raise_error("Define in child")
313
+ end
314
+
315
+ it "should raise an error calling comment?" do
316
+ lambda {
317
+ @thing.comment?("line")
318
+ }.should raise_error("Define in child")
319
+ end
320
+ end
321
+ end
322
+ end