diff options
Diffstat (limited to 'spec/ruby/library/erb')
| -rw-r--r-- | spec/ruby/library/erb/def_class_spec.rb | 2 | ||||
| -rw-r--r-- | spec/ruby/library/erb/def_module_spec.rb | 3 | ||||
| -rw-r--r-- | spec/ruby/library/erb/defmethod/def_erb_method_spec.rb | 2 | ||||
| -rw-r--r-- | spec/ruby/library/erb/filename_spec.rb | 4 | ||||
| -rw-r--r-- | spec/ruby/library/erb/new_spec.rb | 22 | ||||
| -rw-r--r-- | spec/ruby/library/erb/result_spec.rb | 4 | ||||
| -rw-r--r-- | spec/ruby/library/erb/run_spec.rb | 6 |
7 files changed, 33 insertions, 10 deletions
diff --git a/spec/ruby/library/erb/def_class_spec.rb b/spec/ruby/library/erb/def_class_spec.rb index 88bd385f4c..fb687531e0 100644 --- a/spec/ruby/library/erb/def_class_spec.rb +++ b/spec/ruby/library/erb/def_class_spec.rb @@ -24,6 +24,8 @@ END MyClass1ForErb = erb.def_class(MyClass1ForErb_, 'render()') MyClass1ForErb.method_defined?(:render).should == true MyClass1ForErb.new('foo', 123).render().should == expected + ensure + Object.send(:remove_const, :MyClass1ForErb) end end diff --git a/spec/ruby/library/erb/def_module_spec.rb b/spec/ruby/library/erb/def_module_spec.rb index 806e564ef0..5f67aeb2b9 100644 --- a/spec/ruby/library/erb/def_module_spec.rb +++ b/spec/ruby/library/erb/def_module_spec.rb @@ -22,6 +22,9 @@ END include MyModule2ForErb end MyClass2ForErb.new.render('foo', 123).should == expected + ensure + Object.send(:remove_const, :MyClass2ForErb) + Object.send(:remove_const, :MyModule2ForErb) end end diff --git a/spec/ruby/library/erb/defmethod/def_erb_method_spec.rb b/spec/ruby/library/erb/defmethod/def_erb_method_spec.rb index dc1e044d9c..1cd7582936 100644 --- a/spec/ruby/library/erb/defmethod/def_erb_method_spec.rb +++ b/spec/ruby/library/erb/defmethod/def_erb_method_spec.rb @@ -58,6 +58,8 @@ END end end MyClass4ForErb.new([10,20,30]).render().should == expected + ensure + Object.send(:remove_const, :MY_INPUT4_FOR_ERB) end diff --git a/spec/ruby/library/erb/filename_spec.rb b/spec/ruby/library/erb/filename_spec.rb index 8ecaed7343..bbd2233bb3 100644 --- a/spec/ruby/library/erb/filename_spec.rb +++ b/spec/ruby/library/erb/filename_spec.rb @@ -13,7 +13,7 @@ describe "ERB#filename" do @ex = e raise e end - }.should raise_error(SyntaxError) + }.should.raise(SyntaxError) expected = filename @ex.message =~ /^(.*?):(\d+): / @@ -30,7 +30,7 @@ describe "ERB#filename" do @ex = e raise e end - }.should raise_error(SyntaxError) + }.should.raise(SyntaxError) expected = '(erb)' @ex.message =~ /^(.*?):(\d+): / diff --git a/spec/ruby/library/erb/new_spec.rb b/spec/ruby/library/erb/new_spec.rb index f18e25939e..35ac0dfdfe 100644 --- a/spec/ruby/library/erb/new_spec.rb +++ b/spec/ruby/library/erb/new_spec.rb @@ -83,7 +83,7 @@ END -> { ERBSpecs.new_erb(input, trim_mode: '-').result - }.should raise_error(SyntaxError) + }.should.raise(SyntaxError) end it "regards lines starting with '%' as '<% ... %>' when trim_mode is '%'" do @@ -130,12 +130,28 @@ END <b><%#= item %></b> <%# end %> END - ERBSpecs.new_erb(input).result.should == "\n<b></b>\n\n" + ERBSpecs.new_erb(input).result.should == "\n<b></b>\n\n" ERBSpecs.new_erb(input, trim_mode: '<>').result.should == "<b></b>\n" end it "forget local variables defined previous one" do ERB.new(@eruby_str).result - ->{ ERB.new("<%= list %>").result }.should raise_error(NameError) + ->{ ERB.new("<%= list %>").result }.should.raise(NameError) + end + + version_is ERB.const_get(:VERSION, false), ""..."6.0.0" do + describe "warning about arguments" do + it "warns when passed safe_level and later arguments" do + -> { + ERB.new(@eruby_str, nil, '%') + }.should complain(/warning: Passing safe_level with the 2nd argument of ERB.new is deprecated. Do not use it, and specify other arguments as keyword arguments./) + end + + it "does not warn when passed arguments as keyword argument" do + -> { + ERB.new(@eruby_str, trim_mode: '%') + }.should_not complain(/warning: Passing safe_level with the 2nd argument of ERB.new is deprecated. Do not use it, and specify other arguments as keyword arguments./) + end + end end end diff --git a/spec/ruby/library/erb/result_spec.rb b/spec/ruby/library/erb/result_spec.rb index a29c1ccedb..84333031ec 100644 --- a/spec/ruby/library/erb/result_spec.rb +++ b/spec/ruby/library/erb/result_spec.rb @@ -43,7 +43,7 @@ END input = "<%=h '<>' %>" -> { ERB.new(input).result() - }.should raise_error(NameError) + }.should.raise(NameError) end @@ -81,6 +81,6 @@ END -> { myerb2.new.main2() - }.should raise_error(NameError) + }.should.raise(NameError) end end diff --git a/spec/ruby/library/erb/run_spec.rb b/spec/ruby/library/erb/run_spec.rb index 8c07442d8f..d81d534087 100644 --- a/spec/ruby/library/erb/run_spec.rb +++ b/spec/ruby/library/erb/run_spec.rb @@ -6,7 +6,7 @@ describe "ERB#run" do # lambda { ... }.should output def _steal_stdout orig = $stdout - s = '' + s = +'' def s.write(arg); self << arg.to_s; end $stdout = s begin @@ -54,7 +54,7 @@ END input = "<%=h '<>' %>" -> { _steal_stdout { ERB.new(input).run() } - }.should raise_error(NameError) + }.should.raise(NameError) end it "is able to h() or u() if ERB::Util is included" do @@ -91,6 +91,6 @@ END -> { _steal_stdout { myerb2.new.main2() } - }.should raise_error(NameError) + }.should.raise(NameError) end end |
