cypress-on-rails 1.9.0 → 1.12.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/.github/workflows/ruby.yml +57 -0
- data/.gitignore +2 -1
- data/CHANGELOG.md +29 -0
- data/README.md +41 -2
- data/lib/cypress_on_rails/command_executor.rb +1 -1
- data/lib/cypress_on_rails/middleware.rb +13 -8
- data/lib/cypress_on_rails/smart_factory_wrapper.rb +42 -10
- data/lib/cypress_on_rails/version.rb +1 -1
- data/lib/generators/cypress_on_rails/templates/spec/cypress/app_commands/clean.rb +2 -0
- data/lib/generators/cypress_on_rails/templates/spec/cypress/app_commands/log_fail.rb +2 -0
- data/lib/generators/cypress_on_rails/templates/spec/cypress/cypress_helper.rb +1 -1
- data/lib/generators/cypress_on_rails/templates/spec/cypress/support/on-rails.js +9 -3
- data/spec/cypress_on_rails/command_executor_spec.rb +7 -7
- data/spec/cypress_on_rails/middleware_spec.rb +22 -22
- data/spec/cypress_on_rails/smart_factory_wrapper_spec.rb +33 -1
- data/spec/integrations/rails_3_2/test.sh +3 -3
- data/spec/integrations/rails_4_2/test.sh +3 -3
- data/spec/integrations/rails_5_2/test.sh +5 -4
- metadata +4 -4
- data/.travis.yml +0 -39
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 177b927f449263bee75b6df1264121d3786b42b84f628774d132ab16e9bd2661
|
4
|
+
data.tar.gz: 1bf70138742d1a0c5cb4e0251196a4b1ac01757d657f8afdb5a66d59c8b08360
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c853ec1f0a8859a9ceb10bcc5574dcbc4a0cccf92410082bdeb571d5730cefa6ebec1f67ee7ffd0ca1f2f4d52a0c3c13207b72dbae138f80356ad8eaae8d7afa
|
7
|
+
data.tar.gz: b7bba0522ca422efc3de8fbed04d44cd9e4d4662a8fde0a504284f9a8fe304f2ab2e7256a737789fc855360d49c2f43b071021938019482c9dd166f4315481ed
|
@@ -0,0 +1,57 @@
|
|
1
|
+
name: Ruby
|
2
|
+
|
3
|
+
on:
|
4
|
+
push:
|
5
|
+
branches: [ master ]
|
6
|
+
pull_request:
|
7
|
+
branches: [ master ]
|
8
|
+
|
9
|
+
jobs:
|
10
|
+
rails_3_2:
|
11
|
+
runs-on: ubuntu-latest
|
12
|
+
|
13
|
+
steps:
|
14
|
+
- uses: actions/checkout@v2
|
15
|
+
- name: Set up Ruby
|
16
|
+
uses: ruby/setup-ruby@v1
|
17
|
+
with:
|
18
|
+
ruby-version: 2.3
|
19
|
+
bundler-cache: true
|
20
|
+
- name: Run tests
|
21
|
+
run: bundle exec rake
|
22
|
+
- run: gem uninstall -v '>= 2' -ax bundler || true
|
23
|
+
- run: gem install bundler -v '< 2'
|
24
|
+
- name: Run interaction tests
|
25
|
+
run: ./spec/integrations/rails_3_2/test.sh
|
26
|
+
|
27
|
+
rails_4_2:
|
28
|
+
runs-on: ubuntu-latest
|
29
|
+
|
30
|
+
steps:
|
31
|
+
- uses: actions/checkout@v2
|
32
|
+
- name: Set up Ruby
|
33
|
+
uses: ruby/setup-ruby@v1
|
34
|
+
with:
|
35
|
+
ruby-version: 2.5
|
36
|
+
bundler-cache: true
|
37
|
+
- name: Run tests
|
38
|
+
run: bundle exec rake
|
39
|
+
- run: gem uninstall -v '>= 2' -ax bundler || true
|
40
|
+
- run: gem install bundler -v '< 2'
|
41
|
+
- name: Run interaction tests
|
42
|
+
run: ./spec/integrations/rails_4_2/test.sh
|
43
|
+
|
44
|
+
rails_5_2:
|
45
|
+
runs-on: ubuntu-latest
|
46
|
+
|
47
|
+
steps:
|
48
|
+
- uses: actions/checkout@v2
|
49
|
+
- name: Set up Ruby
|
50
|
+
uses: ruby/setup-ruby@v1
|
51
|
+
with:
|
52
|
+
ruby-version: 2.6
|
53
|
+
bundler-cache: true
|
54
|
+
- name: Run tests
|
55
|
+
run: bundle exec rake
|
56
|
+
- name: Run interaction tests
|
57
|
+
run: ./spec/integrations/rails_5_2/test.sh
|
data/.gitignore
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,32 @@
|
|
1
|
+
## [1.12.0]
|
2
|
+
[Compare]: https://github.com/shakacode/cypress-on-rails/compare/v1.11.0...v1.12.0
|
3
|
+
|
4
|
+
### Changed
|
5
|
+
* only reload factories on clean instead of every factory create request [PR 95](https://github.com/shakacode/cypress-on-rails/pull/95)
|
6
|
+
* alternative command added for get tail of logs [PR 89](https://github.com/shakacode/cypress-on-rails/pull/89) by [ccrockett]
|
7
|
+
|
8
|
+
### Tasks
|
9
|
+
* switch from travis to github actions [PR 96]
|
10
|
+
|
11
|
+
## [1.11.0]
|
12
|
+
[Compare]: https://github.com/shakacode/cypress-on-rails/compare/v1.10.1...v1.11.0
|
13
|
+
|
14
|
+
### Changed
|
15
|
+
* improve app command logging on cypress
|
16
|
+
* Allow build and build_list commands to be executed against factory bot [PR 87](https://github.com/shakacode/cypress-on-rails/pull/87) by [Alexander-Blair]
|
17
|
+
|
18
|
+
## [1.10.1]
|
19
|
+
[Compare]: https://github.com/shakacode/cypress-on-rails/compare/v1.9.1...v1.10.1
|
20
|
+
|
21
|
+
### Changed
|
22
|
+
* improve error message received from failed command
|
23
|
+
|
24
|
+
## [1.9.1]
|
25
|
+
[Compare]: https://github.com/shakacode/cypress-on-rails/compare/v1.9.0...v1.9.1
|
26
|
+
|
27
|
+
### Fixed
|
28
|
+
* fix using `load` in command files
|
29
|
+
|
1
30
|
## [1.9.0]
|
2
31
|
[Compare]: https://github.com/shakacode/cypress-on-rails/compare/v1.8.1...v1.9.0
|
3
32
|
|
data/README.md
CHANGED
@@ -1,10 +1,13 @@
|
|
1
1
|
# CypressOnRails
|
2
2
|
|
3
|
-
|
3
|
+

|
4
|
+
[](https://badge.fury.io/rb/cypress-on-rails)
|
4
5
|
|
5
6
|
----
|
6
7
|
|
7
|
-
This project is sponsored by the software consulting firm [ShakaCode](https://www.shakacode.com), creator of the [React on Rails Gem](https://github.com/shakacode/react_on_rails). We focus on React front-ends, often with Ruby on Rails or Gatsby.
|
8
|
+
This project is sponsored by the software consulting firm [ShakaCode](https://www.shakacode.com), creator of the [React on Rails Gem](https://github.com/shakacode/react_on_rails). We focus on React (with TS or ReScript) front-ends, often with Ruby on Rails or Gatsby. See [our recent work](https://www.shakacode.com/recent-work) and [client engagement model](https://www.shakacode.com/blog/client-engagement-model/). Feel free to engage in discussions around this gem at our [Slack Channel](https://join.slack.com/t/reactrails/shared_invite/enQtNjY3NTczMjczNzYxLTlmYjdiZmY3MTVlMzU2YWE0OWM0MzNiZDI0MzdkZGFiZTFkYTFkOGVjODBmOWEyYWQ3MzA2NGE1YWJjNmVlMGE) or our [forum category for Cypress](https://forum.shakacode.com/c/cypress-on-rails/55).
|
9
|
+
|
10
|
+
Interested in joining a small team that loves open source? Check our [careers page](https://www.shakacode.com/career/).
|
8
11
|
|
9
12
|
----
|
10
13
|
|
@@ -164,6 +167,42 @@ describe('My First Test', function() {
|
|
164
167
|
})
|
165
168
|
```
|
166
169
|
|
170
|
+
In some cases, using static Cypress fixtures may not provide sufficient flexibility when mocking HTTP response bodies - it's possible to use `FactoryBot.build` to generate Ruby hashes that can then be used as mock JSON responses:
|
171
|
+
```ruby
|
172
|
+
FactoryBot.define do
|
173
|
+
factory :some_web_response, class: Hash do
|
174
|
+
initialize_with { attributes.deep_stringify_keys }
|
175
|
+
|
176
|
+
id { 123 }
|
177
|
+
name { 'Mr Blobby' }
|
178
|
+
occupation { 'Evil pink clown' }
|
179
|
+
end
|
180
|
+
end
|
181
|
+
|
182
|
+
FactoryBot.build(:some_web_response) => { 'id' => 123, 'name' => 'Mr Blobby', 'occupation' => 'Evil pink clown' }
|
183
|
+
```
|
184
|
+
|
185
|
+
This can then be combined with Cypress mocks:
|
186
|
+
```js
|
187
|
+
describe('My First Test', function() {
|
188
|
+
it('visit root', function() {
|
189
|
+
// This calls to the backend to generate the mocked response
|
190
|
+
cy.appFactories([
|
191
|
+
['build', 'some_web_response', { name: 'Baby Blobby' }]
|
192
|
+
]).then(([responseBody]) => {
|
193
|
+
cy.intercept('http://some-external-url.com/endpoint', {
|
194
|
+
body: responseBody
|
195
|
+
});
|
196
|
+
|
197
|
+
// Visit the application under test
|
198
|
+
cy.visit('/')
|
199
|
+
})
|
200
|
+
|
201
|
+
cy.contains("Hello World")
|
202
|
+
})
|
203
|
+
})
|
204
|
+
```
|
205
|
+
|
167
206
|
### Example of loading rails test fixtures
|
168
207
|
```ruby
|
169
208
|
# spec/cypress/app_commands/activerecord_fixtures.rb
|
@@ -3,7 +3,7 @@ require 'cypress_on_rails/configuration'
|
|
3
3
|
module CypressOnRails
|
4
4
|
# loads and evals the command files
|
5
5
|
class CommandExecutor
|
6
|
-
def self.
|
6
|
+
def self.perform(file,command_options = nil)
|
7
7
|
load_cypress_helper
|
8
8
|
file_data = File.read(file)
|
9
9
|
eval file_data, binding, file
|
@@ -53,18 +53,23 @@ module CypressOnRails
|
|
53
53
|
body = JSON.parse(req.body.read)
|
54
54
|
logger.info "handle_command: #{body}"
|
55
55
|
commands = Command.from_body(body, configuration)
|
56
|
-
missing_command = commands.find {|command| !@file.
|
56
|
+
missing_command = commands.find {|command| !@file.exist?(command.file_path) }
|
57
57
|
|
58
58
|
if missing_command.nil?
|
59
|
-
results = commands.map { |command| @command_executor.load(command.file_path, command.options) }
|
60
|
-
|
61
59
|
begin
|
62
|
-
|
63
|
-
rescue NoMethodError
|
64
|
-
output = {"message" => "Cannot convert to json"}.to_json
|
65
|
-
end
|
60
|
+
results = commands.map { |command| @command_executor.perform(command.file_path, command.options) }
|
66
61
|
|
67
|
-
|
62
|
+
begin
|
63
|
+
output = results.to_json
|
64
|
+
rescue NoMethodError
|
65
|
+
output = {"message" => "Cannot convert to json"}.to_json
|
66
|
+
end
|
67
|
+
|
68
|
+
[201, {'Content-Type' => 'application/json'}, [output]]
|
69
|
+
rescue => e
|
70
|
+
output = {"message" => e.message, "class" => e.class.to_s}.to_json
|
71
|
+
[500, {'Content-Type' => 'application/json'}, [output]]
|
72
|
+
end
|
68
73
|
else
|
69
74
|
[404, {}, ["could not find command file: #{missing_command.file_path}"]]
|
70
75
|
end
|
@@ -19,6 +19,18 @@ module CypressOnRails
|
|
19
19
|
instance.create_list(*args)
|
20
20
|
end
|
21
21
|
|
22
|
+
def self.build(*args)
|
23
|
+
instance.build(*args)
|
24
|
+
end
|
25
|
+
|
26
|
+
def self.build_list(*args)
|
27
|
+
instance.build_list(*args)
|
28
|
+
end
|
29
|
+
|
30
|
+
def self.reload
|
31
|
+
instance.reload
|
32
|
+
end
|
33
|
+
|
22
34
|
# @return [Array]
|
23
35
|
attr_accessor :factory
|
24
36
|
attr_accessor :always_reload
|
@@ -36,7 +48,7 @@ module CypressOnRails
|
|
36
48
|
end
|
37
49
|
|
38
50
|
def create(*options)
|
39
|
-
|
51
|
+
auto_reload
|
40
52
|
factory_name = options.shift
|
41
53
|
if options.last.is_a?(Hash)
|
42
54
|
args = options.pop
|
@@ -47,10 +59,35 @@ module CypressOnRails
|
|
47
59
|
end
|
48
60
|
|
49
61
|
def create_list(*args)
|
50
|
-
|
62
|
+
auto_reload
|
51
63
|
factory.create_list(*args)
|
52
64
|
end
|
53
65
|
|
66
|
+
def build(*options)
|
67
|
+
auto_reload
|
68
|
+
factory_name = options.shift
|
69
|
+
if options.last.is_a?(Hash)
|
70
|
+
args = options.pop
|
71
|
+
else
|
72
|
+
args = {}
|
73
|
+
end
|
74
|
+
factory.build(factory_name, *options.map(&:to_sym), args.symbolize_keys)
|
75
|
+
end
|
76
|
+
|
77
|
+
def build_list(*args)
|
78
|
+
auto_reload
|
79
|
+
factory.build_list(*args)
|
80
|
+
end
|
81
|
+
|
82
|
+
def reload
|
83
|
+
logger.info 'Loading Factories'
|
84
|
+
factory.reload
|
85
|
+
files.each do |file|
|
86
|
+
logger.debug "-- Loading: #{file}"
|
87
|
+
@kernel.load(file)
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
54
91
|
private
|
55
92
|
|
56
93
|
# @param [String,Array] arg
|
@@ -68,20 +105,15 @@ module CypressOnRails
|
|
68
105
|
CypressOnRails.configuration.logger
|
69
106
|
end
|
70
107
|
|
71
|
-
def
|
108
|
+
def auto_reload
|
72
109
|
current_latest_mtime = files.map{|file| @file_system.mtime(file) }.max
|
73
110
|
return unless should_reload?(current_latest_mtime)
|
74
|
-
logger.info 'Loading Factories'
|
75
111
|
@latest_mtime = current_latest_mtime
|
76
|
-
|
77
|
-
files.each do |file|
|
78
|
-
logger.debug "-- Loading: #{file}"
|
79
|
-
@kernel.load(file)
|
80
|
-
end
|
112
|
+
reload
|
81
113
|
end
|
82
114
|
|
83
115
|
def should_reload?(current_latest_mtime)
|
84
116
|
@always_reload || @latest_mtime.nil? || @latest_mtime < current_latest_mtime
|
85
117
|
end
|
86
118
|
end
|
87
|
-
end
|
119
|
+
end
|
@@ -3,6 +3,8 @@ filename = command_options.fetch('runnable_full_title', 'no title').gsub(/[^[:pr
|
|
3
3
|
|
4
4
|
# grab last lines until "APPCLEANED" (Make sure in clean.rb to log the text "APPCLEANED")
|
5
5
|
system "tail -n 10000 -r log/#{Rails.env}.log | sed \"/APPCLEANED/ q\" | sed 'x;1!H;$!d;x' > 'log/#{filename}.log'"
|
6
|
+
# Alternative command if the above does not work
|
7
|
+
# system "tail -n 10000 log/#{Rails.env}.log | tac | sed \"/APPCLEANED/ q\" | sed 'x;1!H;$!d;x' > 'log/#{filename}.log'"
|
6
8
|
|
7
9
|
# create a json debug file for server debugging
|
8
10
|
json_result = {}
|
@@ -29,7 +29,7 @@ factory = FactoryBot if defined?(FactoryBot)
|
|
29
29
|
factory = FactoryGirl if defined?(FactoryGirl)
|
30
30
|
|
31
31
|
CypressOnRails::SmartFactoryWrapper.configure(
|
32
|
-
always_reload:
|
32
|
+
always_reload: false,
|
33
33
|
factory: factory,
|
34
34
|
files: [
|
35
35
|
Rails.root.join('spec', 'factories.rb'),
|
@@ -1,13 +1,19 @@
|
|
1
1
|
// CypressOnRails: dont remove these command
|
2
2
|
Cypress.Commands.add('appCommands', function (body) {
|
3
|
-
|
3
|
+
Object.keys(body).forEach(key => body[key] === undefined ? delete body[key] : {});
|
4
|
+
const log = Cypress.log({ name: "APP", message: body, autoEnd: false })
|
4
5
|
return cy.request({
|
5
6
|
method: 'POST',
|
6
7
|
url: "/__cypress__/command",
|
7
8
|
body: JSON.stringify(body),
|
8
|
-
log:
|
9
|
-
failOnStatusCode:
|
9
|
+
log: false,
|
10
|
+
failOnStatusCode: false
|
10
11
|
}).then((response) => {
|
12
|
+
log.end();
|
13
|
+
if (response.status !== 201) {
|
14
|
+
expect(response.body.message).to.be.empty
|
15
|
+
expect(response.status).to.be.equal(201)
|
16
|
+
}
|
11
17
|
return response.body
|
12
18
|
});
|
13
19
|
});
|
@@ -1,12 +1,12 @@
|
|
1
1
|
require 'cypress_on_rails/command_executor'
|
2
2
|
|
3
3
|
RSpec.describe CypressOnRails::CommandExecutor do
|
4
|
-
describe '.
|
4
|
+
describe '.perform' do
|
5
5
|
let(:folder) { "#{__dir__}/command_executor" }
|
6
6
|
subject { described_class }
|
7
7
|
|
8
|
-
def
|
9
|
-
subject.
|
8
|
+
def executor_perform(*values)
|
9
|
+
subject.perform(*values)
|
10
10
|
end
|
11
11
|
|
12
12
|
before do
|
@@ -15,18 +15,18 @@ RSpec.describe CypressOnRails::CommandExecutor do
|
|
15
15
|
end
|
16
16
|
|
17
17
|
it 'runs test command' do
|
18
|
-
|
18
|
+
executor_perform("#{folder}/test_command.rb")
|
19
19
|
expect(DummyTest.values).to eq(%w(hello))
|
20
20
|
end
|
21
21
|
|
22
22
|
it 'runs test command twice' do
|
23
|
-
|
24
|
-
|
23
|
+
executor_perform("#{folder}/test_command.rb")
|
24
|
+
executor_perform("#{folder}/test_command.rb")
|
25
25
|
expect(DummyTest.values).to eq(%w(hello hello))
|
26
26
|
end
|
27
27
|
|
28
28
|
it 'runs command with options' do
|
29
|
-
|
29
|
+
executor_perform("#{folder}/test_command_with_options.rb", 'my_string')
|
30
30
|
expect(DummyTest.values).to eq(%w(my_string))
|
31
31
|
end
|
32
32
|
end
|
@@ -16,85 +16,85 @@ RSpec.describe CypressOnRails::Middleware do
|
|
16
16
|
|
17
17
|
context '/__cypress__/command' do
|
18
18
|
before do
|
19
|
-
allow(command_executor).to receive(:
|
20
|
-
allow(file).to receive(:
|
19
|
+
allow(command_executor).to receive(:perform).and_return({ id: 1, title: 'some result' })
|
20
|
+
allow(file).to receive(:exist?)
|
21
21
|
env['PATH_INFO'] = '/__cypress__/command'
|
22
22
|
end
|
23
23
|
|
24
|
-
it 'command file
|
25
|
-
allow(command_executor).to receive(:
|
24
|
+
it 'command file exist' do
|
25
|
+
allow(command_executor).to receive(:perform).and_return({ id: 1, title: 'some result' })
|
26
26
|
env['rack.input'] = rack_input(name: 'seed')
|
27
|
-
allow(file).to receive(:
|
27
|
+
allow(file).to receive(:exist?).with('spec/cypress/app_commands/seed.rb').and_return(true)
|
28
28
|
|
29
29
|
aggregate_failures do
|
30
30
|
expect(response).to eq([201,
|
31
31
|
{"Content-Type"=>"application/json"},
|
32
32
|
["[{\"id\":1,\"title\":\"some result\"}]"]])
|
33
|
-
expect(command_executor).to have_received(:
|
33
|
+
expect(command_executor).to have_received(:perform).with('spec/cypress/app_commands/seed.rb', nil)
|
34
34
|
end
|
35
35
|
end
|
36
36
|
|
37
|
-
it 'command file
|
37
|
+
it 'command file exist with options' do
|
38
38
|
env['rack.input'] = rack_input(name: 'seed', options: ['my_options'])
|
39
|
-
allow(file).to receive(:
|
39
|
+
allow(file).to receive(:exist?).with('spec/cypress/app_commands/seed.rb').and_return(true)
|
40
40
|
|
41
41
|
aggregate_failures do
|
42
42
|
expect(response).to eq([201,
|
43
43
|
{"Content-Type"=>"application/json"},
|
44
44
|
["[{\"id\":1,\"title\":\"some result\"}]"]])
|
45
|
-
expect(command_executor).to have_received(:
|
45
|
+
expect(command_executor).to have_received(:perform).with('spec/cypress/app_commands/seed.rb', ['my_options'])
|
46
46
|
end
|
47
47
|
end
|
48
48
|
|
49
|
-
it 'command file does not
|
49
|
+
it 'command file does not exist' do
|
50
50
|
object = BasicObject.new
|
51
|
-
allow(command_executor).to receive(:
|
51
|
+
allow(command_executor).to receive(:perform).and_return(object)
|
52
52
|
env['rack.input'] = rack_input(name: 'seed')
|
53
|
-
allow(file).to receive(:
|
53
|
+
allow(file).to receive(:exist?).with('spec/cypress/app_commands/seed.rb').and_return(true)
|
54
54
|
|
55
55
|
aggregate_failures do
|
56
56
|
expect(response).to eq([201,
|
57
57
|
{"Content-Type"=>"application/json"},
|
58
58
|
["{\"message\":\"Cannot convert to json\"}"]])
|
59
|
-
expect(command_executor).to have_received(:
|
59
|
+
expect(command_executor).to have_received(:perform).with('spec/cypress/app_commands/seed.rb', nil)
|
60
60
|
end
|
61
61
|
end
|
62
62
|
|
63
63
|
it 'command result does not respond to to_json' do
|
64
64
|
env['rack.input'] = rack_input(name: 'seed')
|
65
|
-
allow(file).to receive(:
|
65
|
+
allow(file).to receive(:exist?).with('spec/cypress/app_commands/seed.rb').and_return(true)
|
66
66
|
|
67
67
|
aggregate_failures do
|
68
68
|
expect(response).to eq([201,
|
69
69
|
{"Content-Type"=>"application/json"},
|
70
70
|
["[{\"id\":1,\"title\":\"some result\"}]"]])
|
71
|
-
expect(command_executor).to have_received(:
|
71
|
+
expect(command_executor).to have_received(:perform).with('spec/cypress/app_commands/seed.rb', nil)
|
72
72
|
end
|
73
73
|
end
|
74
74
|
|
75
75
|
it 'running multiple commands' do
|
76
76
|
env['rack.input'] = rack_input([{name: 'load_user'},
|
77
77
|
{name: 'load_sample', options: {'all' => 'true'}}])
|
78
|
-
allow(file).to receive(:
|
79
|
-
allow(file).to receive(:
|
78
|
+
allow(file).to receive(:exist?).with('spec/cypress/app_commands/load_user.rb').and_return(true)
|
79
|
+
allow(file).to receive(:exist?).with('spec/cypress/app_commands/load_sample.rb').and_return(true)
|
80
80
|
|
81
81
|
aggregate_failures do
|
82
82
|
expect(response).to eq([201,
|
83
83
|
{"Content-Type"=>"application/json"},
|
84
84
|
["[{\"id\":1,\"title\":\"some result\"},{\"id\":1,\"title\":\"some result\"}]"]])
|
85
|
-
expect(command_executor).to have_received(:
|
86
|
-
expect(command_executor).to have_received(:
|
85
|
+
expect(command_executor).to have_received(:perform).with('spec/cypress/app_commands/load_user.rb', nil)
|
86
|
+
expect(command_executor).to have_received(:perform).with('spec/cypress/app_commands/load_sample.rb', {'all' => 'true'})
|
87
87
|
end
|
88
88
|
end
|
89
89
|
|
90
90
|
it 'running multiple commands but one missing' do
|
91
91
|
env['rack.input'] = rack_input([{name: 'load_user'}, {name: 'load_sample'}])
|
92
|
-
allow(file).to receive(:
|
93
|
-
allow(file).to receive(:
|
92
|
+
allow(file).to receive(:exist?).with('spec/cypress/app_commands/load_user.rb').and_return(true)
|
93
|
+
allow(file).to receive(:exist?).with('spec/cypress/app_commands/load_sample.rb').and_return(false)
|
94
94
|
|
95
95
|
aggregate_failures do
|
96
96
|
expect(response).to eq([404, {}, ['could not find command file: spec/cypress/app_commands/load_sample.rb']])
|
97
|
-
expect(command_executor).to_not have_received(:
|
97
|
+
expect(command_executor).to_not have_received(:perform)
|
98
98
|
end
|
99
99
|
end
|
100
100
|
end
|
@@ -12,7 +12,7 @@ RSpec.describe CypressOnRails::SmartFactoryWrapper do
|
|
12
12
|
let(:mtime_hash) { {'file1.rb' => time_now, 'file2.rb' => time_now } }
|
13
13
|
let(:files) { %w(file1.rb file2.rb) }
|
14
14
|
let(:factory_double) do
|
15
|
-
class_double(FactoryBot, create: nil, create_list: nil, "definition_file_paths=": nil, reload: nil)
|
15
|
+
class_double(FactoryBot, create: nil, create_list: nil, build: nil, build_list: nil, "definition_file_paths=": nil, reload: nil)
|
16
16
|
end
|
17
17
|
let(:kernel_double) { class_double(Kernel, load: true) }
|
18
18
|
let(:file_double) { FileSystemDummy.new(mtime_hash) }
|
@@ -67,6 +67,31 @@ RSpec.describe CypressOnRails::SmartFactoryWrapper do
|
|
67
67
|
expect(factory_double).to have_received(:create_list).with(:note, 10)
|
68
68
|
end
|
69
69
|
|
70
|
+
it 'delegates build to the factory' do
|
71
|
+
subject.build(:user)
|
72
|
+
expect(factory_double).to have_received(:build).with(:user, {})
|
73
|
+
end
|
74
|
+
|
75
|
+
it 'delegates build to the factory and symbolize keys' do
|
76
|
+
subject.build(:user, {'name' => "name"})
|
77
|
+
expect(factory_double).to have_received(:build).with(:user, {name: 'name'})
|
78
|
+
end
|
79
|
+
|
80
|
+
it 'delegates build to the factory and symbolize keys with trait' do
|
81
|
+
subject.build(:user, 'trait1', {'name' => "name"})
|
82
|
+
expect(factory_double).to have_received(:build).with(:user, :trait1, {name: 'name'})
|
83
|
+
end
|
84
|
+
|
85
|
+
it 'delegates build to the factory and symbolize keys with only trait' do
|
86
|
+
subject.build(:user, 'trait2')
|
87
|
+
expect(factory_double).to have_received(:build).with(:user, :trait2, {})
|
88
|
+
end
|
89
|
+
|
90
|
+
it 'delegates build_list to the factory' do
|
91
|
+
subject.build_list(:note, 10)
|
92
|
+
expect(factory_double).to have_received(:build_list).with(:note, 10)
|
93
|
+
end
|
94
|
+
|
70
95
|
it 'wont load the files if they have not changed' do
|
71
96
|
subject.create(:user)
|
72
97
|
subject.create_list(:user, 2)
|
@@ -115,6 +140,13 @@ RSpec.describe CypressOnRails::SmartFactoryWrapper do
|
|
115
140
|
expect(kernel_double).to have_received(:load).with('file2.rb').twice
|
116
141
|
end
|
117
142
|
|
143
|
+
it 'can manually reload' do
|
144
|
+
subject.reload
|
145
|
+
expect(factory_double).to have_received(:reload)
|
146
|
+
expect(kernel_double).to have_received(:load).with('file1.rb')
|
147
|
+
expect(kernel_double).to have_received(:load).with('file2.rb')
|
148
|
+
end
|
149
|
+
|
118
150
|
context 'files is a string' do
|
119
151
|
let(:files) { 'file*.rb' }
|
120
152
|
|
@@ -4,9 +4,9 @@ set -eo pipefail
|
|
4
4
|
echo '--- testing rails 3.2'
|
5
5
|
|
6
6
|
echo '-- setting environment'
|
7
|
-
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
8
|
-
RAILS_ENV=test
|
9
|
-
BUNDLE_GEMFILE="$DIR/Gemfile"
|
7
|
+
export DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
8
|
+
export RAILS_ENV=test
|
9
|
+
export BUNDLE_GEMFILE="$DIR/Gemfile"
|
10
10
|
cd $DIR
|
11
11
|
|
12
12
|
echo '-- bundle install'
|
@@ -4,9 +4,9 @@ set -eo pipefail
|
|
4
4
|
echo '--- testing rails 4.2'
|
5
5
|
|
6
6
|
echo '-- setting environment'
|
7
|
-
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
8
|
-
RAILS_ENV=test
|
9
|
-
BUNDLE_GEMFILE="$DIR/Gemfile"
|
7
|
+
export DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
8
|
+
export RAILS_ENV=test
|
9
|
+
export BUNDLE_GEMFILE="$DIR/Gemfile"
|
10
10
|
cd $DIR
|
11
11
|
|
12
12
|
echo '-- bundle install'
|
@@ -4,14 +4,15 @@ set -eo pipefail
|
|
4
4
|
echo '--- testing rails 5.2'
|
5
5
|
|
6
6
|
echo '-- setting environment'
|
7
|
-
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
8
|
-
RAILS_ENV=test
|
9
|
-
BUNDLE_GEMFILE="$DIR/Gemfile"
|
7
|
+
export DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
8
|
+
export RAILS_ENV=test
|
9
|
+
export BUNDLE_GEMFILE="$DIR/Gemfile"
|
10
10
|
cd $DIR
|
11
11
|
|
12
12
|
echo '-- bundle install'
|
13
13
|
bundle --version
|
14
|
-
bundle
|
14
|
+
bundle config set --local path 'vendor/bundle'
|
15
|
+
bundle install --quiet --gemfile="$DIR/Gemfile" --retry 2
|
15
16
|
|
16
17
|
echo '-- migration'
|
17
18
|
bundle exec ./bin/rails db:drop || true
|
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.12.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:
|
12
|
+
date: 2022-01-03 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rack
|
@@ -90,9 +90,9 @@ extensions: []
|
|
90
90
|
extra_rdoc_files: []
|
91
91
|
files:
|
92
92
|
- ".github/FUNDING.yml"
|
93
|
+
- ".github/workflows/ruby.yml"
|
93
94
|
- ".gitignore"
|
94
95
|
- ".rspec"
|
95
|
-
- ".travis.yml"
|
96
96
|
- CHANGELOG.md
|
97
97
|
- Gemfile
|
98
98
|
- LICENSE
|
@@ -323,7 +323,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
323
323
|
- !ruby/object:Gem::Version
|
324
324
|
version: '0'
|
325
325
|
requirements: []
|
326
|
-
rubygems_version: 3.2.
|
326
|
+
rubygems_version: 3.2.25
|
327
327
|
signing_key:
|
328
328
|
specification_version: 4
|
329
329
|
summary: Integrates cypress with rails or rack applications
|
data/.travis.yml
DELETED
@@ -1,39 +0,0 @@
|
|
1
|
-
language: ruby
|
2
|
-
rvm:
|
3
|
-
- 2.3
|
4
|
-
- 2.4
|
5
|
-
- 2.5
|
6
|
-
- 2.6
|
7
|
-
# - 2.7
|
8
|
-
|
9
|
-
#addons:
|
10
|
-
# artifacts:
|
11
|
-
# s3_region: "ap-southeast-2"
|
12
|
-
# paths:
|
13
|
-
# - $(ls spec/integrations/*/*/cypress/{screenshots,videos}/* | tr "\n" ":")
|
14
|
-
# - $(ls spec/integrations/rails_3_2/cypress/{screenshots,videos}/* | tr "\n" ":")
|
15
|
-
|
16
|
-
cache:
|
17
|
-
directories:
|
18
|
-
- spec/integrations/rails_5_2/spec/node_modules
|
19
|
-
- spec/integrations/rails_5_2/vendor/bundle
|
20
|
-
- spec/integrations/rails_4_2/test/node_modules
|
21
|
-
- spec/integrations/rails_4_2/vendor/bundle
|
22
|
-
- spec/integrations/rails_3_2/node_modules
|
23
|
-
- spec/integrations/rails_3_2/vendor/bundle
|
24
|
-
|
25
|
-
before_install:
|
26
|
-
- sudo apt-get -qq update
|
27
|
-
- sudo apt-get install -y build-essential patch ruby-dev zlib1g-dev liblzma-dev libxml2-dev
|
28
|
-
- sudo apt-get install -y xvfb libgtk2.0-0 libnotify-dev libgconf-2-4 libnss3 libxss1 libasound2
|
29
|
-
- travis_retry nvm install 14.13.1
|
30
|
-
- node -v
|
31
|
-
- nvm alias default 14.13.1
|
32
|
-
|
33
|
-
script:
|
34
|
-
- bundle exec rake
|
35
|
-
- gem uninstall -v '>= 2' -i $(rvm gemdir)@global -ax bundler || true
|
36
|
-
- gem install bundler -v '< 2'
|
37
|
-
- ./spec/integrations/rails_5_2/test.sh
|
38
|
-
- ./spec/integrations/rails_4_2/test.sh
|
39
|
-
- ./spec/integrations/rails_3_2/test.sh
|