cypress-on-rails 1.1.1 → 1.2.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: 92ef9e4a473b4f2443f22531b4f9841e4b2026cd3c10752e4e21acc3aac4bd26
4
- data.tar.gz: d78ddeef85ade24097a8582e9f96e116c914312cdfee9f2671921a57ce6ebc88
3
+ metadata.gz: f21cac226aa4015c07018d58964e0644fa129190addcf71f9b968ce727bcbbdc
4
+ data.tar.gz: cc6ca291b3054e3da1914927515106d27e2064d262f05040025e3c649d7d7ff0
5
5
  SHA512:
6
- metadata.gz: 8823d163582b4aa7f328ac52069db710fb851cab2e94835eda32dfbb9b7008bbe35fb4cdaa7be826dc5ca9f4db038cf8d947e1ab016b41070171b6c582f87d52
7
- data.tar.gz: 34b03e8a0e6f15152ed263f234768e0af41aeb84fbe5144c5c97d305bc4e3470e592c324d155cad48534310f55682d578b4fcb292d1c6523db96bedc117b888a
6
+ metadata.gz: 880f43bc0764b118be64782dc46d873348b9f579c43f48709002abb2ab970da97228cd046d915a564d9a9183dd6a2bd2501e6326154ceafa79f71598e5e657e7
7
+ data.tar.gz: 2e89c6aca7735d4972aaf270e448d31865c083be59fee3f3611549805d1ea26e7be91e403fece32b82750acfb60f19d1341d85c9e02bd367ac0bf18f6f07f60e
@@ -1,3 +1,7 @@
1
+ ## 1.2.0
2
+ ### Tasks
3
+ * adding additional log failure logging
4
+
1
5
  ## 1.1.1
2
6
  ### Fixed
3
7
  * smart factory wrapper can handle when factory files get deleted
data/README.md CHANGED
@@ -20,6 +20,8 @@ Has examples of setting up state with:
20
20
 
21
21
  This gem is based off https://github.com/konvenit/cypress-on-rails
22
22
 
23
+ Video of getting started with this gem https://grant-ps.blog/2018/08/10/getting-started-with-cypress-io-and-ruby-on-rails/
24
+
23
25
  ## Getting started
24
26
 
25
27
  Add this to your Gemfile:
@@ -54,7 +56,7 @@ Now you can create scenarios and commands that are plan ruby files that get load
54
56
 
55
57
  ### WARNING
56
58
  *WARNING!!:* cypress-on-rails can execute arbitrary ruby code
57
- Please use with extra caution if starting your local server on 0.0.0.0 or running on a hosted server
59
+ Please use with extra caution if starting your local server on 0.0.0.0 or running the gem on a hosted server
58
60
 
59
61
  ## Usage
60
62
 
@@ -1,3 +1,3 @@
1
1
  module CypressDev
2
- VERSION = '1.1.1'
2
+ VERSION = '1.2.0'
3
3
  end
@@ -6,3 +6,5 @@ else
6
6
  logger.warn "add database_cleaner or update clean_db"
7
7
  Post.delete_all if defined?(Post)
8
8
  end
9
+
10
+ Rails.logger.info "APPCLEANED" # used by log_fail.rb
@@ -0,0 +1,24 @@
1
+ # This file is called when a cypress spec fails and allows for extra logging to be captured
2
+ filename = command_options.fetch('runnable_full_title', 'no title').gsub(/[^[:print:]]/, '')
3
+
4
+ # grab last lines until "APPCLEANED" (Make sure in clean.rb to log the text "APPCLEANED")
5
+ system "tail -n 10000 -r log/#{Rails.env}.log | sed \"/APPCLEANED/ q\" | sed 'x;1!H;$!d;x' > 'log/#{filename}.log'"
6
+
7
+ # create a json debug file for server debugging
8
+ json_result = {}
9
+ json_result['error'] = command_options.fetch('error_message', 'no error message')
10
+
11
+ if defined?(ActiveRecord::Base)
12
+ json_result['records'] =
13
+ ActiveRecord::Base.descendants.each_with_object({}) do |record_class, records|
14
+ begin
15
+ records[record_class.to_s] = record_class.limit(100).map(&:attributes)
16
+ rescue
17
+ end
18
+ end
19
+ end
20
+
21
+ filename = command_options.fetch('runnable_full_title', 'no title').gsub(/[^[:print:]]/, '')
22
+ File.open("#{Rails.root}/log/#{filename}.json", "w+") do |file|
23
+ file << JSON.pretty_generate(json_result)
24
+ end
@@ -15,12 +15,16 @@ describe('Rails using scenarios examples', function() {
15
15
  })
16
16
  })
17
17
 
