cypress_rails 0.4.2 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c212de353dc00cfe2301b732d84de95c2e0df047
4
- data.tar.gz: 5c7721559a16191db9d1c7eae4667ea732af2617
3
+ metadata.gz: 3368e52934ad619056582bd906ea33b0b27a1168
4
+ data.tar.gz: bdf8ca62c0c646c3197dedd7496db37f86df8797
5
5
  SHA512:
6
- metadata.gz: 13c4cb8cf964ece2ce08f7dac3225d407bbbf0f42bf13aff3fa9bbfe58f3d6afca10ca11fdb700512ed57377d21d2e94fb7b52fca2a4ba8dedbd46e0377e9ba7
7
- data.tar.gz: c70752e25f1a41dc43b51fc27fecaf661d6fced473709a97f192519d8ec174cb53989ddf7129738af1b0a6bf2f5eecc82dc66a04c122ef154e18fdb9d593be33
6
+ metadata.gz: 347ff016801044922dfc9c6b67311b5302663911159b1d1fe70261840a54c9c1270a86b7e07fa1f7d1d1f182e3f955a3c3223159620338bd7fbd6e1958e65643
7
+ data.tar.gz: 94fc750a210c5d306e91b32cad21608123c360403b543fce286bc60907e76f8927394f11f949c81453df522c37d148ac39bc75dc379f4fa8a215c8640dfa454a
@@ -42,7 +42,15 @@ module CypressRails
42
42
 
43
43
  def execute_script!(request)
44
44
  body = JSON.parse(request.body.read)
45
- CypressRails.scripts(body.fetch("name")).call
45
+ script = CypressRails.scripts(body.fetch("name"))
46
+
47
+ params = body.fetch("params", {})
48
+
49
+ if params.any?
50
+ script.call(params)
51
+ else
52
+ script.call
53
+ end
46
54
  end
47
55
 
48
56
  def reset_db!
@@ -2,5 +2,5 @@
2
2
 
3
3
  module CypressRails
4
4
  # cypress_rails version
5
- VERSION = "0.4.2"
5
+ VERSION = "0.5.0"
6
6
  end
@@ -0,0 +1,30 @@
1
+ require "spec_helper"
2
+ require "rack"
3
+ require "json"
4
+ require "active_support/core_ext/string"
5
+ require "cypress_rails"
6
+
7
+ RSpec.describe CypressRails::Middleware do
8
+ describe "sending params to scripts" do
9
+ let(:app) {
10
+ lambda { |env| [200, env, ["OK"]] }
11
+ }
12
+ let(:middleware) { described_class.new(app) }
13
+ let(:request) { Rack::MockRequest.new(middleware) }
14
+
15
+ it "calls script with params" do
16
+ scripts = double(:scripts)
17
+
18
+ allow(scripts).to receive(:call)
19
+ allow(CypressRails).to receive(:scripts) { scripts }
20
+
21
+ data = { name: "sending_params", params: { user_id: 1, flag: false } }
22
+ request.post("/__cypress_rails__/scripts", input: data.to_json)
23
+
24
+ expect(scripts).to have_received(:call).with({
25
+ "user_id" => 1,
26
+ "flag" => false
27
+ })
28
+ end
29
+ end
30
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cypress_rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.2
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Szymon Szeliga
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-05-25 00:00:00.000000000 Z
11
+ date: 2018-06-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
@@ -206,6 +206,7 @@ files:
206
206
  - lib/cypress_rails/runner.rb
207
207
  - lib/cypress_rails/server.rb
208
208
  - lib/cypress_rails/version.rb
209
+ - spec/cypress_rails/middleware_spec.rb
209
210
  - spec/cypress_rails/runner_spec.rb
210
211
  - spec/cypress_rails/server_spec.rb
211
212
  - spec/spec_helper.rb
@@ -251,6 +252,7 @@ signing_key:
251
252
  specification_version: 4
252
253
  summary: Integrate cypress.io with your rails app
253
254
  test_files:
255
+ - spec/cypress_rails/middleware_spec.rb
254
256
  - spec/cypress_rails/runner_spec.rb
255
257
  - spec/cypress_rails/server_spec.rb
256
258
  - spec/spec_helper.rb