arbre 1.2.1 → 1.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (46) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +10 -0
  3. data/README.md +1 -1
  4. data/lib/arbre/context.rb +2 -1
  5. data/lib/arbre/element.rb +2 -1
  6. data/lib/arbre/version.rb +1 -1
  7. metadata +35 -46
  8. data/.gitignore +0 -10
  9. data/.rubocop.yml +0 -15
  10. data/.travis.yml +0 -16
  11. data/Gemfile +0 -25
  12. data/Gemfile.lock +0 -224
  13. data/Rakefile +0 -21
  14. data/arbre.gemspec +0 -24
  15. data/spec/arbre/integration/html_spec.rb +0 -249
  16. data/spec/arbre/unit/component_spec.rb +0 -44
  17. data/spec/arbre/unit/context_spec.rb +0 -35
  18. data/spec/arbre/unit/element_finder_methods_spec.rb +0 -116
  19. data/spec/arbre/unit/element_spec.rb +0 -271
  20. data/spec/arbre/unit/html/class_list_spec.rb +0 -16
  21. data/spec/arbre/unit/html/tag_attributes_spec.rb +0 -62
  22. data/spec/arbre/unit/html/tag_spec.rb +0 -115
  23. data/spec/arbre/unit/html/text_node_spec.rb +0 -5
  24. data/spec/changelog_spec.rb +0 -27
  25. data/spec/rails/integration/forms_spec.rb +0 -105
  26. data/spec/rails/integration/rendering_spec.rb +0 -99
  27. data/spec/rails/rails_spec_helper.rb +0 -42
  28. data/spec/rails/stub_app/config/database.yml +0 -3
  29. data/spec/rails/stub_app/config/routes.rb +0 -3
  30. data/spec/rails/stub_app/db/schema.rb +0 -3
  31. data/spec/rails/stub_app/log/.gitignore +0 -1
  32. data/spec/rails/stub_app/public/favicon.ico +0 -0
  33. data/spec/rails/support/mock_person.rb +0 -15
  34. data/spec/rails/templates/arbre/_partial.arb +0 -1
  35. data/spec/rails/templates/arbre/_partial_with_assignment.arb +0 -1
  36. data/spec/rails/templates/arbre/empty.arb +0 -0
  37. data/spec/rails/templates/arbre/page_with_arb_partial_and_assignment.arb +0 -3
  38. data/spec/rails/templates/arbre/page_with_assignment.arb +0 -1
  39. data/spec/rails/templates/arbre/page_with_erb_partial.arb +0 -3
  40. data/spec/rails/templates/arbre/page_with_partial.arb +0 -3
  41. data/spec/rails/templates/arbre/simple_page.arb +0 -8
  42. data/spec/rails/templates/erb/_partial.erb +0 -1
  43. data/spec/spec_helper.rb +0 -7
  44. data/spec/support/bundle.rb +0 -4
  45. data/tasks/lint.rake +0 -69
  46. data/tasks/release.rake +0 -6
