arbre 1.2.0 → 1.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +35 -0
- data/README.md +4 -4
- data/docs/Gemfile +1 -0
- data/lib/arbre/component.rb +1 -0
- data/lib/arbre/context.rb +3 -1
- data/lib/arbre/element/builder_methods.rb +1 -0
- data/lib/arbre/element/proxy.rb +1 -0
- data/lib/arbre/element.rb +4 -11
- data/lib/arbre/element_collection.rb +1 -0
- data/lib/arbre/html/attributes.rb +1 -0
- data/lib/arbre/html/class_list.rb +1 -0
- data/lib/arbre/html/document.rb +1 -0
- data/lib/arbre/html/html5_elements.rb +1 -0
- data/lib/arbre/html/tag.rb +7 -6
- data/lib/arbre/html/text_node.rb +1 -0
- data/lib/arbre/rails/forms.rb +2 -1
- data/lib/arbre/rails/rendering.rb +1 -0
- data/lib/arbre/rails/template_handler.rb +0 -17
- data/lib/arbre/rails.rb +1 -0
- data/lib/arbre/version.rb +2 -1
- data/lib/arbre.rb +1 -0
- metadata +38 -50
- data/.gitignore +0 -10
- data/.rubocop.yml +0 -15
- data/.travis.yml +0 -16
- data/Gemfile +0 -25
- data/Gemfile.lock +0 -224
- data/Rakefile +0 -21
- data/arbre.gemspec +0 -24
- data/spec/arbre/integration/html_spec.rb +0 -249
- data/spec/arbre/unit/component_spec.rb +0 -44
- data/spec/arbre/unit/context_spec.rb +0 -35
- data/spec/arbre/unit/element_finder_methods_spec.rb +0 -116
- data/spec/arbre/unit/element_spec.rb +0 -271
- data/spec/arbre/unit/html/class_list_spec.rb +0 -16
- data/spec/arbre/unit/html/tag_attributes_spec.rb +0 -62
- data/spec/arbre/unit/html/tag_spec.rb +0 -115
- data/spec/arbre/unit/html/text_node_spec.rb +0 -5
- data/spec/changelog_spec.rb +0 -27
- data/spec/rails/integration/forms_spec.rb +0 -105
- data/spec/rails/integration/rendering_spec.rb +0 -114
- data/spec/rails/rails_spec_helper.rb +0 -42
- data/spec/rails/stub_app/config/database.yml +0 -3
- data/spec/rails/stub_app/config/routes.rb +0 -3
- data/spec/rails/stub_app/db/schema.rb +0 -3
- data/spec/rails/stub_app/log/.gitignore +0 -1
- data/spec/rails/stub_app/public/favicon.ico +0 -0
- data/spec/rails/support/mock_person.rb +0 -15
- data/spec/rails/templates/arbre/_partial.arb +0 -1
- data/spec/rails/templates/arbre/_partial_with_assignment.arb +0 -1
- data/spec/rails/templates/arbre/empty.arb +0 -0
- data/spec/rails/templates/arbre/page_with_arb_partial_and_assignment.arb +0 -3
- data/spec/rails/templates/arbre/page_with_assignment.arb +0 -1
- data/spec/rails/templates/arbre/page_with_erb_partial.arb +0 -3
- data/spec/rails/templates/arbre/page_with_helpers.arb +0 -7
- data/spec/rails/templates/arbre/page_with_partial.arb +0 -3
- data/spec/rails/templates/arbre/simple_page.arb +0 -8
- data/spec/rails/templates/erb/_partial.erb +0 -1
- data/spec/spec_helper.rb +0 -7
- data/spec/support/bundle.rb +0 -4
- data/tasks/lint.rake +0 -69
- data/tasks/release.rake +0 -6
@@ -1,114 +0,0 @@
|
|
1
|
-
require 'rails/rails_spec_helper'
|
2
|
-
|
3
|
-
ARBRE_VIEWS_PATH = File.expand_path("../../templates", __FILE__)
|
4
|
-
|
5
|
-
class TestController < ActionController::Base
|
6
|
-
append_view_path ARBRE_VIEWS_PATH
|
7
|
-
|
8
|
-
def render_empty
|
9
|
-
render "arbre/empty"
|
10
|
-
end
|
11
|
-
|
12
|
-
def render_simple_page
|
13
|
-
render "arbre/simple_page"
|
14
|
-
end
|
15
|
-
|
16
|
-
def render_partial
|
17
|
-
render "arbre/page_with_partial"
|
18
|
-
end
|
19
|
-
|
20
|
-
def render_erb_partial
|
21
|
-
render "arbre/page_with_erb_partial"
|
22
|
-
end
|
23
|
-
|
24
|
-
def render_with_instance_variable
|
25
|
-
@my_instance_var = "From Instance Var"
|
26
|
-
render "arbre/page_with_assignment"
|
27
|
-
end
|
28
|
-
|
29
|
-
def render_partial_with_instance_variable
|
30
|
-
@my_instance_var = "From Instance Var"
|
31
|
-
render "arbre/page_with_arb_partial_and_assignment"
|
32
|
-
end
|
33
|
-
|
34
|
-
def render_page_with_helpers
|
35
|
-
render "arbre/page_with_helpers"
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
|
40
|
-
describe TestController, "Rendering with Arbre", type: :request do
|
41
|
-
let(:body){ response.body }
|
42
|
-
|
43
|
-
before do
|
44
|
-
Rails.application.routes.draw do
|
45
|
-
get 'test/render_empty', controller: "test"
|
46
|
-
get 'test/render_simple_page', controller: "test"
|
47
|
-
get 'test/render_partial', controller: "test"
|
48
|
-
get 'test/render_erb_partial', controller: "test"
|
49
|
-
get 'test/render_with_instance_variable', controller: "test"
|
50
|
-
get 'test/render_partial_with_instance_variable', controller: "test"
|
51
|
-
get 'test/render_page_with_helpers', controller: "test"
|
52
|
-
end
|
53
|
-
end
|
54
|
-
|
55
|
-
after do
|
56
|
-
Rails.application.reload_routes!
|
57
|
-
end
|
58
|
-
|
59
|
-
it "should render the empty template" do
|
60
|
-
get "/test/render_empty"
|
61
|
-
expect(response).to be_successful
|
62
|
-
end
|
63
|
-
|
64
|
-
it "should render a simple page" do
|
65
|
-
get "/test/render_simple_page"
|
66
|
-
expect(response).to be_successful
|
67
|
-
expect(body).to have_selector("h1", text: "Hello World")
|
68
|
-
expect(body).to have_selector("p", text: "Hello again!")
|
69
|
-
end
|
70
|
-
|
71
|
-
it "should render an arb partial" do
|
72
|
-
get "/test/render_partial"
|
73
|
-
expect(response).to be_successful
|
74
|
-
expect(body).to eq <<~HTML
|
75
|
-
<h1>Before Partial</h1>
|
76
|
-
<p>Hello from a partial</p>
|
77
|
-
<h2>After Partial</h2>
|
78
|
-
HTML
|
79
|
-
end
|
80
|
-
|
81
|
-
it "should render an erb (or other) partial" do
|
82
|
-
get "/test/render_erb_partial"
|
83
|
-
expect(response).to be_successful
|
84
|
-
expect(body).to eq <<~HTML
|
85
|
-
<h1>Before Partial</h1>
|
86
|
-
<p>Hello from an erb partial</p>
|
87
|
-
<h2>After Partial</h2>
|
88
|
-
HTML
|
89
|
-
end
|
90
|
-
|
91
|
-
it "should render with instance variables" do
|
92
|
-
get "/test/render_with_instance_variable"
|
93
|
-
expect(response).to be_successful
|
94
|
-
expect(body).to have_selector("h1", text: "From Instance Var")
|
95
|
-
end
|
96
|
-
|
97
|
-
it "should render an arbre partial with assignments" do
|
98
|
-
get "/test/render_partial_with_instance_variable"
|
99
|
-
expect(response).to be_successful
|
100
|
-
expect(body).to have_selector("p", text: "Partial: From Instance Var")
|
101
|
-
end
|
102
|
-
|
103
|
-
it "should render a page with helpers" do
|
104
|
-
get "/test/render_page_with_helpers"
|
105
|
-
expect(response).to be_successful
|
106
|
-
expect(body).to eq <<~HTML
|
107
|
-
<span>before h1 link</span>
|
108
|
-
<h1><a href="/h1_link_path">h1 link text</a></h1>
|
109
|
-
<span>before link_to block</span>
|
110
|
-
<a href="/link_path"> <i class=\"link-class\">Link text</i>
|
111
|
-
</a><span>at end</span>
|
112
|
-
HTML
|
113
|
-
end
|
114
|
-
end
|
@@ -1,42 +0,0 @@
|
|
1
|
-
require 'rubygems'
|
2
|
-
require 'bundler/setup'
|
3
|
-
|
4
|
-
require 'combustion'
|
5
|
-
|
6
|
-
Combustion.path = 'spec/rails/stub_app'
|
7
|
-
Combustion.initialize! :action_controller,
|
8
|
-
:action_view
|
9
|
-
|
10
|
-
require 'rspec/rails'
|
11
|
-
require 'capybara/rspec'
|
12
|
-
require 'capybara/rails'
|
13
|
-
|
14
|
-
require 'spec_helper'
|
15
|
-
|
16
|
-
require 'rails/support/mock_person'
|
17
|
-
|
18
|
-
# Ensure that the rails plugin is installed
|
19
|
-
require 'arbre/rails'
|
20
|
-
|
21
|
-
module AdditionalHelpers
|
22
|
-
|
23
|
-
def protect_against_forgery?
|
24
|
-
true
|
25
|
-
end
|
26
|
-
|
27
|
-
def form_authenticity_token(form_options: {})
|
28
|
-
"AUTH_TOKEN"
|
29
|
-
end
|
30
|
-
|
31
|
-
end
|
32
|
-
|
33
|
-
def mock_action_view(assigns = {})
|
34
|
-
controller = ActionView::TestCase::TestController.new
|
35
|
-
ActionView::Base.send :include, ActionView::Helpers
|
36
|
-
ActionView::Base.send :include, AdditionalHelpers
|
37
|
-
ActionView::Base.new(ActionController::Base.view_paths, assigns, controller)
|
38
|
-
end
|
39
|
-
|
40
|
-
RSpec.configure do |config|
|
41
|
-
config.include Capybara::RSpecMatchers
|
42
|
-
end
|
@@ -1 +0,0 @@
|
|
1
|
-
*.log
|
File without changes
|
@@ -1 +0,0 @@
|
|
1
|
-
para "Hello from a partial"
|
@@ -1 +0,0 @@
|
|
1
|
-
para "Partial: #{my_instance_var}"
|
File without changes
|
@@ -1 +0,0 @@
|
|
1
|
-
h1 my_instance_var
|
@@ -1 +0,0 @@
|
|
1
|
-
<p>Hello from an erb partial</p>
|
data/spec/spec_helper.rb
DELETED
data/spec/support/bundle.rb
DELETED
data/tasks/lint.rake
DELETED
@@ -1,69 +0,0 @@
|
|
1
|
-
require "open3"
|
2
|
-
|
3
|
-
#
|
4
|
-
# Common stuff for a linter
|
5
|
-
#
|
6
|
-
module LinterMixin
|
7
|
-
def run
|
8
|
-
offenses = []
|
9
|
-
|
10
|
-
applicable_files.each do |file|
|
11
|
-
if clean?(file)
|
12
|
-
print "."
|
13
|
-
else
|
14
|
-
offenses << file
|
15
|
-
print "F"
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
print "\n"
|
20
|
-
|
21
|
-
return if offenses.empty?
|
22
|
-
|
23
|
-
raise failure_message_for(offenses)
|
24
|
-
end
|
25
|
-
|
26
|
-
private
|
27
|
-
|
28
|
-
def applicable_files
|
29
|
-
Open3.capture2("git grep -Il ''")[0].split
|
30
|
-
end
|
31
|
-
|
32
|
-
def failure_message_for(offenses)
|
33
|
-
msg = "#{self.class.name} detected offenses. "
|
34
|
-
|
35
|
-
msg += if respond_to?(:fixing_cmd)
|
36
|
-
"Run `#{fixing_cmd(offenses)}` to fix them."
|
37
|
-
else
|
38
|
-
"Affected files: #{offenses.join(' ')}"
|
39
|
-
end
|
40
|
-
|
41
|
-
msg
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
#
|
46
|
-
# Checks trailing new lines in files
|
47
|
-
#
|
48
|
-
class MissingTrailingCarriageReturn
|
49
|
-
include LinterMixin
|
50
|
-
|
51
|
-
def clean?(file)
|
52
|
-
File.read(file) =~ /\n\Z/m
|
53
|
-
end
|
54
|
-
end
|
55
|
-
|
56
|
-
require 'rubocop/rake_task'
|
57
|
-
RuboCop::RakeTask.new
|
58
|
-
|
59
|
-
desc "Lints ActiveAdmin code base"
|
60
|
-
task lint: ["rubocop", "lint:missing_trailing_carriage_return"]
|
61
|
-
|
62
|
-
namespace :lint do
|
63
|
-
desc "Check for missing trailing new lines"
|
64
|
-
task :missing_trailing_carriage_return do
|
65
|
-
puts "Checking for missing trailing carriage returns..."
|
66
|
-
|
67
|
-
MissingTrailingCarriageReturn.new.run
|
68
|
-
end
|
69
|
-
end
|