<commit_before>def it_acts_as_create_command(type)
  plural = "#{type}s".to_sym
  model_class = "Models::#{type.capitalize}".constantize
  serializer_class = "Serializers::#{type.capitalize}".constantize

  let(:response) { subject.class.run(params) }

  context "with valid params" do
    context "when creating a single item" do
      let(:item) { build("api_#{type}".to_sym) }
      let(:params) { { plural => [item] } }

      it "returns the newly created #{type}" do
        response.success?.should == true
        response.result.should include(plural), "The reponse should include :#{plural} array"

        response_items = response.result[plural]
        response_items.length.should == 1
        response_item = response_items.first

        model = model_class.find(response_item[:id])
        response_item.should == serializer_class.as_json(model)
      end
    end

    context "when creating multiple items" do
      let(:item1) { build("api_#{type}".to_sym) }
      let(:item2) { build("api_#{type}".to_sym) }
      let(:params) { { plural => [item1, item2] } }

      it "returns the newly created #{type}s" do
        response.success?.should == true
        response.result.should include(plural), "The reponse should include :#{plural} array"
<commit_msg>using camilize to better support identifiers with underscores<commit_after>def it_acts_as_create_command(type)
  plural = "#{type}s".to_sym

  model_class = "Models::#{type.to_s.camelize}".constantize
  serializer_class = "Serializers::#{type.to_s.camelize}".constantize

  let(:response) { subject.class.run(params) }

  context "with valid params" do
    context "when creating a single item" do
      let(:item) { build("api_#{type}".to_sym) }
      let(:params) { { plural => [item] } }

      it "returns the newly created #{type}" do
        response.success?.should == true
        response.result.should include(plural), "The reponse should include :#{plural} array"

        response_items = response.result[plural]
        response_items.length.should == 1
        response_item = response_items.first

        model = model_class.find(response_item[:id])
        response_item.should == serializer_class.as_json(model)
      end
    end

    context "when creating multiple items" do
      let(:item1) { build("api_#{type}".to_sym) }
      let(:item2) { build("api_#{type}".to_sym) }
      let(:params) { { plural => [item1, item2] } }

      it "returns the newly created #{type}s" do
        response.success?.should == true
        response.result.should include(plural), "The reponse should include :#{plural} array"

{'fraction_non_alphanumeric': 0.13415101571483326, 'fraction_numerical': 0.0038328861632809506, 'mean_word_length': 3.431239388794567, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5625104', 'n_tokens_mistral': 812, 'n_tokens_neox': 806, 'n_words': 181}