18
- // uncomment these if you want to see what happens
19
- // it('example of missing scenario failure', function() {
20
- // cy.appScenario('missing')
21
- // })
22
- //
23
- // it('example of missing app failure', function() {
24
- // cy.app('run_me')
25
- // })
18
+
19
+ it('example of missing scenario failure', function() {
20
+ cy.visit('/')
21
+ cy.appScenario('basic')
22
+ // cy.appScenario('missing') // uncomment these if you want to see what happens
23
+ })
24
+
25
+ it('example of missing app failure', function() {
26
+ cy.visit('/')
27
+ cy.appScenario('basic')
28
+ // cy.app('run_me') // uncomment these if you want to see what happens
29
+ })
26
30
  })
@@ -34,4 +34,17 @@ Cypress.Commands.add('appFixtures', function (options) {
34
34
  // The next is optional
35
35
  // beforeEach(() => {
36
36
  // cy.app('clean') // have a look at cypress/app_commands/clean.rb
37
- // });
37
+ // });
38
+
39
+ // comment this out if you do not want to attempt to log additional info on test fail
40
+ Cypress.on('fail', (err, runnable) => {
41
+ // allow app to generate additional logging data
42
+ Cypress.$.ajax({
43
+ url: '/__cypress__/command',
44
+ data: JSON.stringify({name: 'log_fail', options: {error_message: err.message, runnable_full_title: runnable.fullTitle() }}),
45
+ async: false,
46
+ method: 'POST'
47
+ });
48
+
49
+ throw err;
50
+ });
@@ -64,6 +64,5 @@ module Rails32
64
64
 
65
65
  # Version of your assets, change this if you want to expire all your assets
66
66
  config.assets.version = '1.0'
67
- config.logger = Logger.new(STDOUT)
68
67
  end
69
68
  end
File without changes
@@ -28,6 +28,5 @@ module Rails42X
28
28
  # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
29
29
  # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
30
30
  # config.i18n.default_locale = :de
31
- config.logger = Logger.new(STDOUT)
32
31
  end
33
32
  end
File without changes
@@ -29,9 +29,5 @@ module Rails52
29
29
 
30
30
  # Don't generate system test files.
31
31
  config.generators.system_tests = nil
32
-
33
- logger = ActiveSupport::Logger.new(STDOUT)
34
- logger.formatter = config.log_formatter
35
- config.logger = ActiveSupport::TaggedLogging.new(logger)
36
32
  end
37
33
  end
File without changes
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.1.1
4
+ version: 1.2.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: 2018-08-09 00:00:00.000000000 Z
12
+ date: 2018-11-07 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rack
@@ -100,6 +100,7 @@ files:
100
100
  - lib/generators/cypress_dev/templates/spec/cypress/app_commands/clean.rb
101
101
  - lib/generators/cypress_dev/templates/spec/cypress/app_commands/eval.rb
102
102
  - lib/generators/cypress_dev/templates/spec/cypress/app_commands/factory_bot.rb
103
+ - lib/generators/cypress_dev/templates/spec/cypress/app_commands/log_fail.rb
103
104
  - lib/generators/cypress_dev/templates/spec/cypress/app_commands/scenarios/basic.rb
104
105
  - lib/generators/cypress_dev/templates/spec/cypress/cypress_helper.rb
105
106
  - lib/generators/cypress_dev/templates/spec/cypress/fixtures/example.json
@@ -165,6 +166,7 @@ files:
165
166
  - spec/integrations/rails_3_2/config/initializers/wrap_parameters.rb
166
167
  - spec/integrations/rails_3_2/config/locales/en.yml
167
168
  - spec/integrations/rails_3_2/config/routes.rb
169
+ - spec/integrations/rails_3_2/log/.keep
168
170
  - spec/integrations/rails_3_2/public/404.html
169
171
  - spec/integrations/rails_3_2/public/422.html
170
172
  - spec/integrations/rails_3_2/public/500.html
@@ -204,6 +206,7 @@ files:
204
206
  - spec/integrations/rails_4_2/config/locales/en.yml
205
207
  - spec/integrations/rails_4_2/config/routes.rb
206
208
  - spec/integrations/rails_4_2/config/secrets.yml
209
+ - spec/integrations/rails_4_2/log/.keep
207
210
  - spec/integrations/rails_4_2/public/404.html
208
211
  - spec/integrations/rails_4_2/public/422.html
209
212
  - spec/integrations/rails_4_2/public/500.html
@@ -257,6 +260,7 @@ files:
257
260
  - spec/integrations/rails_5_2/config/master.key
258
261
  - spec/integrations/rails_5_2/config/routes.rb
259
262
  - spec/integrations/rails_5_2/db/migrate/20180621085832_create_posts.rb
263
+ - spec/integrations/rails_5_2/log/.keep
260
264
  - spec/integrations/rails_5_2/public/404.html
261
265
  - spec/integrations/rails_5_2/public/422.html
262
266
  - spec/integrations/rails_5_2/public/500.html