arbre 1.0.1 → 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -8,44 +8,44 @@ describe Arbre::HTML::Tag do
8
8
  before { tag.build "Hello World", :id => "my_id" }
9
9
 
10
10
  it "should set the contents to a string" do
11
- tag.content.should == "Hello World"
11
+ expect(tag.content).to eq("Hello World")
12
12
  end
13
13
 
14
14
  it "should set the hash of options to the attributes" do
15
- tag.attributes.should == { :id => "my_id" }
15
+ expect(tag.attributes).to eq({ :id => "my_id" })
16
16
  end
17
17
  end
18
18
 
19
19
  describe "creating a tag 'for' an object" do
20
- let(:model_name){ mock(:singular => "resource_class")}
21
- let(:resource_class){ mock(:model_name => model_name) }
22
- let(:resource){ mock(:class => resource_class, :to_key => ['5'])}
20
+ let(:model_name){ double(:singular => "resource_class")}
21
+ let(:resource_class){ double(:model_name => model_name) }
22
+ let(:resource){ double(:class => resource_class, :to_key => ['5'])}
23
23
 
24
24
  before do
25
25
  tag.build :for => resource
26
26
  end
27
27
  it "should set the id to the type and id" do
28
- tag.id.should == "resource_class_5"
28
+ expect(tag.id).to eq("resource_class_5")
29
29
  end
30
30
 
31
31
  it "should add a class name" do
32
- tag.class_list.should include("resource_class")
32
+ expect(tag.class_list).to include("resource_class")
33
33
  end
34
34
 
35
35
 
36
36
  describe "for an object that doesn't have a model_name" do
37
- let(:resource_class){ mock(:name => 'ResourceClass') }
37
+ let(:resource_class){ double(:name => 'ResourceClass') }
38
38
 
39
39
  before do
40
40
  tag.build :for => resource
41
41
  end
42
42
 
43
43
  it "should set the id to the type and id" do
44
- tag.id.should == "resource_class_5"
44
+ expect(tag.id).to eq("resource_class_5")
45
45
  end
46
46
 
47
47
  it "should add a class name" do
48
- tag.class_list.should include("resource_class")
48
+ expect(tag.class_list).to include("resource_class")
49
49
  end
50
50
  end
51
51
 
@@ -60,7 +60,7 @@ describe Arbre::HTML::Tag do
60
60
  end
61
61
 
62
62
  it "should set the id to the type and id" do
63
- tag.id.should == "a_prefix_resource_class_5"
63
+ expect(tag.id).to eq("a_prefix_resource_class_5")
64
64
  end
65
65
 
66
66
  end
@@ -70,32 +70,32 @@ describe Arbre::HTML::Tag do
70
70
 
71
71
  it "should add a class" do
72
72
  tag.add_class "hello_world"
73
- tag.class_names.should == "hello_world"
73
+ expect(tag.class_names).to eq("hello_world")
74
74
  end
75
75
 
76
76
  it "should remove_class" do
77
77
  tag.add_class "hello_world"
78
- tag.class_names.should == "hello_world"
78
+ expect(tag.class_names).to eq("hello_world")
79
79
  tag.remove_class "hello_world"
80
- tag.class_names.should == ""
80
+ expect(tag.class_names).to eq("")
81
81
  end
82
82
 
83
83
  it "should not add a class if it already exists" do
84
84
  tag.add_class "hello_world"
85
85
  tag.add_class "hello_world"
86
- tag.class_names.should == "hello_world"
86
+ expect(tag.class_names).to eq("hello_world")
87
87
  end
88
88
 
89
89
  it "should seperate classes with space" do
90
90
  tag.add_class "hello world"
91
- tag.class_list.size.should == 2
91
+ expect(tag.class_list.size).to eq(2)
92
92
  end
93
93
 
94
94
  it "should create a class list from a string" do
95
95
  tag = Arbre::HTML::Tag.new
96
96
  tag.build(:class => "first-class")
97
97
  tag.add_class "second-class"
98
- tag.class_list.size.should == 2
98
+ expect(tag.class_list.size).to eq(2)
99
99
  end
100
100
 
101
101
  end
@@ -18,19 +18,19 @@ describe "Building forms" do
18
18
  end
19
19
 
20
20
  it "should build a form" do
