diff --git a/lib/ethon/easy/queryable.rb b/lib/ethon/easy/queryable.rb index 694583f..a1a02fa 100644 --- a/lib/ethon/easy/queryable.rb +++ b/lib/ethon/easy/queryable.rb @@ -94,7 +94,7 @@ def recursively_generate_pairs(h, prefix, pairs) end when Array h.each_with_index do |v, i| - key = "#{prefix}[#{i}]" + key = "#{prefix}[]" pairs_for(v, key, pairs) end end diff --git a/spec/ethon/easy/queryable_spec.rb b/spec/ethon/easy/queryable_spec.rb index c2afb5b..0d6cf0f 100644 --- a/spec/ethon/easy/queryable_spec.rb +++ b/spec/ethon/easy/queryable_spec.rb @@ -108,8 +108,8 @@ it "transforms" do expect(pairs).to include([:a, 1]) - expect(pairs).to include(["b[0]", 2]) - expect(pairs).to include(["b[1]", 3]) + expect(pairs).to include(["b[]", 2]) + expect(pairs).to include(["b[]", 3]) end end @@ -118,7 +118,7 @@ let(:hash) { {:a => {:b => ["hello", "world"]}} } it "transforms" do - expect(pairs).to eq([["a[b][0]", "hello"], ["a[b][1]", "world"]]) + expect(pairs).to eq([["a[b][]", "hello"], ["a[b][]", "world"]]) end end @@ -126,7 +126,7 @@ let(:hash) { {:a => {:b => [{:c =>1}, {:d => 2}]}} } it "transforms" do - expect(pairs).to eq([["a[b][0][c]", 1], ["a[b][1][d]", 2]]) + expect(pairs).to eq([["a[b][][c]", 1], ["a[b][][d]", 2]]) end end @@ -136,7 +136,7 @@ let(:hash) { {:a => {:b => [file]}} } it "transforms" do - expect(pairs).to eq([["a[b][0]", file_info]]) + expect(pairs).to eq([["a[b][]", file_info]]) end end end