Sha256: ecbd19b6299600f7e041d71d06b877880ad195e9177faf277aa2e40e1b5f92d4

Contents?: true

Size: 1.62 KB

Versions: 3

Compression:

Stored size: 1.62 KB

Contents

require "spec_helper"

describe "Recipes" do
  let(:params) do
    {
      name: "name",
      type: 1,
      flag: true,
      config: {},
      tags: [],
    }
  end

  describe "POST /recipes" do
    context "without required param" do
      before do
        params.delete(:name)
      end

      it "returns 400" do
        post "/recipes", params
        response.status.should == 400
      end
    end

    context "with wrong integer param" do
      before do
        params[:type] = "x"
      end

      it "returns 400" do
        post "/recipes", params
        response.status.should == 400
      end
    end

    context "with wrong boolean param" do
      before do
        params[:flag] = "x"
      end

      it "returns 400" do
        post "/recipes", params
        response.status.should == 400
      end
    end

    context "with wrong array param" do
      before do
        params[:tags] = "x"
      end

      it "returns 400" do
        post "/recipes", params
        response.status.should == 400
      end
    end

    context "with wrong hash param" do
      before do
        params[:config] = "x"
      end

      it "returns 400" do
        post "/recipes", params
        response.status.should == 400
      end
    end

    context "without non-required param" do
      before do
        params.delete(:type)
      end

      it "creates a new recipe" do
        post "/recipes", params
        response.status.should == 201
      end
    end

    context "with valid condition", :autodoc do
      it "creates a new recipe" do
        post "/recipes", params
        response.status.should == 201
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
weak_parameters-0.0.4 spec/requests/recipes_spec.rb
weak_parameters-0.0.3 spec/requests/recipes_spec.rb
weak_parameters-0.0.2 spec/requests/recipes_spec.rb