21
- html.should have_selector("form")
21
+ expect(html).to have_selector("form")
22
22
  end
23
23
 
24
24
  it "should include the hidden authenticity token" do
25
- html.should have_selector("form input[type=hidden][name=authenticity_token]")
25
+ expect(html).to include '<input name="authenticity_token" type="hidden" value="AUTH_TOKEN" />'
26
26
  end
27
27
 
28
28
  it "should create a label" do
29
- html.should have_selector("form label[for=mock_person_name]")
29
+ expect(html).to have_selector("form label[for=mock_person_name]")
30
30
  end
31
31
 
32
32
  it "should create a text field" do
33
- html.should have_selector("form input[type=text]")
33
+ expect(html).to have_selector("form input[type=text]")
34
34
  end
35
35
 
36
36
  end
@@ -51,15 +51,15 @@ describe "Building forms" do
51
51
  end
52
52
 
53
53
  it "should render nested label" do
54
- html.should have_selector("form label[for=mock_person_permission_admin]", :text => "Admin")
54
+ expect(html).to have_selector("form label[for=mock_person_permission_admin]", :text => "Admin")
55
55
  end
56
56
 
57
57
  it "should render nested label" do
58
- html.should have_selector("form input[type=checkbox][name='mock_person[permission][admin]']")
58
+ expect(html).to have_selector("form input[type=checkbox][name='mock_person[permission][admin]']")
59
59
  end
60
60
 
61
61
  it "should not render a div for the proxy" do
62
- html.should_not have_selector("form div.fields_for_proxy")
62
+ expect(html).not_to have_selector("form div.fields_for_proxy")
63
63
  end
64
64
 
65
65
  end
@@ -93,11 +93,11 @@ describe "Building forms" do
93
93
  end
94
94
 
95
95
  it "should correctly nest elements" do
96
- html.should have_selector("form > p > label")
96
+ expect(html).to have_selector("form > p > label")
97
97
  end
98
98
 
99
99
  it "should correnctly nest elements within fields for" do
100
- html.should have_selector("form > div.permissions > div.permissions_label label")
100
+ expect(html).to have_selector("form > div.permissions > div.permissions_label label")
101
101
  end
102
102
  end
103
103
 
@@ -25,6 +25,11 @@ class TestController < ActionController::Base
25
25
  @my_instance_var = "From Instance Var"
26
26
  render "arbre/page_with_assignment"
27
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
28
33
  end
29
34
 
30
35
 
@@ -33,20 +38,20 @@ describe TestController, "Rendering with Arbre", :type => :request do
33
38
 
34
39
  it "should render the empty template" do
35
40
  get "/test/render_empty"
36
- response.should be_success
41
+ expect(response).to be_success
37
42
  end
38
43
 
39
44
  it "should render a simple page" do
40
45
  get "/test/render_simple_page"
41
- response.should be_success
42
- body.should have_selector("h1", :text => "Hello World")
43
- body.should have_selector("p", :text => "Hello again!")
46
+ expect(response).to be_success
47
+ expect(body).to have_selector("h1", :text => "Hello World")
48
+ expect(body).to have_selector("p", :text => "Hello again!")
44
49
  end
45
50
 
46
51
  it "should render an arb partial" do
47
52
  get "/test/render_partial"
48
- response.should be_success
49
- body.should == <<-EOS
53
+ expect(response).to be_success
54
+ expect(body).to eq <<-EOS
50
55
  <h1>Before Partial</h1>
51
56
  <p>Hello from a partial</p>
52
57
  <h2>After Partial</h2>
@@ -55,8 +60,8 @@ EOS
55
60
 
56
61
  it "should render an erb (or other) partial" do
57
62
  get "/test/render_erb_partial"
58
- response.should be_success
59
- body.should == <<-EOS
63
+ expect(response).to be_success
64
+ expect(body).to eq <<-EOS
60
65
  <h1>Before Partial</h1>
61
66
  <p>Hello from an erb partial</p>
62
67
  <h2>After Partial</h2>
@@ -65,9 +70,14 @@ EOS
65
70
 
66
71
  it "should render with instance variables" do
67
72
  get "test/render_with_instance_variable"
68
- response.should be_success
69
- body.should have_selector("h1", :text => "From Instance Var")
73
+ expect(response).to be_success
74
+ expect(body).to have_selector("h1", :text => "From Instance Var")
70
75
  end
