Sha256: d4f91edf543a0e624237650b678a67ea320684afa7027ee5dcb26522e04b7125

Contents?: true

Size: 856 Bytes

Versions: 3

Compression:

Stored size: 856 Bytes

Contents

module DerailSpecs
  class Server
    App = Rack::Builder.new do
      map "/reset-transaction" do
        run lambda { |_env|
          Transaction.reset
          [202, { "Content-Type" => "text/plain" }, ["Accepted"]]
        }
      end
      map "/factory-bot/create" do
        run lambda { |env|
          body = Rack::Request.new(env).body.gets
          object = FactoryBot.create(*JSON.parse(body))

          [202, { "Content-Type" => "application/json" }, [object.to_json]]
        }
      end
      map "/factory-bot/create-list" do
        run lambda { |env|
          body = Rack::Request.new(env).body.gets
          object = FactoryBot.create_list(*JSON.parse(body))

          [202, { "Content-Type" => "application/json" }, [object.to_json]]
        }
      end
      map "/" do
        run Rails.application
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
derail_specs-0.7.0 lib/derail_specs/server/app.rb
derail_specs-0.6.1 lib/derail_specs/server/app.rb
derail_specs-0.6.0 lib/derail_specs/server/app.rb