Dictionary show action for letters, alphabetical links helper

This commit is contained in:
maddiebaka
2023-10-20 14:29:34 -04:00
parent 6202a6e778
commit c5cbffb4e5
9 changed files with 93 additions and 1 deletions

View File

@@ -0,0 +1,36 @@
require 'rails_helper'
include Capybara::RSpecMatchers
# Specs in this file have access to a helper object that includes
# the DictionaryHelper. For example:
#
# describe DictionaryHelper do
# describe "string concat" do
# it "concats two strings with spaces" do
# expect(helper.concat_strings("this","that")).to eq("this that")
# end
# end
# end
RSpec.describe DictionaryHelper, type: :helper do
describe "#alphabetical_links" do
it "generates fourteen letter-links" do
expect(helper.alphabetical_links).to have_selector(%(a), count: 14)
end
it "generates links for all fourteen letters" do
output = helper.alphabetical_links
letters = ['i', 'u', 'e', 'o', 'a', 'm', 'n', 'p', 't', 'k', 's', 'w', 'l', 'j']
letters.each do |l|
expect(output).to have_link(l, href: dictionary_path(l))
end
end
it "sorts the toki pona alphabet" do
expect(DictionaryHelper::LETTERS).to eql(DictionaryHelper::LETTERS.sort)
end
end
end