Advertisement
Guest User

Untitled

a guest
Nov 11th, 2019
184
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.59 KB | None | 0 0
  1. require 'parser'
  2.  
  3. RSpec.describe Parser do
  4. context "Checks if parser works correctly" do
  5. parser = Parser.new([
  6. "/contact 836.973.694.403",
  7. "/home 444.701.448.104",
  8. "/about/2 543.910.244.929",
  9. "/about 715.156.286.412",
  10. "/contact 184.123.665.067",
  11. "/home 444.701.448.104",
  12. "/contact 836.973.694.403",
  13. "/contact 836.973.694.403"])
  14. parser.open_and_parse
  15.  
  16. it "Checks values hash size" do
  17. expect(parser.values.size).to eq(4)
  18. end
  19.  
  20. it "Checks if enter amount for specific ip adress is correct" do
  21. expect(parser.values["/contact"]["836.973.694.403"]).to eq(3)
  22. end
  23.  
  24. it "Checks if contact hash size is correct" do
  25. expect(parser.values["/contact"].size).to eq(2)
  26. end
  27. end
  28. end
  29. __________________________________________________________________________________________-
  30.  
  31. require 'statistics_counter'
  32.  
  33. RSpec.describe StatisticsCounter do
  34. context "Checks if statistics counter works correctly" do
  35. parser = Parser.new([
  36. "/contact 836.973.694.403",
  37. "/home 444.701.448.104",
  38. "/about/2 543.910.244.929",
  39. "/about 715.156.286.412",
  40. "/contact 184.123.665.067",
  41. "/home 444.701.448.104",
  42. "/contact 836.973.694.403",
  43. "/contact 836.973.694.403",
  44. "/about/2 235.313.352.950",
  45. "/home 555.576.836.194"])
  46. parser.open_and_parse
  47.  
  48.  
  49. statistics_counter = StatisticsCounter.new(parser.values)
  50. statistics_counter.get_results
  51.  
  52. most_viewed_example_stats = [["/contact",4],["/home",3],["/about/2",2],["/about", 1]]
  53. most_unique_viewed_example_stats = [["/about/2",2],["/home",2],["/contact",2],["/about", 1]]
  54.  
  55. it "checks if most_viewed field size is correct" do
  56. expect(statistics_counter.most_viewed.size).to eq(4)
  57. end
  58.  
  59. it "checks if most_viewed statistics are counted correctly" do
  60. expect(statistics_counter.most_viewed).to eq(most_viewed_example_stats)
  61. end
  62.  
  63. it "checks if most_unique_viewed field size is correct" do
  64. puts statistics_counter.most_unique_viewed
  65. expect(statistics_counter.most_unique_viewed.size).to eq(4)
  66. end
  67.  
  68. it "checks if most_unique_viewed statistics are counted correctly" do
  69. expect(statistics_counter.most_unique_viewed).to eq(most_unique_viewed_example_stats)
  70. end
  71. end
  72. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement