cypress-on-rails 1.11.0 → 1.12.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
  SHA256:
3
- metadata.gz: 3b8019daab6920154502f30e3a0bc5acb508d3e54cb7befe5274442b70724e02
4
- data.tar.gz: 626901503a647087b14785b8d0df09c1033a01be4cf4f8456beeed376880f5a8
3
+ metadata.gz: 177b927f449263bee75b6df1264121d3786b42b84f628774d132ab16e9bd2661
4
+ data.tar.gz: 1bf70138742d1a0c5cb4e0251196a4b1ac01757d657f8afdb5a66d59c8b08360
5
5
  SHA512:
6
- metadata.gz: 7379070d5df5642e4d9c45dcd3b935784278b409dde546dd9d8e334d54c473f5b3daf1b0061edc9dcabf2b15d3e1b0a6cf4fb9e75ce7d3bf2bf527f0af29dd85
7
- data.tar.gz: 65dde5afa09ef3a862a19928cd76ead9c5f2755c4c15d22c3b978882ae58393ffbbe8799c4e1e6641301fcd20bb82342220029679443249bf8f1671b91c25c83
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
@@ -5,4 +5,5 @@ spec/examples.txt
5
5
  .idea
6
6
  spec/test.log
7
7
  pkg/*.gem
8
- vendor/bundle
8
+ vendor/bundle
9
+ .vscode
data/CHANGELOG.md CHANGED
@@ -1,3 +1,13 @@
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
+
1
11
  ## [1.11.0]
2
12
  [Compare]: https://github.com/shakacode/cypress-on-rails/compare/v1.10.1...v1.11.0
3
13
 
data/README.md CHANGED
@@ -1,6 +1,7 @@
1
1
  # CypressOnRails
2
2
 
3
- [![Build Status](https://travis-ci.com/shakacode/cypress-on-rails.svg?branch=master)](https://travis-ci.org/shakacode/cypress-on-rails) [![Gem Version](https://badge.fury.io/rb/cypress-on-rails.svg)](https://badge.fury.io/rb/cypress-on-rails)
3
+ ![Build Status](https://github.com/shakacode/cypress-on-rails/actions/workflows/ruby.yml/badge.svg)
4
+ [![Gem Version](https://badge.fury.io/rb/cypress-on-rails.svg)](https://badge.fury.io/rb/cypress-on-rails)
4
5
 
5
6
  ----
6
7
 
@@ -53,7 +53,7 @@ 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.exists?(command.file_path) }
56
+ missing_command = commands.find {|command| !@file.exist?(command.file_path) }
57
57
 
58
58
  if missing_command.nil?
59
59
  begin
@@ -27,6 +27,10 @@ module CypressOnRails
27
27
  instance.build_list(*args)
28
28
  end
29
29
 
30
+ def self.reload
31
+ instance.reload
32
+ end
33
+
30
34
  # @return [Array]
31
35
  attr_accessor :factory
32
36
  attr_accessor :always_reload
@@ -44,7 +48,7 @@ module CypressOnRails
44
48
  end
45
49
 
46
50
  def create(*options)
47
- load_files
51
+ auto_reload
48
52
  factory_name = options.shift
49
53
  if options.last.is_a?(Hash)
50
54
  args = options.pop
@@ -55,12 +59,12 @@ module CypressOnRails
55
59
  end
56
60
 
57
61
  def create_list(*args)
58
- load_files
62
+ auto_reload
59
63
  factory.create_list(*args)
60
64
  end
61
65
 
62
66
  def build(*options)
63
- load_files
67
+ auto_reload
64
68
  factory_name = options.shift
65
69
  if options.last.is_a?(Hash)
66
70
  args = options.pop
@@ -71,10 +75,19 @@ module CypressOnRails
71
75
  end
72
76
 
73
77
  def build_list(*args)
74
- load_files
78
+ auto_reload
75
79
  factory.build_list(*args)
76
80
  end
77
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
+
78
91
  private
79
92
 
80
93
  # @param [String,Array] arg
@@ -92,16 +105,11 @@ module CypressOnRails
92
105
  CypressOnRails.configuration.logger
93
106
  end
94
107
 
95
- def load_files
108
+ def auto_reload
96
109
  current_latest_mtime = files.map{|file| @file_system.mtime(file) }.max
97
110
  return unless should_reload?(current_latest_mtime)
98
- logger.info 'Loading Factories'
99
111
  @latest_mtime = current_latest_mtime
100
- factory.reload
101
- files.each do |file|
102
- logger.debug "-- Loading: #{file}"
103
- @kernel.load(file)
104
- end
112
+ reload
105
113
  end
106
114
 
107
115
  def should_reload?(current_latest_mtime)
@@ -1,3 +1,3 @@
1
1
  module CypressOnRails
2
- VERSION = '1.11.0'.freeze
2
+ VERSION = '1.12.0'.freeze
3
3
  end
@@ -7,4 +7,6 @@ else
7
7
  Post.delete_all if defined?(Post)
8
8
  end
9
9
 
10
+ CypressOnRails::SmartFactoryWrapper.reload
11
+
10
12
  Rails.logger.info "APPCLEANED" # used by log_fail.rb
@@ -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: !Rails.configuration.cache_classes,
32
+ always_reload: false,
33
33
  factory: factory,
34
34
  files: [
35
35
  Rails.root.join('spec', 'factories.rb'),
@@ -17,14 +17,14 @@ RSpec.describe CypressOnRails::Middleware do
17
17
  context '/__cypress__/command' do
18
18
  before do
19
19
  allow(command_executor).to receive(:perform).and_return({ id: 1, title: 'some result' })
20
- allow(file).to receive(:exists?)
20
+ allow(file).to receive(:exist?)
21
21
  env['PATH_INFO'] = '/__cypress__/command'
22
22
  end
23
23
 
24
- it 'command file exists' do
24
+ it 'command file exist' do
25
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(:exists?).with('spec/cypress/app_commands/seed.rb').and_return(true)
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,
@@ -34,9 +34,9 @@ RSpec.describe CypressOnRails::Middleware do
34
34
  end
35
35
  end
36
36
 
37
- it 'command file exists with options' do
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(:exists?).with('spec/cypress/app_commands/seed.rb').and_return(true)
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,
@@ -46,11 +46,11 @@ RSpec.describe CypressOnRails::Middleware do
46
46
  end
47
47
  end
48
48
 
49
- it 'command file does not exists' do
49
+ it 'command file does not exist' do
50
50
  object = BasicObject.new
51
51
  allow(command_executor).to receive(:perform).and_return(object)
52
52
  env['rack.input'] = rack_input(name: 'seed')
53
- allow(file).to receive(:exists?).with('spec/cypress/app_commands/seed.rb').and_return(true)
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,
@@ -62,7 +62,7 @@ RSpec.describe CypressOnRails::Middleware do
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(:exists?).with('spec/cypress/app_commands/seed.rb').and_return(true)
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,
@@ -75,8 +75,8 @@ RSpec.describe CypressOnRails::Middleware do
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(:exists?).with('spec/cypress/app_commands/load_user.rb').and_return(true)
79
- allow(file).to receive(:exists?).with('spec/cypress/app_commands/load_sample.rb').and_return(true)
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,
@@ -89,8 +89,8 @@ RSpec.describe CypressOnRails::Middleware do
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(:exists?).with('spec/cypress/app_commands/load_user.rb').and_return(true)
93
- allow(file).to receive(:exists?).with('spec/cypress/app_commands/load_sample.rb').and_return(false)
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']])
@@ -140,6 +140,13 @@ RSpec.describe CypressOnRails::SmartFactoryWrapper do
140
140
  expect(kernel_double).to have_received(:load).with('file2.rb').twice
141
141
  end
142
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
+
143
150
  context 'files is a string' do
144
151
  let(:files) { 'file*.rb' }
145
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 install --quiet --gemfile="$DIR/Gemfile" --retry 2 --path vendor/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.11.0
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: 2021-08-01 00:00:00.000000000 Z
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
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