<commit_before>require 'test_helper'

class PicturesControllerTest < ActionController::TestCase

  test "routing /" do
    assert_routing '/', :controller => 'pictures', :action => 'index'
  end

  test "routing /pictures/some_tag" do
    assert_routing '/pictures/some_tag', :controller => "pictures",
      :action => "index", :tag => "some_tag"
  end

  test "should raise exception on bad route /pictures" do
    begin
      assert_routing '/pictures', :controller => "pictures", :action => "index"
      flunk "should have failed"
    rescue ActionController::RoutingError # Expected.
    end
  end

  test "should render right webmaster page file" do
# Could not get this test to work.
#    get :index
#print "assigns(:pictures) "; p assigns(:pictures)
#    assert_template :file => "#{Rails.root}/../gallery-webmaster/page"
#,
#        :partial => 'pictures/pictures',
#        :locals => {:pictures => assigns(:pictures)}
#        :locals => nil
  end

  test "should get index" do
    get_mock_page
    assert_response :success
  end

  test "should render a mock page" do
    get_mock_page
  end

  test "should render a gallery" do
    get_mock_page
    see_output
    assert_select 'div.gallery'
  end

  test "should render a list of all tags" do
    get_mock_page
    assert_select 'div.all-tags'
  end

  test "should render a picture within a gallery" do
    get_mock_page
    assert_select 'div.gallery > div.picture'
  end

  test "should render all the pictures" do
    get_mock_page
    assert_select 'div.gallery > div.picture', 2
  end

  test "should render a title within a picture" do
    get_mock_page
    assert_select 'div.picture > div.title'
  end

  test "should render a description within a picture" do
    get_mock_page
    assert_select 'div.picture > div.description'
  end

  test "should render a year within a picture" do
    get_mock_page
    assert_select 'div.picture > div.year'
  end

  test "should render a thumbnail within a picture" do
    get_mock_page
    assert_select 'div.picture > div.thumbnail'
  end

  test "should render an image within a thumbnail" do 
    get_mock_page
    assert_select 'div.thumbnail > img'
  end

  test "image should have the right thumbnail filename" do
    pictures(:one).destroy
    get_mock_page
    assert_select '[src=?]', '/images/two-t.png'
  end

  private

  def get_mock_page
    Webmaster.expects(:page_path).returns "#{Rails.root}"\
      '/test/fixtures/files/picture/page'
    get :index
  end

  def see_output
    print response.body
  end

end
<commit_msg>Print html response to file.<commit_after>require 'test_helper'

class PicturesControllerTest < ActionController::TestCase

  test "routing /" do
    assert_routing '/', :controller => 'pictures', :action => 'index'
  end

  test "routing /pictures/some_tag" do
    assert_routing '/pictures/some_tag', :controller => "pictures",
      :action => "index", :tag => "some_tag"
  end

  test "should raise exception on bad route /pictures" do
    begin
      assert_routing '/pictures', :controller => "pictures", :action => "index"
      flunk "should have failed"
    rescue ActionController::RoutingError # Expected.
    end
  end

  test "should render right webmaster page file" do
# Could not get this test to work.
#    get :index
#print "assigns(:pictures) "; p assigns(:pictures)
#    assert_template :file => "#{Rails.root}/../gallery-webmaster/page"
#,
#        :partial => 'pictures/pictures',
#        :locals => {:pictures => assigns(:pictures)}
#        :locals => nil
  end

  test "should get index" do
    get_mock_page
    assert_response :success
  end

  test "should render a mock page" do
    get_mock_page
  end

  test "should render a gallery" do
    get_mock_page
    see_output
    assert_select 'div.gallery'
  end

  test "should render a list of all tags" do
    get_mock_page
    assert_select 'div.all-tags'
  end

  test "should render a picture within a gallery" do
    get_mock_page
    assert_select 'div.gallery > div.picture'
  end

  test "should render all the pictures" do
    get_mock_page
    assert_select 'div.gallery > div.picture', 2
  end

  test "should render a title within a picture" do
    get_mock_page
    assert_select 'div.picture > div.title'
  end

  test "should render a description within a picture" do
    get_mock_page
    assert_select 'div.picture > div.description'
  end

  test "should render a year within a picture" do
    get_mock_page
    assert_select 'div.picture > div.year'
  end

  test "should render a thumbnail within a picture" do
    get_mock_page
    assert_select 'div.picture > div.thumbnail'
  end

  test "should render an image within a thumbnail" do 
    get_mock_page
    assert_select 'div.thumbnail > img'
  end

  test "image should have the right thumbnail filename" do
    pictures(:one).destroy
    get_mock_page
    assert_select '[src=?]', '/images/two-t.png'
  end

  private

  def get_mock_page
    Webmaster.expects(:page_path).returns "#{Rails.root}"\
      '/test/fixtures/files/picture/page'
    get :index
  end

  def see_output
    f=File.new("#{Rails.root}"\
      '/out/see-output','w')
    f.print response.body
    f.close
  end

end

{'fraction_non_alphanumeric': 0.09615384615384616, 'fraction_numerical': 0.0003846153846153846, 'mean_word_length': 3.144223107569721, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 41, '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': '2756266', 'n_tokens_mistral': 1700, 'n_tokens_neox': 1635, 'n_words': 513}