@@ -1,5 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Arbre::HTML::TextNode do
4
-
5
- end
@@ -1,27 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe "Changelog" do
4
- subject(:changelog) do
5
- path = File.join(File.dirname(__dir__), "CHANGELOG.md")
6
- File.read(path)
7
- end
8
-
9
- it 'has definitions for all implicit links' do
10
- implicit_link_names = changelog.scan(/\[([^\]]+)\]\[\]/).flatten.uniq
11
- implicit_link_names.each do |name|
12
- expect(changelog).to include("[#{name}]: https")
13
- end
14
- end
15
-
16
- describe 'entry' do
17
- let(:lines) { changelog.each_line }
18
-
19
- subject(:entries) { lines.grep(/^\*/) }
20
-
21
- it 'does not end with a punctuation' do
22
- entries.each do |entry|
23
- expect(entry).not_to match(/\.$/)
24
- end
25
- end
26
- end
27
- end
@@ -1,105 +0,0 @@
1
- require 'rails/rails_spec_helper'
2
-
3
- describe "Building forms" do
4
-
5
- let(:assigns){ {} }
6
- let(:helpers){ mock_action_view }
7
- let(:html) { form.to_s }
8
-
9
- describe "building a simple form for" do
10
-
11
- let(:form) do
12
- arbre do
13
- form_for MockPerson.new, url: "/" do |f|
14
- f.label :name
15
- f.text_field :name
16
- end
17
- end
18
- end
19
-
20
- it "should build a form" do
21
- expect(html).to have_selector("form")
22
- end
23
-
24
- it "should include the hidden authenticity token" do
25
- expect(html).to include '<input type="hidden" name="authenticity_token" value="AUTH_TOKEN" />'
26
- end
27
-
28
- it "should create a label" do
29
- expect(html).to have_selector("form label[for=mock_person_name]")
30
- end
31
-
32
- it "should create a text field" do
33
- expect(html).to have_selector("form input[type=text]")
34
- end
35
-
36
- end
37
-
38
- describe "building a form with fields for" do
39
-
40
- let(:form) do
41
- arbre do
42
- form_for MockPerson.new, url: "/" do |f|
43
- f.label :name
44
- f.text_field :name
45
- f.fields_for :permission do |pf|
46
- pf.label :admin
47
- pf.check_box :admin
48
- end
49
- end
50
- end
51
- end
52
-
53
- it "should render nested label" do
54
- expect(html).to have_selector("form label[for=mock_person_permission_admin]", text: "Admin")
55
- end
56
-
57
- it "should render nested label" do
58
- expect(html).to have_selector("form input[type=checkbox][name='mock_person[permission][admin]']")
59
- end
60
-
61
- it "should not render a div for the proxy" do
62
- expect(html).not_to have_selector("form div.fields_for_proxy")
63
- end
64
-
65
- end
66
-
67
- describe "forms with other elements" do
68
- let(:form) do
69
- arbre do
70
- form_for MockPerson.new, url: "/" do |f|
71
-
72
- div do
73
- f.label :name
74
- f.text_field :name
75
- end
76
-
77
- para do
78
- f.label :name
79
- f.text_field :name
80
- end
81
-
82
- div class: "permissions" do
83
- f.fields_for :permission do |pf|
84
- div class: "permissions_label" do
85
- pf.label :admin
86
- end
87
- pf.check_box :admin
88
- end
89
- end
90
-
91
- end
92
- end
93
- end
94
-
95
- it "should correctly nest elements" do
96
- expect(html).to have_selector("form > p > label")
97
- end
98
-
99
- it "should correnctly nest elements within fields for" do
100
- expect(html).to have_selector("form > div.permissions > div.permissions_label label")
101
- end
102
- end
103
-
104
-
105
- end
@@ -1,99 +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
- end
34
-
35
-
36
- describe TestController, "Rendering with Arbre", type: :request do
37
- let(:body){ response.body }
38
-
39
- before do
40
- Rails.application.routes.draw do
41
- get 'test/render_empty', controller: "test"
42
- get 'test/render_simple_page', controller: "test"
43
- get 'test/render_partial', controller: "test"
44
- get 'test/render_erb_partial', controller: "test"
45
- get 'test/render_with_instance_variable', controller: "test"
46
- get 'test/render_partial_with_instance_variable', controller: "test"
47
- get 'test/render_page_with_helpers', controller: "test"
48
- end
49
- end
50
-
51
- after do
52
- Rails.application.reload_routes!
53
- end
54
-
55
- it "should render the empty template" do
56
- get "/test/render_empty"
57
- expect(response).to be_successful
58
- end
59
-
60
- it "should render a simple page" do
61
- get "/test/render_simple_page"
62
- expect(response).to be_successful
63
- expect(body).to have_selector("h1", text: "Hello World")
64
- expect(body).to have_selector("p", text: "Hello again!")
65
- end
66
-
67
- it "should render an arb partial" do
68
- get "/test/render_partial"
69
- expect(response).to be_successful
70
- expect(body).to eq <<~HTML
71
- <h1>Before Partial</h1>
72
- <p>Hello from a partial</p>
73
- <h2>After Partial</h2>
74
- HTML
75
- end
76
-
77
- it "should render an erb (or other) partial" do
78
- get "/test/render_erb_partial"
79
- expect(response).to be_successful
80
- expect(body).to eq <<~HTML
81
- <h1>Before Partial</h1>
82
- <p>Hello from an erb partial</p>
83
- <h2>After Partial</h2>
84
- HTML
85
- end
86
-
87
- it "should render with instance variables" do
88
- get "/test/render_with_instance_variable"
89
- expect(response).to be_successful
90
- expect(body).to have_selector("h1", text: "From Instance Var")
91
- end
92
-
93
- it "should render an arbre partial with assignments" do
94
- get "/test/render_partial_with_instance_variable"
95
- expect(response).to be_successful
96
- expect(body).to have_selector("p", text: "Partial: From Instance Var")
97
- end
98
-
99
- 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,3 +0,0 @@
1
- test:
2
- adapter: sqlite3
3
- database: db/combustion_test.sqlite
@@ -1,3 +0,0 @@
1
- Rails.application.routes.draw do
2
- #
3
- end
@@ -1,3 +0,0 @@
1
- # ActiveRecord::Schema.define do
2
- # #
3
- # end
@@ -1 +0,0 @@
1
- *.log
File without changes
@@ -1,15 +0,0 @@
1
- require 'active_model'
2
-
3
- class MockPerson
4
- extend ActiveModel::Naming
5
-
6
- attr_accessor :name
7
-
8
- def persisted?
9
- false
10
- end
11
-
12
- def to_key
13
- []
14
- end
15
- end
@@ -1 +0,0 @@
1
- para "Hello from a partial"
@@ -1 +0,0 @@
1
- para "Partial: #{my_instance_var}"
File without changes
@@ -1,3 +0,0 @@
1
- h1 "Before Partial"
2
- render "arbre/partial_with_assignment"
3
- h2 "After Partial"
@@ -1 +0,0 @@
1
- h1 my_instance_var
@@ -1,3 +0,0 @@
1
- h1 "Before Partial"
2
- render "erb/partial"
3
- h2 "After Partial"
@@ -1,3 +0,0 @@
1
- h1 "Before Partial"
2
- render "arbre/partial"
3
- h2 "After Partial"
@@ -1,8 +0,0 @@
1
- html do
2
- head do
3
- end
4
- body do
5
- h1 "Hello World"
6
- para "Hello again!"
7
- end
8
- end
@@ -1 +0,0 @@
1
- <p>Hello from an erb partial</p>
@@ -1,7 +0,0 @@
1
- require 'support/bundle'
2
-
3
- require 'arbre'
4
-
5
- def arbre(&block)
6
- Arbre::Context.new assigns, helpers, &block
7
- end
@@ -1,4 +0,0 @@
1
- $LOAD_PATH.unshift(File.expand_path("../../", __FILE__))
2
-
3
- require "bundler"
4
- Bundler.setup
@@ -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
@@ -1,6 +0,0 @@
1
- require "chandler/tasks"
2
-
3
- #
4
- # Add chandler as a prerequisite for `rake release`
5
- #
6
- task "release:rubygem_push" => "chandler:push"