nonnative 0.1.0 → 0.2.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
  SHA256:
3
- metadata.gz: b01dea5ebaa9e2aa1d2d063048becc970754fe1a4a3ba54dd5714c36249d3ccd
4
- data.tar.gz: e3f5c4de9b55c8c57bee33aff57c3a37eaa8929cad2189c2b885f9694ed5414d
3
+ metadata.gz: 1ed669db2bc4d723a469ae8ce5676a01b126d42853fa0cc699750e401bd48c90
4
+ data.tar.gz: ef2ddf88fc1f44f443694bac824f95c8ae145520908735f5a64647d7d0201cd2
5
5
  SHA512:
6
- metadata.gz: d418eca36f02f59274be718dd49e6a9c29d1526fd085f3f33f38833ff48a436ce72144e51aba59347ed75769819a5944711111caa0fb0c5d3e6f4512965b7a56
7
- data.tar.gz: 69f9f4dc3f987245774ec0faf9175be5ec0e601cc14d9923270e3edf66f2561075cefd7fa637eed773886abce6721dfe0dae8f02e646e2e4348cb9311a748ea0
6
+ metadata.gz: 7839b3142b57d89d1f3de87cbb44b255497a08bcb59a039ac056af8626686cc96a893b2f0a9a6a16dbad80492ff16a50655f8a5189c14c4d9395ab40793fbebf
7
+ data.tar.gz: 7036322afd6219153aa0964d13138ed7ff6966f9b45cee76670138f0d10e1686d0c5ac0ddaadfc7abc6d770941a4a466b543d7ab2655b00042e63a86968829ee
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- nonnative (0.1.0)
4
+ nonnative (0.2.0)
5
5
  cucumber
6
6
  rspec-expectations
7
7
 
@@ -9,6 +9,7 @@ GEM
9
9
  remote: https://rubygems.org/
10
10
  specs:
11
11
  ast (2.4.0)
12
+ backport (1.1.1)
12
13
  backports (3.15.0)
13
14
  builder (3.2.3)
14
15
  cucumber (3.1.2)
@@ -29,14 +30,21 @@ GEM
29
30
  cucumber-wire (0.0.1)
30
31
  diff-lcs (1.3)
31
32
  gherkin (5.1.0)
33
+ htmlentities (4.3.4)
32
34
  jaro_winkler (1.5.3)
35
+ kramdown (1.17.0)
36
+ mini_portile2 (2.4.0)
33
37
  multi_json (1.13.1)
34
38
  multi_test (0.1.2)
39
+ nokogiri (1.10.3)
40
+ mini_portile2 (~> 2.4.0)
35
41
  parallel (1.17.0)
36
42
  parser (2.6.3.0)
37
43
  ast (~> 2.4.0)
38
44
  rainbow (3.0.0)
39
45
  rake (12.3.2)
46
+ reverse_markdown (1.1.0)
47
+ nokogiri
40
48
  rspec-expectations (3.8.4)
41
49
  diff-lcs (>= 1.2.0, < 2.0)
42
50
  rspec-support (~> 3.8.0)
@@ -49,7 +57,22 @@ GEM
49
57
  ruby-progressbar (~> 1.7)
50
58
  unicode-display_width (>= 1.4.0, < 1.7)
51
59
  ruby-progressbar (1.10.1)
60
+ solargraph (0.35.1)
61
+ backport (~> 1.1)
62
+ bundler (>= 1.17.2)
63
+ htmlentities (~> 4.3, >= 4.3.4)
64
+ jaro_winkler (~> 1.5)
65
+ kramdown (~> 1.16)
66
+ parser (~> 2.3)
67
+ reverse_markdown (~> 1.0, >= 1.0.5)
68
+ rubocop (~> 0.52)
69
+ thor (~> 0.19, >= 0.19.4)
70
+ tilt (~> 2.0)
71
+ yard (~> 0.9)
72
+ thor (0.20.3)
73
+ tilt (2.0.9)
52
74
  unicode-display_width (1.6.0)
75
+ yard (0.9.20)
53
76
 
54
77
  PLATFORMS
55
78
  ruby
@@ -59,6 +82,7 @@ DEPENDENCIES
59
82
  nonnative!
60
83
  rake
61
84
  rubocop
85
+ solargraph
62
86
 
63
87
  BUNDLED WITH
64
88
  1.17.2
