Sha256: bebc51aa8f382a02dc1a5732b2349fb75f12c3af71106793952e09baf4c4c811

Contents?: true

Size: 1.13 KB

Versions: 3

Compression:

Stored size: 1.13 KB

Contents

require 'spec_helper'

# A mock subclass to play with
class MockComponent < Arbo::Component

  builder_method :mock_component

  def build
    h2 "Hello World"
  end

end

describe Arbo::Component do

  let(:assigns) { {} }
  let(:helpers) { nil }

  let(:component_class){ MockComponent }
  let(:component){ component_class.new }

  it "should be a subclass of an html div" do
    expect(Arbo::Component.ancestors).to include(Arbo::HTML::Div)
  end

  it "should render to a div, even as a subclass" do
    expect(component.tag_name).to eq('div')
  end

  it "should add a class by default" do
    expect(component.class_list).to include("mock_component")
  end

  it "should render (to_s) the object using the builder method name" do
    comp = expect(arbo {
      mock_component
    }.to_s).to eq <<-HTML
<div class="mock_component">
  <h2>Hello World</h2>
</div>
HTML
  end

  it "should render (render_in) the object using the builder method name" do
    context = arbo { mock_component }
    output_buffer = context.render_in(context)

    expect(output_buffer).to eq <<-HTML
<div class="mock_component">
  <h2>Hello World</h2>
</div>
HTML
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
arbo-1.3.1 spec/arbo/unit/component_spec.rb
arbo-1.3.0 spec/arbo/unit/component_spec.rb
arbo-1.2.0 spec/arbo/unit/component_spec.rb