cypress_rails 0.4.2 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/cypress_rails/middleware.rb +9 -1
- data/lib/cypress_rails/version.rb +1 -1
- data/spec/cypress_rails/middleware_spec.rb +30 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3368e52934ad619056582bd906ea33b0b27a1168
|
4
|
+
data.tar.gz: bdf8ca62c0c646c3197dedd7496db37f86df8797
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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"))
|
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!
|
@@ -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
|
+
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-
|
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
|