cypress-on-rails 1.4.2 → 1.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/.gitignore +1 -0
- data/.travis.yml +2 -2
- data/CHANGELOG.md +14 -4
- data/README.md +9 -1
- data/lib/cypress_on_rails/middleware.rb +10 -2
- data/lib/cypress_on_rails/version.rb +1 -1
- data/lib/generators/cypress_on_rails/templates/spec/cypress/app_commands/activerecord_fixtures.rb +1 -0
- data/lib/generators/cypress_on_rails/templates/spec/cypress/app_commands/factory_bot.rb +1 -1
- data/lib/generators/cypress_on_rails/templates/spec/cypress/integration/rails_examples/advance_factory_bot_spec.js +27 -0
- data/lib/generators/cypress_on_rails/templates/spec/cypress/integration/rails_examples/{using_factory_bot.js → using_factory_bot_spec.js} +0 -0
- data/lib/generators/cypress_on_rails/templates/spec/cypress/integration/rails_examples/{using_fixtures.js → using_fixtures_spec.js} +0 -0
- data/lib/generators/cypress_on_rails/templates/spec/cypress/support/on-rails.js +10 -6
- data/lib/generators/cypress_on_rails/update_generator.rb +13 -0
- data/spec/cypress_on_rails/middleware_spec.rb +30 -7
- data/spec/integrations/rails_3_2/test.sh +1 -0
- data/spec/integrations/rails_4_2/test.sh +1 -1
- data/spec/integrations/rails_5_2/.gitignore +2 -2
- metadata +7 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 423d83b19153f88f90b88295c62934aeb0a20e79cd1e4d700e9a01990972c400
|
4
|
+
data.tar.gz: a5c6a528c074c22ce50206c8120290d9bf12d576348cd033342f593c3efd2d38
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 309a6837d21c5cd1814a3b84f9903edcc9d4ddb035f4f0dd8e435640ce16b96e21d51f52b7715d3b88f3f87956143bb53db9434cd151b1c53ba5505316f46cf4
|
7
|
+
data.tar.gz: ec631f2f6a4a48240d1314911076888557da7f24e62ea7b9e0ad50be33f2367fd5581fe09699790a0cd55aa9dbc44d911252284d48e3aee595e5c4765790c91c
|
data/.gitignore
CHANGED
data/.travis.yml
CHANGED
@@ -25,6 +25,6 @@ before_install:
|
|
25
25
|
|
26
26
|
script:
|
27
27
|
- bundle exec rake
|
28
|
-
- ./spec/integrations/rails_3_2/test.sh
|
29
|
-
- ./spec/integrations/rails_4_2/test.sh
|
30
28
|
- ./spec/integrations/rails_5_2/test.sh
|
29
|
+
- ./spec/integrations/rails_4_2/test.sh
|
30
|
+
- ./spec/integrations/rails_3_2/test.sh
|
data/CHANGELOG.md
CHANGED
@@ -1,9 +1,21 @@
|
|
1
|
+
## [1.5.0]
|
2
|
+
[Compare]: https://github.com/shakacode/cypress-on-rails/compare/v1.4.2...v1.5.0
|
3
|
+
|
4
|
+
### Added
|
5
|
+
* Serialize and return responses to be used in tests [PR 34](https://github.com/shakacode/cypress-on-rails/pull/34).
|
6
|
+
* Update generator to make it easier to update core generated files [PR 35](https://github.com/shakacode/cypress-on-rails/pull/35).
|
7
|
+
|
8
|
+
### Tasks
|
9
|
+
* Update integration tests [PR 36](https://github.com/shakacode/cypress-on-rails/pull/36).
|
10
|
+
|
1
11
|
## [1.4.2]
|
12
|
+
[Compare]: https://github.com/shakacode/cypress-on-rails/compare/v1.4.1...v1.4.2
|
2
13
|
|
3
14
|
### Fixed
|
4
15
|
* update generator to use full paths for Factory files [PR 33](https://github.com/shakacode/cypress-on-rails/pull/33).
|
5
16
|
|
6
17
|
## [1.4.1]
|
18
|
+
[Compare]: https://github.com/shakacode/cypress-on-rails/compare/v1.4.0...v1.4.1
|
7
19
|
|
8
20
|
### Fixed
|
9
21
|
* fix install generator when using npm [PR 22](https://github.com/shakacode/cypress-on-rails/pull/22) by [josephan](https://github.com/josephan).
|
@@ -15,6 +27,8 @@
|
|
15
27
|
* Fix CI by Installing cypress dependencies on Travis CI [PR 31](https://github.com/shakacode/cypress-on-rails/pull/31)
|
16
28
|
|
17
29
|
## [1.4.0]
|
30
|
+
[Compare]: https://github.com/shakacode/cypress-on-rails/compare/v1.3.0...v1.4.0
|
31
|
+
|
18
32
|
* Accept an options argument for scenarios. [PR 18](https://github.com/shakacode/cypress-on-rails/pull/18) by [ericraio](https://github.com/ericraio).
|
19
33
|
|
20
34
|
### Changed
|
@@ -78,10 +92,6 @@
|
|
78
92
|
## 0.1.2 (2017-10-31)
|
79
93
|
* First release.
|
80
94
|
|
81
|
-
[Unreleased]: https://github.com/shakacode/cypress-on-rails/compare/v1.4.2...master
|
82
|
-
[1.4.2]: https://github.com/shakacode/cypress-on-rails/compare/v1.4.1...v1.4.2
|
83
|
-
[1.4.1]: https://github.com/shakacode/cypress-on-rails/compare/v1.4.0...v1.4.1
|
84
|
-
[1.4.0]: https://github.com/shakacode/cypress-on-rails/compare/v1.3.0...v1.4.0
|
85
95
|
[1.3.0]: https://github.com/shakacode/cypress-on-rails/compare/v1.2.1...v1.3.0
|
86
96
|
[1.2.1]: https://github.com/shakacode/cypress-on-rails/compare/v1.2.0...v1.2.1
|
87
97
|
[1.2.0]: https://github.com/shakacode/cypress-on-rails/compare/v1.1.1...v1.2.0
|
data/README.md
CHANGED
@@ -31,7 +31,7 @@ group :test, :development do
|
|
31
31
|
end
|
32
32
|
```
|
33
33
|
|
34
|
-
|
34
|
+
Generate the boilerplate code using:
|
35
35
|
```
|
36
36
|
bin/rails g cypress_on_rails:install
|
37
37
|
|
@@ -40,6 +40,9 @@ bin/rails g cypress_on_rails:install --cypress_folder=test/cypress
|
|
40
40
|
|
41
41
|
# if you want to install cypress with npm
|
42
42
|
bin/rails g cypress_on_rails:install --install_cypress_with=npm
|
43
|
+
|
44
|
+
# to update the generated files run
|
45
|
+
bin/rails g cypress_on_rails:update
|
43
46
|
```
|
44
47
|
|
45
48
|
The generator adds the following files/directory to your application:
|
@@ -99,6 +102,11 @@ describe('My First Test', function() {
|
|
99
102
|
cy.visit('/')
|
100
103
|
|
101
104
|
cy.contains("Hello World")
|
105
|
+
|
106
|
+
// Accessing result
|
107
|
+
cy.appFactories([['create', 'invoice', { paid: false }]]).then((records) => {
|
108
|
+
cy.visit(`/invoices/${records[0].id}`);
|
109
|
+
});
|
102
110
|
})
|
103
111
|
})
|
104
112
|
```
|
@@ -54,9 +54,17 @@ module CypressOnRails
|
|
54
54
|
logger.info "handle_command: #{body}"
|
55
55
|
commands = Command.from_body(body, configuration)
|
56
56
|
missing_command = commands.find {|command| !@file.exists?(command.file_path) }
|
57
|
+
|
57
58
|
if missing_command.nil?
|
58
|
-
commands.
|
59
|
-
|
59
|
+
results = commands.map { |command| @command_executor.load(command.file_path, command.options) }
|
60
|
+
|
61
|
+
begin
|
62
|
+
output = results.to_json
|
63
|
+
rescue NoMethodError
|
64
|
+
output = {"message" => "Cannot convert to json"}.to_json
|
65
|
+
end
|
66
|
+
|
67
|
+
[201, {'Content-Type' => 'application/json'}, [output]]
|
60
68
|
else
|
61
69
|
[404, {}, ["could not find command file: #{missing_command.file_path}"]]
|
62
70
|
end
|
data/lib/generators/cypress_on_rails/templates/spec/cypress/app_commands/activerecord_fixtures.rb
CHANGED
@@ -12,6 +12,7 @@ if defined?(ActiveRecord)
|
|
12
12
|
logger.debug "loading fixtures: { dir: #{fixtures_dir}, files: #{fixture_files} }"
|
13
13
|
ActiveRecord::FixtureSet.reset_cache
|
14
14
|
ActiveRecord::FixtureSet.create_fixtures(fixtures_dir, fixture_files)
|
15
|
+
"Fixtures Done" # this gets returned
|
15
16
|
else # this else part can be removed
|
16
17
|
logger.error "Looks like activerecord_fixtures has to be modified to suite your need"
|
17
18
|
Post.create(title: 'MyCypressFixtures')
|
@@ -0,0 +1,27 @@
|
|
1
|
+
describe('More Rails using factory bot examples', function() {
|
2
|
+
beforeEach(() => {
|
3
|
+
cy.app('clean') // have a look at cypress/app_commands/clean.rb
|
4
|
+
})
|
5
|
+
|
6
|
+
it('using response from factory bot', function() {
|
7
|
+
cy.appFactories([['create', 'post', { title: 'Good bye Mars'} ]]).then((results) => {
|
8
|
+
const record = results[0];
|
9
|
+
|
10
|
+
cy.visit(`/posts/${record.id}`);
|
11
|
+
});
|
12
|
+
cy.contains("Good bye Mars")
|
13
|
+
})
|
14
|
+
|
15
|
+
it('using response from multiple factory bot', function() {
|
16
|
+
cy.appFactories([
|
17
|
+
['create', 'post', { title: 'My First Post'} ],
|
18
|
+
['create', 'post', { title: 'My Second Post'} ]
|
19
|
+
]).then((results) => {
|
20
|
+
cy.visit(`/posts/${results[0].id}`);
|
21
|
+
cy.contains("My First Post")
|
22
|
+
|
23
|
+
cy.visit(`/posts/${results[1].id}`);
|
24
|
+
cy.contains("My Second Post")
|
25
|
+
});
|
26
|
+
})
|
27
|
+
})
|
File without changes
|
File without changes
|
@@ -1,29 +1,33 @@
|
|
1
1
|
// CypressOnRails: dont remove these command
|
2
2
|
Cypress.Commands.add('appCommands', function (body) {
|
3
3
|
cy.log("APP: " + JSON.stringify(body))
|
4
|
-
cy.request({
|
4
|
+
return cy.request({
|
5
5
|
method: 'POST',
|
6
6
|
url: "/__cypress__/command",
|
7
7
|
body: JSON.stringify(body),
|
8
8
|
log: true,
|
9
9
|
failOnStatusCode: true
|
10
|
-
})
|
10
|
+
}).then((response) => {
|
11
|
+
return response.body
|
12
|
+
});
|
11
13
|
});
|
12
14
|
|
13
15
|
Cypress.Commands.add('app', function (name, command_options) {
|
14
|
-
cy.appCommands({name: name, options: command_options})
|
16
|
+
return cy.appCommands({name: name, options: command_options}).then((body) => {
|
17
|
+
return body[0]
|
18
|
+
});
|
15
19
|
});
|
16
20
|
|
17
21
|
Cypress.Commands.add('appScenario', function (name, options = {}) {
|
18
|
-
cy.app('scenarios/' + name, options)
|
22
|
+
return cy.app('scenarios/' + name, options)
|
19
23
|
});
|
20
24
|
|
21
25
|
Cypress.Commands.add('appEval', function (code) {
|
22
|
-
cy.app('eval', code)
|
26
|
+
return cy.app('eval', code)
|
23
27
|
});
|
24
28
|
|
25
29
|
Cypress.Commands.add('appFactories', function (options) {
|
26
|
-
cy.app('factory_bot', options)
|
30
|
+
return cy.app('factory_bot', options)
|
27
31
|
});
|
28
32
|
|
29
33
|
Cypress.Commands.add('appFixtures', function (options) {
|
@@ -0,0 +1,13 @@
|
|
1
|
+
module CypressOnRails
|
2
|
+
class UpdateGenerator < Rails::Generators::Base
|
3
|
+
class_option :cypress_folder, type: :string, default: 'spec/cypress'
|
4
|
+
source_root File.expand_path('../templates', __FILE__)
|
5
|
+
|
6
|
+
def update_generated_files
|
7
|
+
template "config/initializers/cypress_on_rails.rb.erb", "config/initializers/cypress_on_rails.rb"
|
8
|
+
copy_file "spec/cypress/cypress_helper.rb", "#{options.cypress_folder}/cypress_helper.rb"
|
9
|
+
copy_file "spec/cypress/support/on-rails.js", "#{options.cypress_folder}/support/on-rails.js"
|
10
|
+
directory 'spec/cypress/app_commands', "#{options.cypress_folder}/app_commands"
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -16,17 +16,20 @@ RSpec.describe CypressOnRails::Middleware do
|
|
16
16
|
|
17
17
|
context '/__cypress__/command' do
|
18
18
|
before do
|
19
|
-
allow(command_executor).to receive(:load)
|
19
|
+
allow(command_executor).to receive(:load).and_return({ id: 1, title: 'some result' })
|
20
20
|
allow(file).to receive(:exists?)
|
21
21
|
env['PATH_INFO'] = '/__cypress__/command'
|
22
22
|
end
|
23
23
|
|
24
24
|
it 'command file exists' do
|
25
|
+
allow(command_executor).to receive(:load).and_return({ id: 1, title: 'some result' })
|
25
26
|
env['rack.input'] = rack_input(name: 'seed')
|
26
27
|
allow(file).to receive(:exists?).with('spec/cypress/app_commands/seed.rb').and_return(true)
|
27
28
|
|
28
29
|
aggregate_failures do
|
29
|
-
expect(response).to eq([201,
|
30
|
+
expect(response).to eq([201,
|
31
|
+
{"Content-Type"=>"application/json"},
|
32
|
+
["[{\"id\":1,\"title\":\"some result\"}]"]])
|
30
33
|
expect(command_executor).to have_received(:load).with('spec/cypress/app_commands/seed.rb', nil)
|
31
34
|
end
|
32
35
|
end
|
@@ -36,18 +39,36 @@ RSpec.describe CypressOnRails::Middleware do
|
|
36
39
|
allow(file).to receive(:exists?).with('spec/cypress/app_commands/seed.rb').and_return(true)
|
37
40
|
|
38
41
|
aggregate_failures do
|
39
|
-
expect(response).to eq([201,
|
42
|
+
expect(response).to eq([201,
|
43
|
+
{"Content-Type"=>"application/json"},
|
44
|
+
["[{\"id\":1,\"title\":\"some result\"}]"]])
|
40
45
|
expect(command_executor).to have_received(:load).with('spec/cypress/app_commands/seed.rb', ['my_options'])
|
41
46
|
end
|
42
47
|
end
|
43
48
|
|
44
49
|
it 'command file does not exists' do
|
50
|
+
object = BasicObject.new
|
51
|
+
allow(command_executor).to receive(:load).and_return(object)
|
45
52
|
env['rack.input'] = rack_input(name: 'seed')
|
46
|
-
allow(file).to receive(:exists?).with('spec/cypress/app_commands/seed.rb').and_return(
|
53
|
+
allow(file).to receive(:exists?).with('spec/cypress/app_commands/seed.rb').and_return(true)
|
47
54
|
|
48
55
|
aggregate_failures do
|
49
|
-
expect(response).to eq([
|
50
|
-
|
56
|
+
expect(response).to eq([201,
|
57
|
+
{"Content-Type"=>"application/json"},
|
58
|
+
["{\"message\":\"Cannot convert to json\"}"]])
|
59
|
+
expect(command_executor).to have_received(:load).with('spec/cypress/app_commands/seed.rb', nil)
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
it 'command result does not respond to to_json' do
|
64
|
+
env['rack.input'] = rack_input(name: 'seed')
|
65
|
+
allow(file).to receive(:exists?).with('spec/cypress/app_commands/seed.rb').and_return(true)
|
66
|
+
|
67
|
+
aggregate_failures do
|
68
|
+
expect(response).to eq([201,
|
69
|
+
{"Content-Type"=>"application/json"},
|
70
|
+
["[{\"id\":1,\"title\":\"some result\"}]"]])
|
71
|
+
expect(command_executor).to have_received(:load).with('spec/cypress/app_commands/seed.rb', nil)
|
51
72
|
end
|
52
73
|
end
|
53
74
|
|
@@ -58,7 +79,9 @@ RSpec.describe CypressOnRails::Middleware do
|
|
58
79
|
allow(file).to receive(:exists?).with('spec/cypress/app_commands/load_sample.rb').and_return(true)
|
59
80
|
|
60
81
|
aggregate_failures do
|
61
|
-
expect(response).to eq([201,
|
82
|
+
expect(response).to eq([201,
|
83
|
+
{"Content-Type"=>"application/json"},
|
84
|
+
["[{\"id\":1,\"title\":\"some result\"},{\"id\":1,\"title\":\"some result\"}]"]])
|
62
85
|
expect(command_executor).to have_received(:load).with('spec/cypress/app_commands/load_user.rb', nil)
|
63
86
|
expect(command_executor).to have_received(:load).with('spec/cypress/app_commands/load_sample.rb', {'all' => 'true'})
|
64
87
|
end
|
@@ -15,6 +15,7 @@ bundle install --quiet --gemfile="$DIR/Gemfile" --retry 2 --path vendor/bundle
|
|
15
15
|
|
16
16
|
echo '-- cypress install'
|
17
17
|
bundle exec ./bin/rails g cypress_on_rails:install --cypress_folder=cypress --install_cypress_with=npm --no-install-cypress-examples
|
18
|
+
rm -vf cypress/integration/rails_examples/advance_factory_bot_spec.js
|
18
19
|
|
19
20
|
echo '-- start rails server'
|
20
21
|
# make sure the server is not running
|
@@ -15,6 +15,7 @@ bundle install --quiet --gemfile="$DIR/Gemfile" --retry 2 --path vendor/bundle
|
|
15
15
|
|
16
16
|
echo '-- cypress install'
|
17
17
|
bundle exec ./bin/rails g cypress_on_rails:install --no-install-cypress-examples
|
18
|
+
rm -vf spec/cypress/integration/rails_examples/advance_factory_bot_spec.js
|
18
19
|
|
19
20
|
echo '-- start rails server'
|
20
21
|
# make sure the server is not running
|
@@ -33,6 +34,5 @@ else
|
|
33
34
|
yarn run cypress run --record
|
34
35
|
fi
|
35
36
|
|
36
|
-
|
37
37
|
echo '-- stop rails server'
|
38
38
|
kill -9 `cat ../tmp/pids/server.pid`
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cypress-on-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- miceportal team
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2019-
|
12
|
+
date: 2019-10-06 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rack
|
@@ -127,13 +127,15 @@ files:
|
|
127
127
|
- lib/generators/cypress_on_rails/templates/spec/cypress/integration/examples/viewport.spec.js
|
128
128
|
- lib/generators/cypress_on_rails/templates/spec/cypress/integration/examples/waiting.spec.js
|
129
129
|
- lib/generators/cypress_on_rails/templates/spec/cypress/integration/examples/window.spec.js
|
130
|
+
- lib/generators/cypress_on_rails/templates/spec/cypress/integration/rails_examples/advance_factory_bot_spec.js
|
130
131
|
- lib/generators/cypress_on_rails/templates/spec/cypress/integration/rails_examples/other_spec.js
|
131
|
-
- lib/generators/cypress_on_rails/templates/spec/cypress/integration/rails_examples/
|
132
|
-
- lib/generators/cypress_on_rails/templates/spec/cypress/integration/rails_examples/
|
132
|
+
- lib/generators/cypress_on_rails/templates/spec/cypress/integration/rails_examples/using_factory_bot_spec.js
|
133
|
+
- lib/generators/cypress_on_rails/templates/spec/cypress/integration/rails_examples/using_fixtures_spec.js
|
133
134
|
- lib/generators/cypress_on_rails/templates/spec/cypress/integration/rails_examples/using_scenarios_spec.js
|
134
135
|
- lib/generators/cypress_on_rails/templates/spec/cypress/support/commands.js
|
135
136
|
- lib/generators/cypress_on_rails/templates/spec/cypress/support/index.js
|
136
137
|
- lib/generators/cypress_on_rails/templates/spec/cypress/support/on-rails.js
|
138
|
+
- lib/generators/cypress_on_rails/update_generator.rb
|
137
139
|
- spec/cypress_on_rails/command_executor/cypress_helper.rb
|
138
140
|
- spec/cypress_on_rails/command_executor/test_command.rb
|
139
141
|
- spec/cypress_on_rails/command_executor/test_command_with_options.rb
|
@@ -301,8 +303,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
301
303
|
- !ruby/object:Gem::Version
|
302
304
|
version: '0'
|
303
305
|
requirements: []
|
304
|
-
|
305
|
-
rubygems_version: 2.7.6
|
306
|
+
rubygems_version: 3.0.3
|
306
307
|
signing_key:
|
307
308
|
specification_version: 4
|
308
309
|
summary: Integrates cypress with rails or rack applications
|