Skip to content

Instantly share code, notes, and snippets.

//date formatting
import java.util.Date;
import java.text.SimpleDateFormat;
import java.util.TimeZone;
//http request
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.DataOutputStream;
describe "updating matching categories on project save", :focus do
let(:project) { Factory.build :project }
before(:each) do
@old_matching_categories = project.matching_categories
end
it "should update the matching categories after updating the category and saving the project" do
project.category = "C01"
def seek_and_replace(array_of_keys, new_value)
last_level = self
sought_value = nil
array_of_keys.each_with_index do |_key_, _idx_|
if last_level.is_a?(Hash) && last_level.has_key?(_key_)
if _idx_ + 1 == array_of_keys.count
last_level[_key_] = new_value
else
last_level = last_level[_key_]