capybara_spa 0.2.0 → 0.3.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: 255f4a684ee49123f2acbe5abc15309f68f513bcc3ac8186c0bdab0b5b1af330
4
- data.tar.gz: 6b942d330af15b3fb6f450c6254498c16e4b5cfffbe836f935d1ac556c9d52c5
3
+ metadata.gz: 19ed7589902a6d0325189f481b625b7b51c76f69e1db77007908d782ec8f8284
4
+ data.tar.gz: 5e3812be9fffb593695a0c29b3aa989a9d0930410883bb8040f062a308b41b64
5
5
  SHA512:
6
- metadata.gz: 3bb18b51fb30a17043685808c1405a0b0ae67b02bd2adfebeca5197376bf7889867b1f991d9b40fa37f01aa6c14a7c6c311945bf72ae107c7a437e22fce9733e
7
- data.tar.gz: 0ec570c654aa125d6c2fb1e0aa25a126d09c3950d7d4e11ad4067cdd208ace99502bd23d2d5b7521d20696b5c1e17c9650c17eef91b5ec0c0c3a673a00739a17
6
+ metadata.gz: 8dfff66e5fd86435ff0daa5f1786d537fb581c55d588923b7d373811d0fa4426567072134d8ad82c621fc5f514ae9b3e8e61fd86f55348b05784f665a7f2c45e
7
+ data.tar.gz: 9c2b0307ddb544cb7745cc9922ea7ec78a435f1cc4cc9c74bd1a34e480a9faad08ac7561a6d46cf6f608c8e2ac73801e6f04dc082b7e10d408bc100196352d2e
@@ -1,5 +1,62 @@
1
- sudo: false
2
- language: ruby
1
+ language: node_js
2
+ sudo: required
3
+ node_js:
4
+ - '9.11.1'
3
5
  rvm:
4
6
  - 2.4.1
5
- before_install: gem install bundler -v 1.16.1
7
+
8
+ addons:
9
+ apt:
10
+ sources:
11
+ - google-chrome
12
+ packages:
13
+ - google-chrome-stable
14
+
15
+ cache:
16
+ bundler: true
17
+ directories:
18
+ - /home/travis/.rvm/
19
+ - spec/angular-app
20
+
21
+ cache: bundler
22
+
23
+ before_install:
24
+ - wget http://chromedriver.storage.googleapis.com/2.38/chromedriver_linux64.zip
25
+ - unzip chromedriver_linux64.zip
26
+ - rm chromedriver_linux64.zip
27
+ - sudo mv -f chromedriver /usr/local/bin/
28
+ - sudo chmod +x /usr/local/bin/chromedriver
29
+ - google-chrome-stable --headless --no-sandbox
30
+
31
+ - gem install bundler -v 1.16.1
32
+ - ruby --version
33
+ - rvm --version
34
+ - bundle --version
35
+ - gem --version
36
+
37
+ - pwd
38
+ - ls
39
+
40
+ install:
41
+
42
+ before_script:
43
+ - bundle install
44
+
45
+ - cd spec/angular-app && npm install && cd ../../
46
+ - export DISPLAY=:99.0
47
+ - sh -e /etc/init.d/xvfb start
48
+ - sleep 1
49
+
50
+ script:
51
+ - HEADLESS=true bundle exec rspec spec
52
+
53
+ after_success:
54
+
55
+ after_failure:
56
+
57
+ after_script:
58
+
59
+ branches:
60
+
61
+ notifications:
62
+ email: false
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- capybara_spa (0.1.0)
4
+ capybara_spa (0.3.0)
5
5
  capybara (~> 3.0)
6
6
 
7
7
  GEM
@@ -11,6 +11,7 @@ GEM
11
11
  public_suffix (>= 2.0.2, < 4.0)
12
12
  archive-zip (0.11.0)
13
13
  io-like (~> 0.3.0)
14
+ bump (0.6.0)
14
15
  byebug (10.0.2)
