Permalink
Browse files

Merge pull request #3 from ratnikov/master

Fixed the issue with rails integration for fixnums
  • Loading branch information...
2 parents 45b9a46 + 366b11d commit 78771d88c66286d8adaa15ac348437b1b9cda7bf @igrigorik committed Mar 29, 2012
Showing with 37 additions and 2 deletions.
  1. +3 −0 contextual.gemspec
  2. +1 −1 lib/contextual/contextual.rb
  3. +3 −1 lib/contextual/rails_erubis.rb
  4. +9 −0 spec/contextual_spec.rb
  5. +21 −0 spec/rails_handler_spec.rb
View
@@ -16,6 +16,9 @@ Gem::Specification.new do |s|
s.add_development_dependency "rspec"
+ # Only required to test rails integration
+ s.add_development_dependency 'rails'
+
s.files = `git ls-files`.split("\n")
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
@@ -52,7 +52,7 @@ def initialize
end
def writeSafe(code)
- @buf.writeSafe(code)
+ @buf.writeSafe(code.to_s)
end
alias :writeSafe= :writeSafe
alias :append= :writeSafe
@@ -1,3 +1,5 @@
+require 'action_view'
+
module ActionView
class Template
module Handlers
@@ -91,4 +93,4 @@ def add_postamble(src)
end
end
-end
+end
View
@@ -67,4 +67,13 @@
res.should == exp
end
+ it "should render fixnums" do
+ template = Erubis::ContextualEruby.new <<-TEMPLATE
+ Number: <%= 42 %>
+ TEMPLATE
+
+ result = template.result(binding)
+
+ result.should =~ /Number: 42/
+ end
end
View
@@ -0,0 +1,21 @@
+require 'rails'
+
+require 'contextual'
+
+describe Contextual do
+ it 'should allow fixnums' do
+ template = ActionView::Template::Handlers::SafeErubis.new <<-TEMPLATE
+ Number: <%= 42 %>
+ TEMPLATE
+
+ result = template.result(binding)
+
+ result.should =~ /Number:\s*42/
+ end
+
+ private
+
+ def output_buffer
+ ::Erubis::ContextualBuffer.new
+ end
+end

0 comments on commit 78771d8

Please sign in to comment.