<commit_before>require "feedcellar/curses_view"

class CursesViewTest < Test::Unit::TestCase
  def setup
    @feeds = [
      Feed.new("title", "http://example.net/rss"),
      Feed.new("title", "http://example.net/rss2"),
    ]
  end

  def test_run_quit
    mock(Curses).getch { "q" }
    assert_nothing_raised do
      Feedcellar::CursesView.run(@feeds)
    end
  end

  def test_run_down
    mock(Curses).getch { "j" }
    mock(Curses).getch { "q" }
    assert_nothing_raised do
      Feedcellar::CursesView.run(@feeds)
    end
  end

  def test_run_up
    mock(Curses).getch { "k" }
    mock(Curses).getch { "q" }
    assert_nothing_raised do
      Feedcellar::CursesView.run(@feeds)
    end
  end

  def test_run_firefox
    mock(Curses).getch { "f" }
    mock(Feedcellar::CursesView).spawn("firefox",
                       @feeds[0].link,
                       [:out, :err] => "/dev/null")
    mock(Curses).getch { "q" }
    assert_nothing_raised do
      Feedcellar::CursesView.run(@feeds)
    end
  end

  def test_run_down_and_firefox
    mock(Curses).getch { "j" }
    mock(Curses).getch { "f" }
    mock(Feedcellar::CursesView).spawn("firefox",
                       @feeds[1].link,
                       [:out, :err] => "/dev/null")
    mock(Curses).getch { "q" }
    assert_nothing_raised do
      Feedcellar::CursesView.run(@feeds)
    end
  end

  class Feed
    attr_reader :title, :link, :date
    def initialize(title, link)
      @title = title
      @link = link
      @date = Time.now
    end
  end
end<commit_msg>test: add a test for description keybind<commit_after>require "feedcellar/curses_view"

class CursesViewTest < Test::Unit::TestCase
  def setup
    @feeds = [
      Feed.new("title", "http://example.net/rss", "desc1"),
      Feed.new("title", "http://example.net/rss2", "desc2"),
    ]
  end

  def test_run_quit
    mock(Curses).getch { "q" }
    assert_nothing_raised do
      Feedcellar::CursesView.run(@feeds)
    end
  end

  def test_run_down
    mock(Curses).getch { "j" }
    mock(Curses).getch { "q" }
    assert_nothing_raised do
      Feedcellar::CursesView.run(@feeds)
    end
  end

  def test_run_up
    mock(Curses).getch { "k" }
    mock(Curses).getch { "q" }
    assert_nothing_raised do
      Feedcellar::CursesView.run(@feeds)
    end
  end

  def test_run_firefox
    mock(Curses).getch { "f" }
    mock(Feedcellar::CursesView).spawn("firefox",
                       @feeds[0].link,
                       [:out, :err] => "/dev/null")
    mock(Curses).getch { "q" }
    assert_nothing_raised do
      Feedcellar::CursesView.run(@feeds)
    end
  end

  def test_run_down_and_firefox
    mock(Curses).getch { "j" }
    mock(Curses).getch { "f" }
    mock(Feedcellar::CursesView).spawn("firefox",
                       @feeds[1].link,
                       [:out, :err] => "/dev/null")
    mock(Curses).getch { "q" }
    assert_nothing_raised do
      Feedcellar::CursesView.run(@feeds)
    end
  end

  def test_run_description
    mock(Curses).getch { "d" }
    mock(Curses).getch { "q" }
    mock(Curses).getch { "q" }
    assert_nothing_raised do
      Feedcellar::CursesView.run(@feeds)
    end
  end

  class Feed
    attr_reader :title, :link, :date, :description, :resource
    def initialize(title, link, description)
      @title = title
      @link = link
      @date = Time.now
      @description = description
      @resource = Resource.new("Web Site's Title")
    end

    class Resource
      attr_reader :title
      def initialize(title)
        @title = title
      end
    end
  end
end
{'fraction_non_alphanumeric': 0.13292204150308468, 'fraction_numerical': 0.002243409983174425, 'mean_word_length': 2.4265129682997117, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, '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': '1648807', 'n_tokens_mistral': 1368, 'n_tokens_neox': 1299, 'n_words': 231}