15
16
  capybara (3.0.3)
16
17
  addressable
@@ -75,6 +76,7 @@ PLATFORMS
75
76
  ruby
76
77
 
77
78
  DEPENDENCIES
79
+ bump (~> 0.6.0)
78
80
  bundler (~> 1.16)
79
81
  capybara_spa!
80
82
  chromedriver-helper (~> 1.2)
@@ -31,6 +31,7 @@ Gem::Specification.new do |spec|
31
31
  spec.require_paths = ["lib"]
32
32
 
33
33
  spec.add_dependency "capybara", "~> 3.0"
34
+ spec.add_development_dependency "bump", "~> 0.6.0"
34
35
  spec.add_development_dependency "bundler", "~> 1.16"
35
36
  spec.add_development_dependency "rake", "~> 10.0"
36
37
  spec.add_development_dependency "rspec", "~> 3.0"
@@ -11,7 +11,7 @@ module CapybaraSpa
11
11
  end
12
12
 
13
13
  self.app_tag = ENV.fetch('NG_APP_TAG', 'app-root')
14
- self.log_file = ENV.fetch('NG_LOG_FILE', '/dev/null')
14
+ self.log_file = ENV.fetch('NG_LOG_FILE', STDOUT)
15
15
 
16
16
  module Server
17
17
  end
@@ -23,8 +23,9 @@ module CapybaraSpa
23
23
  attr_accessor :build_path, :http_server_bin_path, :log_file, :pid_file, :port
24
24
  attr_accessor :pid
25
25
 
26
- def initialize(build_path:, http_server_bin_path: nil, log_file: CapybaraSpa.log_file, pid_file: nil, port: nil)
27
- @build_path = build_path || ENV.fetch('NG_BUILD_PATH', nil)
26
+ def initialize(build_path: nil, http_server_bin_path: nil, log_file: CapybaraSpa.log_file, pid_file: nil, port: nil)
27
+ build_path ||= ENV.fetch('NG_BUILD_PATH', nil)
28
+ @build_path = File.expand_path(build_path) if build_path
28
29
  @http_server_bin_path = http_server_bin_path || ENV.fetch('NG_HTTP_SERVER_BIN') { find_http_server_bin_path }
29
30
  @log_file = log_file
30
31
  @pid_file = pid_file || ENV.fetch('NG_PID_FILE', '/tmp/angular-process.pid')
@@ -46,7 +47,7 @@ module CapybaraSpa
46
47
  check_requirements!
47
48
 
48
49
  @pid = fork do
49
- STDOUT.reopen(@log_file)
50
+ STDOUT.reopen(@log_file) unless @log_file == STDOUT
50
51
  run_server
51
52
  end
52
53
  File.write(pid_file, pid)
@@ -58,7 +59,7 @@ module CapybaraSpa
58
59
  def stop
59
60
  if File.exist?(pid_file)
60
61
  pid = File.read(pid_file).to_i
61
- puts "capybara-angular/angular-http-server:parent#at_exit sending SIGTERM to pid: #{pid}" if ENV['DEBUG']
62
+ puts "capybara_spa/angular-http-server:parent#at_exit sending SIGTERM to pid: #{pid}" if ENV['DEBUG']
62
63
  begin
63
64
  Process.kill 'SIGTERM', pid
64
65
  Process.wait pid
@@ -66,12 +67,12 @@ module CapybaraSpa
66
67
  # no-op, the child process does not exist
67
68
  end
68
69
 
69
- puts "capybara-angular/angular-http-server removing pid_file: #{pid_file}" if ENV['DEBUG']
70
+ puts "capybara_spa/angular-http-server removing pid_file: #{pid_file}" if ENV['DEBUG']
70
71
  FileUtils.rm pid_file
71
72
  @started = false
72
73
  true
73
74
  else
74
- puts "capybara-angular/angular-http-server did not find pid_file, no process to SIGHUP: #{pid_file}" if ENV['DEBUG']
75
+ puts "capybara_spa/angular-http-server did not find pid_file, no process to SIGHUP: #{pid_file}" if ENV['DEBUG']
75
76
  false
