Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* Create .rspec * Update .rubocop.yml * Update .travis.yml * Update hanami-helpers.gemspec * Update Rakefile * Create escape_helper_spec.rb * Create escape_helper_spec.rb * Create escape_helper_spec.rb * Delete escape_helper_spec.rb * Create fixtures.rb * Create version_spec.rb * Update escape_helper_spec.rb * Create html_helper_spec.rb * create form_helper_spec in progress * Create link_to_helper_spec.rb * Create routing_helper_spec.rb * Create number_formatting_helper_spec.rb * Update escape_helper_spec.rb * Create html_helper_spec * Create number_formatter_helper_spec * Create routing_helper_spec * Rename number_formatter_helper_spec to number_formatter_helper_spec.rb * Rename html_helper_spec to html_helper_spec.rb * Rename routing_helper_spec to routing_helper_spec.rb * Create form_helper_spec.rb * Create link_to_helper_spec.rb * Update .travis.yml * Update fixtures.rb * Create new.html.erb * Add files via upload * Create spec_helper.rb * Create html_builder_spec.rb * Update html_helper_spec.rb * Update escape_helper_spec.rb * Update form_helper_spec.rb * Update html_helper_spec.rb * Update escape_helper_spec.rb * Update version_spec.rb * Update * Update form_helper_spec.rb * Update html_helper_spec.rb * Update number_formatting_helper_spec.rb * clear trailing whitespace * Update spec_helper.rb * Update html_helper_spec.rb * Update hanami-helpers.gemspec * Update escape_helper_spec.rb * fix indentation issues * Update hanami-helpers.gemspec * Update Rakefile * Update form_helper_spec.rb * Update form_helper_spec.rb * Fix to skip errors about array and indent * Fix to clear CI issue This should fix this issue: test/fixtures.rb:58:5: W: Lint/AmbiguousBlockAssociation: Parenthesize the param html to make sure that the block will be associated with the + method call. (https://github.com/bbatsov/ruby-style-guide#syntax) html { div 'Hello' } + html { div 'Hanami' } ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ * Update form_helper_spec.rb * Update fixtures.rb * Update fixtures.rb * Update form_helper_spec.rb * Update fixtures.rb
- Loading branch information
Showing
33 changed files
with
4,184 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
--color | ||
--require spec_helper |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,25 @@ | ||
require 'rake' | ||
require 'rake/testtask' | ||
require 'bundler/gem_tasks' | ||
require 'rspec/core/rake_task' | ||
require 'rake/testtask' | ||
|
||
Rake::TestTask.new do |t| | ||
t.pattern = 'test/**/*_test.rb' | ||
t.libs.push 'test' | ||
end | ||
|
||
namespace :test do | ||
namespace :spec do | ||
RSpec::Core::RakeTask.new(:unit) do |task| | ||
file_list = FileList['spec/**/*_spec.rb'] | ||
file_list = file_list.exclude("spec/{integration,isolation}/**/*_spec.rb") | ||
|
||
task.pattern = file_list | ||
end | ||
|
||
task :coverage do | ||
ENV['COVERALL'] = 'true' | ||
Rake::Task['test'].invoke | ||
ENV['COVERAGE'] = 'true' | ||
Rake::Task['spec:unit'].invoke | ||
end | ||
end | ||
|
||
task default: :test | ||
task default: 'spec:unit' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
RSpec.describe Hanami::Helpers::EscapeHelper do | ||
before do | ||
@view = EscapeView.new | ||
end | ||
|
||
it 'has a private escape html method' do | ||
expect { @view.escape_html }.to raise_error(NoMethodError) | ||
end | ||
|
||
it 'has a private escape html attribute method' do | ||
expect { @view.escape_html_attribute }.to raise_error(NoMethodError) | ||
end | ||
|
||
it 'has a private escape url method' do | ||
expect { @view.escape_url }.to raise_error(NoMethodError) | ||
end | ||
|
||
it 'has a private raw method' do | ||
expect { @view.raw }.to raise_error(NoMethodError) | ||
end | ||
it 'autoscape evil string' do | ||
expect(@view.evil_string).to eq(%(<script>alert('xss')</script>)) | ||
end | ||
|
||
it "don't autoscape safe string" do | ||
expect(@view.good_string).to eq(%(this is a good string)) | ||
end | ||
|
||
it 'autoscape attributes evil string' do | ||
expect(@view.good_attributes_string).to eq(%(<a title='foo'>link</a>)) | ||
end | ||
|
||
it "don't autoscape attributes safe string" do | ||
expect(@view.evil_attributes_string).to eq(%(<a title='<script>alert('xss')</script>'>link</a>)) | ||
end | ||
|
||
it 'autoscape url evil string' do | ||
expect(@view.good_url_string).to eq(%(http://hanamirb.org)) | ||
end | ||
|
||
it "don't autoscape url evil string" do | ||
expect(@view.evil_url_string).to be_empty | ||
end | ||
|
||
it 'raw string is returned' do | ||
expect(@view.raw_string).to eq(%(<div>I'm a raw string</div>)) | ||
end | ||
|
||
it 'raw string is a Hanami::Helpers::Escape::SafeString class' do | ||
expect(@view.raw_string.class).to eq(Hanami::Utils::Escape::SafeString) | ||
end | ||
|
||
it 'html helper alias' do | ||
expect(@view.html_string_alias).to eq(%(this is a good string)) | ||
end | ||
|
||
it 'html attribute helper alias' do | ||
expect(@view.html_attribute_string_alias).to eq(%(<a title='foo'>link</a>)) | ||
end | ||
|
||
it 'url helper alias' do | ||
expect(@view.url_string_alias).to eq(%(http://hanamirb.org)) | ||
end | ||
end |
Oops, something went wrong.