71
76
 
77
+ it "should render an arbre partial with assignments" do
78
+ get "test/render_partial_with_instance_variable"
79
+ expect(response).to be_success
80
+ expect(body).to have_selector("p", :text => "Partial: From Instance Var")
81
+ end
72
82
 
73
83
  end
@@ -1,21 +1,14 @@
1
- require 'support/bundle'
1
+ require 'rubygems'
2
+ require 'bundler/setup'
2
3
 
3
- require 'capybara/rspec'
4
-
5
- # Combustion
6
4
  require 'combustion'
7
5
 
8
- # Arbre's Rails integration should satisfy Rack::Lint.
9
- class Combustion::Application
10
- config.middleware.use 'Rack::Lint'
11
- end
12
-
13
6
  Combustion.path = 'spec/rails/stub_app'
14
7
  Combustion.initialize! :action_controller,
15
- :action_view,
16
- :sprockets
8
+ :action_view
17
9
 
18
10
  require 'rspec/rails'
11
+ require 'capybara/rspec'
19
12
  require 'capybara/rails'
20
13
 
21
14
  require 'spec_helper'
@@ -26,7 +19,7 @@ require 'rails/support/mock_person'
26
19
  require 'arbre/rails'
27
20
 
28
21
  Rails.application.routes.draw do
29
- match 'test/:action', :controller => "test"
22
+ get 'test/:action', :controller => "test"
30
23
  end
31
24
 
32
25
  module AdditionalHelpers
@@ -0,0 +1 @@
1
+ para "Partial: #{my_instance_var}"
@@ -0,0 +1,3 @@
1
+ h1 "Before Partial"
2
+ render "arbre/partial_with_assignment"
3
+ h2 "After Partial"
metadata CHANGED
@@ -1,27 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: arbre
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
5
- prerelease:
4
+ version: 1.0.2
6
5
  platform: ruby
7
6
  authors:
8
7
  - Greg Bell
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2012-08-28 00:00:00.000000000 Z
11
+ date: 2014-08-20 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: activesupport
16
- requirement: &70297377112220 !ruby/object:Gem::Requirement
17
- none: false
15
+ requirement: !ruby/object:Gem::Requirement
18
16
  requirements:
19
- - - ! '>='
17
+ - - ">="
20
18
  - !ruby/object:Gem::Version
21
19
  version: 3.0.0
22
20
  type: :runtime
23
21
  prerelease: false
24
- version_requirements: *70297377112220
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: 3.0.0
25
27
  description: An Object Oriented DOM Tree in Ruby
26
28
  email:
27
29
  - gregdbell@gmail.com
@@ -29,11 +31,12 @@ executables: []
29
31
  extensions: []
30
32
  extra_rdoc_files: []
31
33
  files:
32
- - .gitignore
33
- - .travis.yml
34
+ - ".gitignore"
35
+ - ".travis.yml"
34
36
  - CHANGELOG.md
35
37
  - Gemfile
36
- - README.rdoc
38
+ - LICENSE
39
+ - README.md
37
40
  - Rakefile
38
41
  - arbre.gemspec
39
42
  - lib/arbre.rb
@@ -41,6 +44,7 @@ files:
41
44
  - lib/arbre/context.rb
42
45
  - lib/arbre/element.rb
43
46
  - lib/arbre/element/builder_methods.rb
47
+ - lib/arbre/element/proxy.rb
44
48
  - lib/arbre/element_collection.rb
45
49
  - lib/arbre/html/attributes.rb
46
50
  - lib/arbre/html/class_list.rb
@@ -72,7 +76,9 @@ files:
72
76
  - spec/rails/stub_app/public/favicon.ico
73
77
  - spec/rails/support/mock_person.rb
74
78
  - spec/rails/templates/arbre/_partial.arb
79
+ - spec/rails/templates/arbre/_partial_with_assignment.arb
75
80
  - spec/rails/templates/arbre/empty.arb
81
+ - spec/rails/templates/arbre/page_with_arb_partial_and_assignment.arb
76
82
  - spec/rails/templates/arbre/page_with_assignment.arb
77
83
  - spec/rails/templates/arbre/page_with_erb_partial.arb
78
84
  - spec/rails/templates/arbre/page_with_partial.arb