76
77
  end
77
78
  end
@@ -85,7 +86,6 @@ module CapybaraSpa
85
86
 
86
87
  def check_executable_requirements!
87
88
  executable_name = File.basename(http_server_bin_path)
88
-
89
89
  if File.exist?(http_server_bin_path)
90
90
  if !File.executable?(http_server_bin_path)
91
91
  raise NgHttpServerNotExecutable, 'File found, but not executable!'
@@ -125,32 +125,47 @@ module CapybaraSpa
125
125
  # if no http-server found in default PATH then try to find it in node_modules
126
126
  if http_server_bin_path.length == 0
127
127
  http_server_bin_path = File.join(node_modules_path, '.bin', 'angular-http-server')
128
+ else
128
129
  end
129
130
 
130
- http_server_bin_path
131
+ File.expand_path(http_server_bin_path) if http_server_bin_path
132
+ end
133
+
134
+ def node_modules_path
135
+ cwd = ''
136
+ loop do
137
+ path = File.expand_path File.join(build_path, cwd, 'node_modules')
138
+ if Dir.exist?(path)
139
+ return path
140
+ elsif File.expand_path(path) == '/node_modules'
141
+ raise NodeModulesDirectoryNotFound, 'Cannot find "node_modules" directory. Walked all the way to the root "/"!'
142
+ else
143
+ cwd = File.join '..', cwd
144
+ end
145
+ end
131
146
  end
132
147
 
133
148
  def run_server
134
149
  build_dir = File.dirname(build_path)
135
150
  Dir.chdir(build_dir) do
136
151
  cmd = "#{http_server_bin_path} -p #{port} --path #{File.basename(build_path)}"
137
- puts "capybara-angular/angular-http-server is executing command: #{cmd}" # if ENV['DEBUG']
152
+ puts "capybara_spa/angular-http-server is executing command: #{cmd}" if ENV['DEBUG']
138
153
  spawn_cmd(cmd)
139
154
  end
140
155
  end
141
156
 
142
157
  def spawn_cmd(cmd)
143
- puts "capybara-angular/angular-http-server is executing command: #{cmd}" if ENV['DEBUG']
158
+ puts "capybara_spa/angular-http-server is executing command: #{cmd}" if ENV['DEBUG']
144
159
 
145
160
  # use spawn(cmd, arg1, ... ) version to avoid launching a shell that launches the
146
161
  # http-server or ng process. We want this pid to be the actual process to kill when
147
162
  # this program is done exiting.
148
163
  pid = spawn *cmd.split(/\s+/)
149
164
 
150
- puts "capybara-angular/angular-http-server:forked child with pid: #{pid}" if ENV['DEBUG']
165
+ puts "capybara_spa/angular-http-server:forked child with pid: #{pid}" if ENV['DEBUG']
151
166
 
152
167
  at_exit do
153
- puts "capybara-angular/angular-http-server:forked#at_exit is sending SIGTERM signal to pid: #{pid}" if ENV['DEBUG']
168
+ puts "capybara_spa/angular-http-server:forked#at_exit is sending SIGTERM signal to pid: #{pid}" if ENV['DEBUG']
154
169
  begin
155
170
  Process.kill 'TERM', pid
156
171
  Process.wait pid
@@ -1,3 +1,3 @@
1
1
  module CapybaraSpa
2
- VERSION = "0.2.0"
2
+ VERSION = "0.3.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: capybara_spa
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Zach Dennis
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-05-07 00:00:00.000000000 Z
11
+ date: 2018-05-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: capybara
@@ -24,6 +24,20 @@ dependencies:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '3.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bump
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: 0.6.0
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: 0.6.0
27
41
  - !ruby/object:Gem::Dependency
28
42
  name: bundler
29
43
  requirement: !ruby/object:Gem::Requirement