Sha256: eeb8e6a06bcebcf3a18eea44308342c42ce7179380162dc325d82299cdeb91a8

Contents?: true

Size: 1.26 KB

Versions: 5

Compression:

Stored size: 1.26 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"><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 = {context: :default, class: 'important', data: {value: 1}, id: 'my-button_to'}
    html = %r{<(input|button) class="important btn btn-default" data-value="1" id="my-button_to" type="submit"}
    expect(button_to: options).to generate html
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
bh-1.3.4 spec/rails/button_to_helper.rb
bh-1.3.3 spec/rails/button_to_helper.rb
bh-1.3.1 spec/rails/button_to_helper.rb
bh-1.3.0 spec/rails/button_to_helper.rb
bh-1.2.0 spec/rails/button_to_helper.rb