Sha256: 7f0582f9b041d7dd4f06e60f2c86043651aceca7d2cacdcc2e4c66b9ffc6d07b

Contents?: true

Size: 819 Bytes

Versions: 8

Compression:

Stored size: 819 Bytes

Contents

require "spec_helper"
require "rack"
require "json"
require "active_support/core_ext/string"
require "cypress_rails"

RSpec.describe CypressRails::Middleware do
  describe "sending params to scripts" do
    let(:app) {
      lambda { |env| [200, env, ["OK"]] }
    }
    let(:middleware) { described_class.new(app) }
    let(:request) { Rack::MockRequest.new(middleware) }

    it "calls script with params" do
      scripts = double(:scripts)

      allow(scripts).to receive(:call)
      allow(CypressRails).to receive(:scripts) { scripts }

      data = { name: "sending_params", params: { user_id: 1, flag: false } }
      request.post("/__cypress_rails__/scripts", input: data.to_json)

      expect(scripts).to have_received(:call).with({
        "user_id" => 1,
        "flag" => false
      })
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
cypress_rails-0.9.3 spec/cypress_rails/middleware_spec.rb
cypress_rails-0.9.2 spec/cypress_rails/middleware_spec.rb
cypress_rails-0.9.1 spec/cypress_rails/middleware_spec.rb
cypress_rails-0.9.0 spec/cypress_rails/middleware_spec.rb
cypress_rails-0.8.0 spec/cypress_rails/middleware_spec.rb
cypress_rails-0.7.0 spec/cypress_rails/middleware_spec.rb
cypress_rails-0.6.0 spec/cypress_rails/middleware_spec.rb
cypress_rails-0.5.0 spec/cypress_rails/middleware_spec.rb