Permalink
Browse files

Drop micronaut, add rvm and bundler, move to rspec

  • Loading branch information...
1 parent ca13fa7 commit a703bb4e62358f75daf94981120c22558e2c0a12 @abedra committed Dec 30, 2012
Showing with 68 additions and 84 deletions.
  1. +1 −0 .rspec
  2. +1 −0 .rvmrc
  3. +4 −0 Gemfile
  4. +38 −0 Gemfile.lock
  5. +3 −42 Rakefile
  6. +0 −16 examples/example_helper.rb
  7. +20 −26 examples/safe_erb_example.rb → spec/safe_erb_spec.rb
  8. +1 −0 spec/spec_helper.rb
View
1 .rspec
@@ -0,0 +1 @@
+--colour
View
1 .rvmrc
@@ -0,0 +1 @@
+rvm use ruby-1.9.3@safe_erb --create
View
@@ -0,0 +1,4 @@
+source :rubygems
+
+gem 'rails', '~>2.3'
+gem 'rspec', '~>2.12'
View
@@ -0,0 +1,38 @@
+GEM
+ remote: http://rubygems.org/
+ specs:
+ actionmailer (2.3.14)
+ actionpack (= 2.3.14)
+ actionpack (2.3.14)
+ activesupport (= 2.3.14)
+ rack (~> 1.1.0)
+ activerecord (2.3.14)
+ activesupport (= 2.3.14)
+ activeresource (2.3.14)
+ activesupport (= 2.3.14)
+ activesupport (2.3.14)
+ diff-lcs (1.1.3)
+ rack (1.1.3)
+ rails (2.3.14)
+ actionmailer (= 2.3.14)
+ actionpack (= 2.3.14)
+ activerecord (= 2.3.14)
+ activeresource (= 2.3.14)
+ activesupport (= 2.3.14)
+ rake (>= 0.8.3)
+ rake (10.0.3)
+ rspec (2.12.0)
+ rspec-core (~> 2.12.0)
+ rspec-expectations (~> 2.12.0)
+ rspec-mocks (~> 2.12.0)
+ rspec-core (2.12.2)
+ rspec-expectations (2.12.1)
+ diff-lcs (~> 1.1.3)
+ rspec-mocks (2.12.1)
+
+PLATFORMS
+ ruby
+
+DEPENDENCIES
+ rails (~> 2.3)
+ rspec (~> 2.12)
View
@@ -1,45 +1,6 @@
require 'rake'
-require 'rake/testtask'
-require 'rake/rdoctask'
-gem "spicycode-micronaut", ">= 0.2.10"
-require 'micronaut'
-require 'micronaut/rake_task'
+require 'rspec/core/rake_task'
-desc "Run all micronaut examples"
-Micronaut::RakeTask.new :examples do |t|
- t.pattern = "examples/**/*_example.rb"
-end
+RSpec::Core::RakeTask.new(:spec)
-namespace :examples do
- desc "Run all micronaut examples using rcov"
- Micronaut::RakeTask.new :coverage do |t|
- t.pattern = "examples/**/*_example.rb"
- t.rcov = true
- t.rcov_opts = %[--exclude "gems/*,/Library/Ruby/*,config/*" --text-summary --sort coverage]
- end
-
- RAILS_VERSIONS = %w[2.0.2 2.1.0 2.1.1 2.2.2 2.3.1 2.3.2]
-
- desc "Run exmaples with multiple versions of rails"
- task :multi_rails do
- RAILS_VERSIONS.each do |rails_version|
- puts
- sh "RAILS_VERSION='#{rails_version}' rake examples"
- end
- end
-end
-
-if ENV["RUN_CODE_RUN"]
- task :default => "examples:multi_rails"
-else
- task :default => "examples:coverage"
-end
-
-desc 'Generate documentation for the safe_erb plugin.'
-Rake::RDocTask.new(:rdoc) do |rdoc|
- rdoc.rdoc_dir = 'rdoc'
- rdoc.title = 'SafeERB'
- rdoc.options << '--line-numbers' << '--inline-source'
- rdoc.rdoc_files.include('README.rdoc')
- rdoc.rdoc_files.include('lib/**/*.rb')
-end
+task :default => :spec
View
@@ -1,16 +0,0 @@
-require File.expand_path(File.join(File.dirname(__FILE__), "../" "lib", "safe_erb.rb"))
-
-gem "spicycode-micronaut", ">= 0.2.4"
-require 'micronaut'
-
-def not_in_editor?
- ['TM_MODE', 'EMACS', 'VIM'].all? { |k| !ENV.has_key?(k) }
-end
-
-Micronaut.configure do |c|
- c.alias_example_to :fit, :focused => true
- c.alias_example_to :xit, :disabled => true
- c.mock_with :mocha
- c.color_enabled = not_in_editor?
- c.filter_run :focused => true
-end
@@ -1,27 +1,13 @@
-require File.expand_path(File.join(File.dirname(__FILE__), "example_helper.rb"))
+require 'spec_helper'
describe "Safe ERB" do
-
- describe "ERB" do
-
- describe "Util" do
- it "html_escape renders an untainted string" do
- src = "<script>alert('hi');</script>"
- out = ERB::Util.html_escape(src)
- out.should == "&lt;script&gt;alert('hi');&lt;/script&gt;"
- out.should_not be_tainted
- end
- end
-
- end
-
- describe "ActionView::Helpers::SanitizeHelper" do
- pending "strip_tags_with_untaint renders an untainted string" do
+ describe "ERB::Util" do
+ it "html_escape renders an untainted string" do
src = "<script>alert('hi');</script>"
- out = ActionView::Helpers::SanitizeHelper.strip_tags_with_untaint(src)
+ out = ERB::Util.html_escape(src)
out.should == "&lt;script&gt;alert('hi');&lt;/script&gt;"
- out.should_not be_tainted
- end
+ out.should_not be_tainted
+ end
end
describe "render_with_checking_tainted" do
@@ -31,23 +17,31 @@
lambda { eval(src) }.should raise_error(RuntimeError)
end
end
-
+
it "test checking non tainted" do
ERB.with_checking_tainted do
src = ERB.new("<%= 'This string is not tainted' %>", nil, '-').src
lambda { eval(src) }.should_not raise_error
end
end
end
-
+
+ describe "ActionView::Helpers::SanitizeHelper" do
+ pending "strip_tags_with_untaint renders an untainted string" do
+ src = "<script>alert('hi');</script>"
+ out = ActionView::Helpers::SanitizeHelper.strip_tags_with_untaint(src)
+ out.should == "&lt;script&gt;alert('hi');&lt;/script&gt;"
+ out.should_not be_tainted
+ end
+ end
+
describe "Tag Helper Tests" do
include ActionView::Helpers::TagHelper
-
+
it "test taghelper untaints" do
evil_str = "evil knievel".taint
escape_once(evil_str).should_not be_tainted
escape_once_without_untaint(evil_str).should be_tainted
end
- end
-
-end
+ end
+end
View
@@ -0,0 +1 @@
+require File.expand_path(File.join(File.dirname(__FILE__), "../" "lib", "safe_erb.rb"))

0 comments on commit a703bb4

Please sign in to comment.