Sha256: 2e36bb0594c7ba5b366910ac4a26837641aa4c7f699d8a724b5bea5a73abaf5a

Contents?: true

Size: 1.28 KB

Versions: 2

Compression:

Stored size: 1.28 KB

Contents

shared_examples_for 'the vertical helper' do
  all_tests_pass_with 'the vertical not wrapped in navbar'
  all_tests_pass_with 'no vertical options'
  all_tests_pass_with 'extra vertical options'
  all_tests_pass_with 'the vertical wrapped in a navbar with :id'
end

#--

shared_examples_for 'the vertical not wrapped in navbar' do
  specify 'returns nil' do
    expect(:vertical).to generate nil
  end
end

shared_examples_for 'no vertical options' do
  specify 'creates a <div> element with the "navbar-header" class and toggle button' do
    html = %r{(class="navbar-header")?(button.+(class="navbar-toggler"))}
    railsstrap.navbar { expect(:vertical).to generate %r{#{html}} }
  end
end

shared_examples_for 'extra vertical options' do
  specify 'passes the options to the <div> element' do
    options = {class: 'important', data: {value: 1}, id: 'my-navbar-header'}
    html = %r{<div class="important navbar-header" data-value="1" id="my-navbar-header">}
    railsstrap.navbar { expect(vertical: options).to generate html }
  end
end

shared_examples_for 'the vertical wrapped in a navbar with :id' do
  it 'uses the id from the navbar' do
    id = 'my-navbar'
    html = %r{(class="navbar-toggler").+(data-target="##{id}")?}
    railsstrap.navbar(id: id) { expect(:vertical).to generate html}
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
railsstrap-4.0.0.beta3 spec/shared/vertical_helper.rb
railsstrap-4.0.0.beta2 spec/shared/vertical_helper.rb