Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- require 'parser'
- RSpec.describe Parser do
- context "Checks if parser works correctly" do
- parser = Parser.new([
- "/contact 836.973.694.403",
- "/home 444.701.448.104",
- "/about/2 543.910.244.929",
- "/about 715.156.286.412",
- "/contact 184.123.665.067",
- "/home 444.701.448.104",
- "/contact 836.973.694.403",
- "/contact 836.973.694.403"])
- parser.open_and_parse
- it "Checks values hash size" do
- expect(parser.values.size).to eq(4)
- end
- it "Checks if enter amount for specific ip adress is correct" do
- expect(parser.values["/contact"]["836.973.694.403"]).to eq(3)
- end
- it "Checks if contact hash size is correct" do
- expect(parser.values["/contact"].size).to eq(2)
- end
- end
- end
- __________________________________________________________________________________________-
- require 'statistics_counter'
- RSpec.describe StatisticsCounter do
- context "Checks if statistics counter works correctly" do
- parser = Parser.new([
- "/contact 836.973.694.403",
- "/home 444.701.448.104",
- "/about/2 543.910.244.929",
- "/about 715.156.286.412",
- "/contact 184.123.665.067",
- "/home 444.701.448.104",
- "/contact 836.973.694.403",
- "/contact 836.973.694.403",
- "/about/2 235.313.352.950",
- "/home 555.576.836.194"])
- parser.open_and_parse
- statistics_counter = StatisticsCounter.new(parser.values)
- statistics_counter.get_results
- most_viewed_example_stats = [["/contact",4],["/home",3],["/about/2",2],["/about", 1]]
- most_unique_viewed_example_stats = [["/about/2",2],["/home",2],["/contact",2],["/about", 1]]
- it "checks if most_viewed field size is correct" do
- expect(statistics_counter.most_viewed.size).to eq(4)
- end
- it "checks if most_viewed statistics are counted correctly" do
- expect(statistics_counter.most_viewed).to eq(most_viewed_example_stats)
- end
- it "checks if most_unique_viewed field size is correct" do
- puts statistics_counter.most_unique_viewed
- expect(statistics_counter.most_unique_viewed.size).to eq(4)
- end
- it "checks if most_unique_viewed statistics are counted correctly" do
- expect(statistics_counter.most_unique_viewed).to eq(most_unique_viewed_example_stats)
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement