diff --git a/Rakefile b/Rakefile index 5f11412..ab776c9 100644 --- a/Rakefile +++ b/Rakefile @@ -10,4 +10,10 @@ Bundler::GemHelper.install_tasks desc "Create a test html page to demonstrate nested list use." task :nested_list_html_page do generate_html -end \ No newline at end of file +end + +require 'rake/testtask' +Rake::TestTask.new do |t| + t.libs << "test" + t.test_files = FileList['test/tc_*.rb'] +end diff --git a/lib/nested_list/nested_select.rb b/lib/nested_list/nested_select.rb index 533af6e..955c6c4 100644 --- a/lib/nested_list/nested_select.rb +++ b/lib/nested_list/nested_select.rb @@ -92,7 +92,7 @@ def remove_item(item) def find_item(tmp_name) tmp_name = tmp_name.to_s.strip @items.find do |item| - item.name == tmp_name + item.name.downcase == tmp_name.downcase end end diff --git a/test/tc_nested_list.rb b/test/tc_nested_list.rb new file mode 100644 index 0000000..dd5c87c --- /dev/null +++ b/test/tc_nested_list.rb @@ -0,0 +1,15 @@ +require 'test/unit' +require 'nested_list' + +class NestedListTest < Test::Unit::TestCase + def test_registry_insensitive + categories = [ + { id: 1679, name: "Cooking" }, + { id: 8140, name: "COOKING > BICOOKING" }, + { id: 8130, name: "COOKING > BIHOBS" } + ] + _expected_html_options = "" + nested_list = Generator::NestedList.new(categories) + assert_equal _expected_html_options, nested_list.html_options + end +end