data/README.md CHANGED
@@ -1,6 +1,16 @@
1
+ [![CircleCI](https://circleci.com/gh/alexfalkowski/nonnative.svg?style=svg)](https://circleci.com/gh/alexfalkowski/nonnative)
2
+
1
3
  # Nonnative
2
4
 
3
- Allows you to keep using the power of ruby to test other systems
5
+ Do you love building microservices using different languages?
6
+
7
+ Do you love testing applications using [cucumber](https://cucumber.io/) with [ruby](https://www.ruby-lang.org/en/)?
8
+
9
+ Well so do I. The issue is that most languages the cucumber implementation is not always complete or you have to write a lot of code to get it working.
10
+
11
+ So why not test the way you want and build the microservice how you want. These kind of tests will make sure your application is tested properly by going end-to-end.
12
+
13
+ The way it works is it spawns the process you configure and waits for it to start. Then you communicate with your microservice however you like (TCP, HTTP, gRPC, etc)
4
14
 
5
15
  ## Installation
6
16
 
@@ -20,30 +30,22 @@ Or install it yourself as:
20
30
 
21
31
  ## Usage
22
32
 
23
- Configure the system withh the process and how long we give to wait until it's ready
33
+ Configure nonnative with the process that you want to start, a timeout value and a port to verify it's working.
24
34
 
25
35
  ```ruby
26
36
  require 'nonnative'
27
37
 
28
38
  Nonnative.configure do |config|
29
39
  config.process = 'features/support/bin/start'
30
- config.wait = 0.5
40
+ config.timeout = 0.5
41
+ config.port = 12_321
31
42
  end
32
43
  ```
33
44
 
34
45
  Tag your cucumber scenarios with @nonnative
35
46
 
36
47
  ```cucumber
37
- @nonnative
38
48
  Scenario: Successful Response
39
49
  When we send "test" with the echo client
40
50
  Then we should receive a "test" response
41
51
  ```
42
-
43
- ## Development
44
-
45
- Look at the Makefile
46
-
47
- ## Contributing
48
-
49
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/nonnative.
@@ -3,6 +3,7 @@
3
3
  module Nonnative
4
4
  class Configuration
5
5
  attr_accessor :process
6
- attr_accessor :wait
6
+ attr_accessor :timeout
7
+ attr_accessor :port
7
8
  end
8
9
  end
@@ -1,9 +1,9 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- Before('@nonnative') do
3
+ Before do
4
4
  Nonnative.start
5
5
  end
6
6
 
7
- After('@nonnative') do
7
+ After do
8
8
  Nonnative.stop
9
9
  end
@@ -0,0 +1,37 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Nonnative
4
+ class Process
5
+ def initialize(configuration)
6
+ @configuration = configuration
7
+ end
8
+
9
+ def start
10
+ @child_pid = spawn(configuration.process)
11
+ return if port_open?
12
+
13
+ stop
14
+ raise Nonnative::Error, 'Could not start the process'
15
+ end
16
+
17
+ def stop
18
+ ::Process.kill('SIGHUP', child_pid)
19
+ end
20
+
21
+ private
22
+
23
+ attr_reader :configuration, :child_pid
24
+
25
+ def port_open?
26
+ Timeout.timeout(configuration.timeout) do
27
+ TCPSocket.new('127.0.0.1', configuration.port).close
28
+ true
29
+ rescue Errno::ECONNREFUSED, Errno::EHOSTUNREACH
30
+ sleep 0.01
31
+ retry
32
+ end
33
+ rescue Timeout::Error
34
+ false
35
+ end
36
+ end
37
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Nonnative
4
- VERSION = '0.1.0'
4
+ VERSION = '0.2.0'
5
5
  end
data/lib/nonnative.rb CHANGED
@@ -1,11 +1,15 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'socket'
4
+ require 'timeout'
5
+
3
6
  require 'cucumber'
4
7
 
5
8
  require 'nonnative/version'
6
9
  require 'nonnative/error'
7
10
  require 'nonnative/configuration'
8
11
  require 'nonnative/cucumber'
12
+ require 'nonnative/process'
9
13
 
10
14
  module Nonnative
11
15
  class << self
@@ -18,12 +22,12 @@ module Nonnative
18
22
  end
19
23
 
20
24
  def start
21
- @child_pid = spawn(configuration.process)
22
- sleep configuration.wait
25
+ @process ||= Nonnative::Process.new(configuration)
26
+ @process.start
23
27
  end
24
28
 
25
29
  def stop
26
- Process.kill('SIGHUP', @child_pid)
30
+ @process.stop
27
31
  end
28
32
  end
29
33
  end
data/nonnative.gemspec CHANGED
@@ -30,4 +30,5 @@ Gem::Specification.new do |spec|
30
30
  spec.add_development_dependency 'bundler'
31
31
  spec.add_development_dependency 'rake'
32
32
  spec.add_development_dependency 'rubocop'
33
+ spec.add_development_dependency 'solargraph'
33
34
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nonnative
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alex Falkowski
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-07-27 00:00:00.000000000 Z
11
+ date: 2019-08-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: cucumber
@@ -80,6 +80,20 @@ dependencies:
80
80
  - - ">="
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: solargraph
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
83
97
  description: Allows you to keep using the power of ruby to test other systems
84
98
  email:
85
99
  - alexrfalkowski@gmail.com
@@ -104,6 +118,7 @@ files:
104
118
  - lib/nonnative/configuration.rb
105
119
  - lib/nonnative/cucumber.rb
106
120
  - lib/nonnative/error.rb
121
+ - lib/nonnative/process.rb
107
122
  - lib/nonnative/version.rb
108
123
  - nonnative.gemspec
109
124
  homepage: https://github.com/alexfalkowski/nonnative