<commit_before>require File.join(File.dirname(File.expand_path(__FILE__)), 'spec_helper.rb')

require 'rubygems'
require 'sinatra/base'
require 'forme/sinatra'
require 'erb'

class FormeSinatraTest < Sinatra::Base
  helpers Forme::Sinatra::ERB
  disable :show_exceptions

  get '/' do
    erb <<END
<% form([:foo, :bar], :action=>'/baz') do |f| %>
  <p>FBB</p>
  <%= f.input(:first) %>
  <%= f.input(:last) %>
<% end %>
END
  end

  get '/nest' do
    erb <<END
<% form([:foo, :bar], :action=>'/baz') do |f| %>
  <p>FBB</p>
  <% f.tag(:div) do %>
    <%= f.input(:first) %>
    <%= f.input(:last) %>
  <% end %>
<% end %>
END
  end
end

describe "Forme Sinatra ERB integration" do
  specify "#form should add start and end tags and yield Forme::Form instance" do
    FormeSinatraTest.new.call({'rack.input'=>'', 'REQUEST_METHOD'=>'GET', 'PATH_INFO'=>'/'})[2].join.gsub(/\s+/, ' ').should == '<form action="/baz"> <p>FBB</p> <input id="first" name="first" type="text" value="foo"/> <input id="last" name="last" type="text" value="bar"/> </form>'
  end

  specify "#form should add start and end tags and yield Forme::Form instance" do
    FormeSinatraTest.new.call({'rack.input'=>'', 'REQUEST_METHOD'=>'GET', 'PATH_INFO'=>'/nest'})[2].join.gsub(/\s+/, ' ').should == '<form action="/baz"> <p>FBB</p> <div> <input id="first" name="first" type="text" value="foo"/> <input id="last" name="last" type="text" value="bar"/> </div> </form>'
  end
end<commit_msg>Add a strip in the sinatra spec for greater compatibility with different sinatra versions<commit_after>require File.join(File.dirname(File.expand_path(__FILE__)), 'spec_helper.rb')

require 'rubygems'
require 'sinatra/base'
require 'forme/sinatra'
require 'erb'

class FormeSinatraTest < Sinatra::Base
  helpers Forme::Sinatra::ERB
  disable :show_exceptions

  get '/' do
    erb <<END
<% form([:foo, :bar], :action=>'/baz') do |f| %>
  <p>FBB</p>
  <%= f.input(:first) %>
  <%= f.input(:last) %>
<% end %>
END
  end

  get '/nest' do
    erb <<END
<% form([:foo, :bar], :action=>'/baz') do |f| %>
  <p>FBB</p>
  <% f.tag(:div) do %>
    <%= f.input(:first) %>
    <%= f.input(:last) %>
  <% end %>
<% end %>
END
  end
end

describe "Forme Sinatra ERB integration" do
  specify "#form should add start and end tags and yield Forme::Form instance" do
    FormeSinatraTest.new.call({'rack.input'=>'', 'REQUEST_METHOD'=>'GET', 'PATH_INFO'=>'/'})[2].join.gsub(/\s+/, ' ').strip.should == '<form action="/baz"> <p>FBB</p> <input id="first" name="first" type="text" value="foo"/> <input id="last" name="last" type="text" value="bar"/> </form>'
  end

  specify "#form should add start and end tags and yield Forme::Form instance" do
    FormeSinatraTest.new.call({'rack.input'=>'', 'REQUEST_METHOD'=>'GET', 'PATH_INFO'=>'/nest'})[2].join.gsub(/\s+/, ' ').strip.should == '<form action="/baz"> <p>FBB</p> <div> <input id="first" name="first" type="text" value="foo"/> <input id="last" name="last" type="text" value="bar"/> </div> </form>'
  end
end
{'fraction_non_alphanumeric': 0.23230974632843793, 'fraction_numerical': 0.0013351134846461949, 'mean_word_length': 4.570631970260223, 'pattern_counts': {'":': 0, '<': 69, '<?xml version=': 0, '>': 75, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6688588', 'n_tokens_mistral': 1170, 'n_tokens_neox': 1107, 'n_words': 264}