system_tester 0.2.5 → 0.3.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8b0fac5ad1140386d17a844f927d73a34e8bdd49
4
- data.tar.gz: 82d0ca4794470b7ed00d4279bc91420b81189c9c
3
+ metadata.gz: 19a1cef419a93ad63e94fe903e7dbfcfaa9383d2
4
+ data.tar.gz: 85cfe13344fd10b969c47294f3df282291001808
5
5
  SHA512:
6
- metadata.gz: 0e3e6e4d5b5e36e9a5ea79de9e2f62283ffe2f3b3229325487c4721bbad76dd8350ed69723106213cc49167a3bb0f8fb72ab653d5db232cd9a6654e70fd1bbfa
7
- data.tar.gz: 1be44430ff8da32004725332b518e6501a6e874b2fcbe03128abb9dd918a693478591c99993c431fe1d392da6725bd151462eeac57b346fb00f98ec1ad775f8c
6
+ metadata.gz: 280cbc5f15ce8d5c4110bcd9d7375a7112fe79c75d3f70e25dc78baf7da37ba4ec25308068ae9901dea9259ee46d2a8201c3c44656331a0daa03979a1c273105
7
+ data.tar.gz: 9302e284ce8181fcf6db2389e3912f7af14ebd676436a58dece8977f4679444035acf64de3fd6af42e8ab3d0e929be6433ceb30650628988e6bc10491d7d6f09
@@ -0,0 +1,4 @@
1
+ module ApplicationCable
2
+ class Channel < ActionCable::Channel::Base
3
+ end
4
+ end
@@ -0,0 +1,4 @@
1
+ module ApplicationCable
2
+ class Connection < ActionCable::Connection::Base
3
+ end
4
+ end
@@ -0,0 +1,7 @@
1
+ module SystemTester
2
+ class ExecutionChannel < ApplicationCable::Channel
3
+ def subscribed
4
+ stream_from "system_tester_execution"
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,22 @@
1
+ module SystemTester
2
+ class ExecutionsController < ApplicationController
3
+ def create
4
+ feature = params[:feature_id].present? ? Feature.find(params[:feature_id]) : nil
5
+ scenario = params[:scenario_id].present? ? Scenario.find(params[:scenario_id]) : nil
6
+ @cmd = feature.present? ? "bin/rails test #{feature.full_file}" : "bin/rails test #{scenario.feature.full_file}:#{scenario.line_number}"
7
+ status = handle_command
8
+ render json: {exit_code: status}
9
+ end
10
+
11
+ private
12
+
13
+ def handle_command
14
+ command_handler = CommandHandler.new(@cmd)
15
+ position = 0
16
+ command_handler.run_each_line do |char|
17
+ ActionCable.server.broadcast "system_tester_execution", {output: char, position: position}
18
+ position += 1
19
+ end
20
+ end
21
+ end
22
+ end
@@ -31,6 +31,10 @@ module SystemTester
31
31
  delete_file
32
32
  end
33
33
 
34
+ def full_file
35
+ File.join(base_path, file_name)
36
+ end
37
+
34
38
  private
35
39
 
36
40
  def test_path
@@ -41,10 +45,6 @@ module SystemTester
41
45
  File.join(test_path, base_dir)
42
46
  end
43
47
 
44
- def full_file
45
- File.join(base_path, file_name)
46
- end
47
-
48
48
  def old_file
49
49
  File.join(base_path, file_name_was)
50
50
  end
@@ -13,7 +13,3 @@ module SystemTester
13
13
  end
14
14
  end
15
15
  end
16
-
17
- %w(click_on fill_in visit).each do |dep|
18
- require_dependency "system_tester/#{dep}"
19
- end
@@ -13,7 +13,3 @@ module SystemTester
13
13
  end
14
14
  end
15
15
  end
