Sha256: d33507f41c14eaeb31b46061ab33452127a6d15f9dd4bff05cd3d3db17593977

Contents?: true

Size: 1.29 KB

Versions: 2

Compression:

Stored size: 1.29 KB

Contents

shared_examples_for 'the button_to helper (Rails)' do
  all_tests_pass_with 'no button_to options (Rails)'
  all_tests_pass_with 'only extra button_to options (Rails)'
  all_tests_pass_with 'extra button_to options (Rails)'
  all_tests_pass_for 'the button_to helper'
end

#--

shared_examples_for 'no button_to options (Rails)' do
  specify 'uses the original button_to helper' do
    html = %r{^<form(?:| action="/") class="button_to" method="post"(?:| action="/")>(?:|<div>)<(input|button) type="submit"(>| value=")content(" />|</button>)(?:|</div>)</form>$}
    expect(:button_to).to generate html
  end
end

shared_examples_for 'only extra button_to options (Rails)' do
  specify 'uses the original button_to helper' do
    options = {class: 'important', data: {value: 1}, id: 'my-button_to'}
    html = %r{<(input|button) class="important" data-value="1" id="my-button_to" type="submit"}
    expect(button_to: options).to generate html
  end
end

shared_examples_for 'extra button_to options (Rails)' do
  specify 'passes the options to the button' do
    options = {variant: :default, class: 'important', data: {value: 1}, id: 'my-button_to'}
    html = %r{<(input|button) class="important btn btn-primary" data-value="1" id="my-button_to" type="submit"}
    expect(button_to: options).to generate html
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
railsstrap-4.0.0.beta3 spec/rails/button_to_helper.rb
railsstrap-4.0.0.beta2 spec/rails/button_to_helper.rb