Navigation Menu

Skip to content

Commit

Permalink
Retire webrat and nokogiri from helper tests (#2076)
Browse files Browse the repository at this point in the history
* optimize travis build time, remove jruby-9.0.5.0

* retire Webrat and Nokogiri from tests, use Oga

* fix jruby 1.7.19
  • Loading branch information
ujifgc committed Oct 30, 2016
1 parent 0ada17a commit bba1cfb
Show file tree
Hide file tree
Showing 13 changed files with 1,383 additions and 1,363 deletions.
8 changes: 3 additions & 5 deletions .travis.yml
Expand Up @@ -6,15 +6,15 @@ before_install:
install:
- bundle update
rvm:
- rbx-2
- jruby
- jruby-head
- 1.9.3
- 2.0.0
- 2.1
- 2.2.2
- 2.3.1
- rbx-2
- jruby-9.1.4.0
- ruby-head
- jruby-head
notifications:
irc: 'irc.freenode.org#padrino'
recipients:
Expand All @@ -40,8 +40,6 @@ matrix:
env: STDLIB_ERB=true
- rvm: 2.1
env: AS_VERSION=3.2
- rvm: jruby
env: AS_VERSION=4.2
allow_failures:
- rvm: jruby-9.1.4.0
- rvm: rbx-2
Expand Down
4 changes: 2 additions & 2 deletions Gemfile
Expand Up @@ -6,7 +6,7 @@ if ENV["AS_VERSION"]
gem 'activesupport', "~> #{ENV['AS_VERSION']}"
else
if RUBY_VERSION < "2.2.2"
gem 'activesupport', "< 5.0.0", :platform => :mri, :group => :development
gem 'activesupport', "< 5.0.0", :group => :development
end
end

Expand All @@ -31,7 +31,7 @@ group :development do
gem "yard", ">= 0.7.2"
gem "rack-test", "~> 0.6.3"
gem "fakeweb", ">= 1.2.8"
gem "webrat", ">= 0.5.1"
gem "oga", "~> 2.5"
gem "haml", ">= 4.0.5"
gem "liquid", ">= 2.1.2"
if ENV['STDLIB_ERB']
Expand Down
2 changes: 1 addition & 1 deletion padrino-admin/test/fixtures/sequel.rb
@@ -1,5 +1,6 @@
require 'digest/sha1'
require 'sequel'
require 'sequel/extensions/migration'

Sequel::Model.plugin(:schema)

Expand All @@ -12,7 +13,6 @@
Sequel.sqlite(":memory:")
end

Sequel.extension :migration
migration = Sequel.migration do
up do
create_table :accounts do
Expand Down
17 changes: 2 additions & 15 deletions padrino-helpers/test/helper.rb
Expand Up @@ -4,7 +4,6 @@
require 'minitest/pride'
require 'mocha/setup'
require 'rack/test'
require 'webrat'
require 'builder'
require 'padrino-helpers'
require 'padrino/rendering'
Expand All @@ -13,18 +12,14 @@

require 'ext/minitest-spec'
require 'ext/rack-test-methods'
require 'padrino/test-methods'

class MiniTest::Spec
include Padrino::Helpers::OutputHelpers
include Padrino::Helpers::TagHelpers
include Padrino::Helpers::AssetTagHelpers
include Rack::Test::Methods
include Webrat::Methods
include Webrat::Matchers

Webrat.configure do |config|
config.mode = :rack
end
include Padrino::TestMethods

def stop_time_for_test
time = Time.now
Expand Down Expand Up @@ -80,11 +75,3 @@ def app
Rack::Lint.new(@app)
end
end

module Webrat
module Logging
def logger # @private
@logger = nil
end
end
end
187 changes: 91 additions & 96 deletions padrino-helpers/test/test_asset_tag_helpers.rb

Large diffs are not rendered by default.

1,009 changes: 506 additions & 503 deletions padrino-helpers/test/test_form_builder.rb

Large diffs are not rendered by default.

1,032 changes: 516 additions & 516 deletions padrino-helpers/test/test_form_helpers.rb

Large diffs are not rendered by default.

144 changes: 72 additions & 72 deletions padrino-helpers/test/test_output_helpers.rb
Expand Up @@ -8,150 +8,150 @@ def app

describe 'for #content_for method' do
it 'should work for erb templates' do
visit '/erb/content_for'
assert_have_selector '.demo h1', :content => "This is content yielded from a content_for", :count => 1
assert_have_selector '.demo2 h1', :content => "This is content yielded with name Johnny Smith", :count => 1
assert_have_no_selector '.demo3 p', :content => "One", :class => "duplication"
assert_have_selector '.demo3 p', :content => "Two", :class => "duplication"
get "/erb/content_for"
assert_response_has_tag '.demo h1', :content => "This is content yielded from a content_for", :count => 1
assert_response_has_tag '.demo2 h1', :content => "This is content yielded with name Johnny Smith", :count => 1
assert_response_has_no_tag '.demo3 p', :content => "One", :class => "duplication"
assert_response_has_tag '.demo3 p', :content => "Two", :class => "duplication"
end

it 'should work for haml templates' do
visit '/haml/content_for'
assert_have_selector '.demo h1', :content => "This is content yielded from a content_for", :count => 1
assert_have_selector '.demo2 h1', :content => "This is content yielded with name Johnny Smith", :count => 1
assert_have_no_selector '.demo3 p', :content => "One", :class => "duplication"
assert_have_selector '.demo3 p', :content => "Two", :class => "duplication"
get "/haml/content_for"
assert_response_has_tag '.demo h1', :content => "This is content yielded from a content_for", :count => 1
assert_response_has_tag '.demo2 h1', :content => "This is content yielded with name Johnny Smith", :count => 1
assert_response_has_no_tag '.demo3 p', :content => "One", :class => "duplication"
assert_response_has_tag '.demo3 p', :content => "Two", :class => "duplication"
end

it 'should work for slim templates' do
visit '/slim/content_for'
assert_have_selector '.demo h1', :content => "This is content yielded from a content_for", :count => 1
assert_have_selector '.demo2 h1', :content => "This is content yielded with name Johnny Smith", :count => 1
assert_have_no_selector '.demo3 p', :content => "One", :class => "duplication"
assert_have_selector '.demo3 p', :content => "Two", :class => "duplication"
get "/slim/content_for"
assert_response_has_tag '.demo h1', :content => "This is content yielded from a content_for", :count => 1
assert_response_has_tag '.demo2 h1', :content => "This is content yielded with name Johnny Smith", :count => 1
assert_response_has_no_tag '.demo3 p', :content => "One", :class => "duplication"
assert_response_has_tag '.demo3 p', :content => "Two", :class => "duplication"
end
end # content_for

describe "for #content_for? method" do
it 'should work for erb templates' do
visit '/erb/content_for'
assert_have_selector '.demo_has_content', :content => "true"
assert_have_selector '.fake_has_content', :content => "false"
get "/erb/content_for"
assert_response_has_tag '.demo_has_content', :content => "true"
assert_response_has_tag '.fake_has_content', :content => "false"
end

it 'should work for haml templates' do
visit '/haml/content_for'
assert_have_selector '.demo_has_content', :content => "true"
assert_have_selector '.fake_has_content', :content => "false"
get "/haml/content_for"
assert_response_has_tag '.demo_has_content', :content => "true"
assert_response_has_tag '.fake_has_content', :content => "false"
end

it 'should work for slim templates' do
visit '/slim/content_for'
assert_have_selector '.demo_has_content', :content => "true"
assert_have_selector '.fake_has_content', :content => "false"
get "/slim/content_for"
assert_response_has_tag '.demo_has_content', :content => "true"
assert_response_has_tag '.fake_has_content', :content => "false"
end
end # content_for?

describe 'for #capture_html method' do
it 'should work for erb templates' do
visit '/erb/capture_concat'
assert_have_selector 'p span', :content => "Captured Line 1", :count => 1
assert_have_selector 'p span', :content => "Captured Line 2", :count => 1
get "/erb/capture_concat"
assert_response_has_tag 'p span', :content => "Captured Line 1", :count => 1
assert_response_has_tag 'p span', :content => "Captured Line 2", :count => 1
end

it 'should work for haml templates' do
visit '/haml/capture_concat'
assert_have_selector 'p span', :content => "Captured Line 1", :count => 1
assert_have_selector 'p span', :content => "Captured Line 2", :count => 1
get "/haml/capture_concat"
assert_response_has_tag 'p span', :content => "Captured Line 1", :count => 1
assert_response_has_tag 'p span', :content => "Captured Line 2", :count => 1
end

it 'should work for slim templates' do
visit '/slim/capture_concat'
assert_have_selector 'p span', :content => "Captured Line 1", :count => 1
assert_have_selector 'p span', :content => "Captured Line 2", :count => 1
get "/slim/capture_concat"
assert_response_has_tag 'p span', :content => "Captured Line 1", :count => 1
assert_response_has_tag 'p span', :content => "Captured Line 2", :count => 1
end
end

describe 'for #concat_content method' do
it 'should work for erb templates' do
visit '/erb/capture_concat'
assert_have_selector 'p', :content => "Concat Line 3", :count => 1
get "/erb/capture_concat"
assert_response_has_tag 'p', :content => "Concat Line 3", :count => 1
end

it 'should work for haml templates' do
visit '/haml/capture_concat'
assert_have_selector 'p', :content => "Concat Line 3", :count => 1
get "/haml/capture_concat"
assert_response_has_tag 'p', :content => "Concat Line 3", :count => 1
end

it 'should work for slim templates' do
visit '/slim/capture_concat'
assert_have_selector 'p', :content => "Concat Line 3", :count => 1
get "/slim/capture_concat"
assert_response_has_tag 'p', :content => "Concat Line 3", :count => 1
end
end

describe 'for #block_is_template?' do
it 'should work for erb templates' do
visit '/erb/capture_concat'
assert_have_selector 'p', :content => "The erb block passed in is a template", :class => 'is_template', :count => 1
assert_have_no_selector 'p', :content => "The ruby block passed in is a template", :class => 'is_template', :count => 1
get "/erb/capture_concat"
assert_response_has_tag 'p', :content => "The erb block passed in is a template", :class => 'is_template', :count => 1
assert_response_has_no_tag 'p', :content => "The ruby block passed in is a template", :class => 'is_template', :count => 1
end

it 'should work for haml templates' do
visit '/haml/capture_concat'
assert_have_selector 'p', :content => "The haml block passed in is a template", :class => 'is_template', :count => 1
assert_have_no_selector 'p', :content => "The ruby block passed in is a template", :class => 'is_template', :count => 1
get "/haml/capture_concat"
assert_response_has_tag 'p', :content => "The haml block passed in is a template", :class => 'is_template', :count => 1
assert_response_has_no_tag 'p', :content => "The ruby block passed in is a template", :class => 'is_template', :count => 1
end

it 'should work for slim templates' do
visit '/slim/capture_concat'
assert_have_selector 'p', :content => "The slim block passed in is a template", :class => 'is_template', :count => 1
assert_have_no_selector 'p', :content => "The ruby block passed in is a template", :class => 'is_template', :count => 1
get "/slim/capture_concat"
assert_response_has_tag 'p', :content => "The slim block passed in is a template", :class => 'is_template', :count => 1
assert_response_has_no_tag 'p', :content => "The ruby block passed in is a template", :class => 'is_template', :count => 1
end
end

describe 'for #current_engine method' do
it 'should detect correctly current engine for erb' do
visit '/erb/current_engine'
assert_have_selector 'p.start', :content => "erb"
assert_have_selector 'p.haml', :content => "haml"
assert_have_selector 'p.erb', :content => "erb"
assert_have_selector 'p.slim', :content => "slim"
assert_have_selector 'p.end', :content => "erb"
get "/erb/current_engine"
assert_response_has_tag 'p.start', :content => "erb"
assert_response_has_tag 'p.haml', :content => "haml"
assert_response_has_tag 'p.erb', :content => "erb"
assert_response_has_tag 'p.slim', :content => "slim"
assert_response_has_tag 'p.end', :content => "erb"
end

it 'should detect correctly current engine for haml' do
visit '/haml/current_engine'
assert_have_selector 'p.start', :content => "haml"
assert_have_selector 'p.haml', :content => "haml"
assert_have_selector 'p.erb', :content => "erb"
assert_have_selector 'p.slim', :content => "slim"
assert_have_selector 'p.end', :content => "haml"
get "/haml/current_engine"
assert_response_has_tag 'p.start', :content => "haml"
assert_response_has_tag 'p.haml', :content => "haml"
assert_response_has_tag 'p.erb', :content => "erb"
assert_response_has_tag 'p.slim', :content => "slim"
assert_response_has_tag 'p.end', :content => "haml"
end

it 'should detect correctly current engine for slim' do
visit '/slim/current_engine'
assert_have_selector 'p.start', :content => "slim"
assert_have_selector 'p.haml', :content => "haml"
assert_have_selector 'p.erb', :content => "erb"
assert_have_selector 'p.slim', :content => "slim"
assert_have_selector 'p.end', :content => "slim"
get "/slim/current_engine"
assert_response_has_tag 'p.start', :content => "slim"
assert_response_has_tag 'p.haml', :content => "haml"
assert_response_has_tag 'p.erb', :content => "erb"
assert_response_has_tag 'p.slim', :content => "slim"
assert_response_has_tag 'p.end', :content => "slim"
end
end

describe 'for #partial method in simple sinatra application' do
it 'should properly output in erb' do
visit '/erb/simple_partial'
assert_have_selector 'p.erb', :content => "erb"
get "/erb/simple_partial"
assert_response_has_tag 'p.erb', :content => "erb"
end

it 'should properly output in haml' do
visit '/haml/simple_partial'
assert_have_selector 'p.haml', :content => "haml"
get "/haml/simple_partial"
assert_response_has_tag 'p.haml', :content => "haml"
end

it 'should properly output in slim' do
visit '/slim/simple_partial'
assert_have_selector 'p.slim', :content => "slim"
get "/slim/simple_partial"
assert_response_has_tag 'p.slim', :content => "slim"
end
end
end

0 comments on commit bba1cfb

Please sign in to comment.