16
-
17
- %w(assert_text assert_selector).each do |dep|
18
- require_dependency "system_tester/#{dep}"
19
- end
@@ -0,0 +1,44 @@
1
+ require 'pty'
2
+ module SystemTester
3
+ class CommandHandler
4
+ attr_reader :status
5
+ def initialize(cmd)
6
+ @cmd = cmd
7
+ @status = nil
8
+ end
9
+
10
+ def run(&block)
11
+ pty do |r,w,pid|
12
+ rescue_errno pid do
13
+ yield r.getc until r.eof?
14
+ end
15
+ end
16
+ end
17
+
18
+ def run_each_line(&block)
19
+ pty do |r,w,pid|
20
+ rescue_errno pid do
21
+ r.each do |line|
22
+ yield line
23
+ end
24
+ end
25
+ end
26
+ end
27
+
28
+ private
29
+
30
+ def pty(&block)
31
+ PTY.spawn(@cmd, &block)
32
+ @status = $?.exitstatus
33
+ end
34
+
35
+ def rescue_errno(pid, &block)
36
+ begin
37
+ yield
38
+ rescue Errno::EIO
39
+ ensure
40
+ Process.wait pid
41
+ end
42
+ end
43
+ end
44
+ end
@@ -23,6 +23,11 @@ module SystemTester
23
23
  str << close
24
24
  str
25
25
  end
26
+
27
+ def line_number
28
+ lines = feature.to_s.split("\n")
29
+ lines.index { |line| open.chomp === line } + 1
30
+ end
26
31
 
27
32
  private
28
33
 
@@ -1,4 +1,5 @@
1
1
  SystemTester::Engine.routes.draw do
2
+ mount ActionCable.server => '/cable'
2
3
  resources :features, only: [:index, :create, :update, :destroy], :defaults => {:format => :json}
3
4
  resources :scenarios, only: [:index, :show, :create, :update, :destroy], :defaults => {:format => :json}
4
5
  resources :steps, only: [:index, :show, :new, :create, :update, :destroy], :defaults => {:format => :json}
@@ -10,4 +11,5 @@ SystemTester::Engine.routes.draw do
10
11
  end
11
12
  end
12
13
  resources :status, only: [:index], :defaults => {:format => :json}
14
+ resources :executions, only: [:create]
13
15
  end
@@ -12,6 +12,8 @@ module SystemTester
12
12
  :methods => [:get, :post, :delete, :put, :patch, :options, :head]
13
13
  end
14
14
  end
15
+
16
+ app.config.action_cable.allowed_request_origins = ['chrome-extension://ebpjncfolmfiiphibdajgblbchkklbcf', 'http://localhost:8080']
15
17
  end
16
18
 
17
19
  config.to_prepare do
@@ -1,3 +1,3 @@
1
1
  module SystemTester
2
- VERSION = '0.2.5'
2
+ VERSION = '0.3.0'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: system_tester
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.5
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Richard LaFranchi
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-07-11 00:00:00.000000000 Z
11
+ date: 2017-07-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -105,7 +105,11 @@ files:
105
105
  - MIT-LICENSE
106
106
  - README.md
107
107
  - Rakefile
108
+ - app/channels/application_cable/channel.rb
109
+ - app/channels/application_cable/connection.rb
110
+ - app/channels/system_tester/execution_channel.rb
108
111
  - app/controllers/system_tester/application_controller.rb
112
+ - app/controllers/system_tester/executions_controller.rb
109
113
  - app/controllers/system_tester/features_controller.rb
110
114
  - app/controllers/system_tester/scenario_steps_controller.rb
111
115
  - app/controllers/system_tester/scenarios_controller.rb
@@ -122,6 +126,7 @@ files:
122
126
  - app/models/system_tester/assert_text.rb
123
127
  - app/models/system_tester/assertion.rb
124
128
  - app/models/system_tester/click_on.rb
129
+ - app/models/system_tester/command_handler.rb
125
130
  - app/models/system_tester/feature.rb
126
131
  - app/models/system_tester/fill_in.rb
127
132
  - app/models/system_tester/scenario.rb