@@ -81,28 +87,28 @@ files:
81
87
  - spec/spec_helper.rb
82
88
  - spec/support/bundle.rb
83
89
  homepage: ''
84
- licenses: []
90
+ licenses:
91
+ - MIT
92
+ metadata: {}
85
93
  post_install_message:
86
94
  rdoc_options: []
87
95
  require_paths:
88
96
  - lib
89
97
  required_ruby_version: !ruby/object:Gem::Requirement
90
- none: false
91
98
  requirements:
92
- - - ! '>='
99
+ - - ">="
93
100
  - !ruby/object:Gem::Version
94
101
  version: '0'
95
102
  required_rubygems_version: !ruby/object:Gem::Requirement
96
- none: false
97
103
  requirements:
98
- - - ! '>='
104
+ - - ">="
99
105
  - !ruby/object:Gem::Version
100
106
  version: '0'
101
107
  requirements: []
102
108
  rubyforge_project:
103
- rubygems_version: 1.8.10
109
+ rubygems_version: 2.2.2
104
110
  signing_key:
105
- specification_version: 3
111
+ specification_version: 4
106
112
  summary: An Object Oriented DOM Tree in Ruby
107
113
  test_files:
108
114
  - spec/arbre/integration/html_spec.rb
@@ -124,7 +130,9 @@ test_files:
124
130
  - spec/rails/stub_app/public/favicon.ico
125
131
  - spec/rails/support/mock_person.rb
126
132
  - spec/rails/templates/arbre/_partial.arb
133
+ - spec/rails/templates/arbre/_partial_with_assignment.arb
127
134
  - spec/rails/templates/arbre/empty.arb
135
+ - spec/rails/templates/arbre/page_with_arb_partial_and_assignment.arb
128
136
  - spec/rails/templates/arbre/page_with_assignment.arb
129
137
  - spec/rails/templates/arbre/page_with_erb_partial.arb
130
138
  - spec/rails/templates/arbre/page_with_partial.arb
@@ -1,71 +0,0 @@
1
- = Arbre - Ruby Object Oriented HTML Views
2
-
3
- Arbre is the DOM implemented in Ruby. This project is primarily used as
4
- the object oriented view layer in Active Admin.
5
-
6
- {<img src="https://secure.travis-ci.org/gregbell/arbre.png?branch=master" alt="Build Status" />}[http://travis-ci.org/gregbell/arbre]
7
-
8
- == Simple Usage
9
-
10
- A simple example of setting up an Arbre context and creating some html
11
-
12
- html = Arbre::Context.new do
13
- h2 "Why Arbre is awesome?"
14
-
15
- ul do
16
- li "The DOM is implemented in ruby"
17
- li "You can create object oriented views"
18
- li "Templates suck"
19
- end
20
- end
21
-
22
- puts html.to_s #=> <h2>Why</h2><ul><li></li></ul>
23
-
24
-
25
- == The DOM in Ruby
26
-
27
- The purpose of Arbre is to leave the view as ruby objects as long
28
- as possible. This allows OO Design to be used to implement the view layer.
29
-
30
-
31
- html = Arbre::Context.new do
32
- h2 "Why Arbre is awesome?"
33
- end
34
-
35
- html.children.size #=> 1
36
- html.children.first #=> #<Arbre::HTML::H2>
37
-
38
- == Components
39
-
40
- The purpose of Arbre is to be able to create shareable and extendable HTML
41
- components. To do this, you create a subclass of Arbre::Component.
42
-
43
- For example:
44
-
45
- class Panel < Arbre::Component
46
- builder_method :panel
47
-
48
- def build(title, attributes = {})
49
- super(attributes)
50
-
51
- h3(title, :class => "panel-title")
52
- end
53
- end
54
-
55
- The builder_method defines the method that will be called to build this component
56
- when using the DSL. The arguments passed into the builder_method will be passed
57
- into the #build method for you.
58
-
59
- You can now use this panel in any Arbre context:
60
-
61
- html = Arbre::Context.new do
62
- panel "Hello World", :id => "my-panel" do
63
- span "Inside the panel"
64
- end
65
- end
66
-
67
- html.to_s #=>
68
- # <div class='panel' id="my-panel">
69
- # <h3 class='panel-title'>Hello World</h3>
70
- # <span>Inside the panel</span>
71
- # </div>