dock_test 0.1.1 → 0.1.2

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: 6428ec4296e609ae46c0982e22596bf1eb73e7ae
4
- data.tar.gz: 34eedfb10543be92875c61c432dddf804a71aaaf
3
+ metadata.gz: 8df485fce515216c5708b86194832e7d86b4f86c
4
+ data.tar.gz: df50712cf65788a3abe2bbf4206bc7fa94325c4a
5
5
  SHA512:
6
- metadata.gz: 6ae1e4fb5dadb27b972499c2bca9ea639e88a456821ef39ab569ccd6973f27fa6ee6d3e32e721402c88cc64b0da90ac3453a54174faf250eb6b910e0d22a9074
7
- data.tar.gz: b4270bc7898e55ee98ecf4680e3171975b2aa3fe9244f92ef5fc51db4815e4223585a0d0078eeb4208a592a6d9c351b8bed3909855e37742bc6989c518c2cd3f
6
+ metadata.gz: 80d74479fa3106f0aaaa56a3a39a4e049dab36bf2306c9c5281b514a62ef18e0bc547c8f3d88cf5577907b15629733be3d834ac0288512af25c57edb155c1134
7
+ data.tar.gz: 0a43901742776345a2936b6d5534b0dd8b6d8774e2ee9951c435c678e6f6ff6559c37b43389b2b84d94ef3a3fe9e86cbf68ed469cdf9ff5fbae1485ae01f7d3e
data/README.md CHANGED
@@ -1,29 +1,69 @@
1
- # DockTest
1
+ # DockTest Gem
2
+ <img src="https://raw.githubusercontent.com/jackxxu/dock_test/master/dock_test_logo.jpeg" alt="DockTest Gem" align="right" height="300" width="320"/>
2
3
 
3
- TODO: Write a gem description
4
+ ### Description
4
5
 
5
- ## Installation
6
+ DockTest is an outside-in testing framework for ruby service api applications.
7
+
8
+ ### Features
9
+
10
+ Different from the popular [Rack::Test], DockTest focuses on just on service applications and tests 100% from outside.
11
+
12
+ 1. 100% end-to-end as it is based on HTTP requests/responses. When testing in local mode, it also racks up the local rack server.
13
+ 2. same tests can run for all deployment environments - development, test, staging, and production.
14
+ 3. environment-specific `skippy` setting to automatically skip tests with requests that create side-effects in production environments.
15
+ 4. focuses on service applications to strip out sessions, cookies, javascript, file uploads, and other browser-related features.
16
+ 5. provides custom assertions that are specific to api responses, including schema validation.
17
+ 6. same methods as [Rack::Test] for easy test reuse.
18
+
19
+ ### Sample Application
20
+
21
+ 1. [newark] app: [https://github.com/jackxxu/sample_dock_tested_app](https://github.com/jackxxu/sample_dock_tested_app)
22
+ 2. [grape] app: [https://github.com/jackxxu/grape_dock_tested_app](https://github.com/jackxxu/grape_dock_tested_app)
23
+ 3. [rails-api] app: [https://github.com/jackxxu/rails_api_dock_tested_app](https://github.com/jackxxu/rails_api_dock_tested_app)
24
+
25
+ ### Install
6
26
 
7
27
  Add this line to your application's Gemfile:
8
28
 
29
+ ```ruby
30
+ group :test do
9
31
  gem 'dock_test'
32
+ end
33
+ ```
10
34
 
11
35
  And then execute:
12
36
 
13
37
  $ bundle
14
38
 
15
- Or install it yourself as:
39
+ In your test helper file (often `test/test_helper.rb`), include the following DockTest configuration:
40
+
41
+ ```ruby
42
+ DockTest.configure do |c|
43
+ c.url = case ENV['DOCK_ENV']
44
+ when 'production'
45
+ 'http://vast-reaches-9635.herokuapp.com/' # your production service url
46
+ when ...
47
+ else
48
+ 'http://localhost:9871' # your local service url with abitary unbound port number
49
+ end
50
+ c.skippy = :production # in production mode, skip all the post, delete, put requests.
51
+ end
52
+ ```
53
+
54
+ Add `include DockTest::Methods` to give your integration tests access to all the verb test methods and also assertions.
55
+
56
+ Now you can excute your test collectively or individually, such as:
16
57
 
17
- $ gem install dock_test
58
+ $ bundle exec rake test
59
+ $ DOCK_ENV=product bundle exec rake test
18
60
 
19
- ## Usage
61
+ ### Assumptions
20
62
 
21
- TODO: Write usage instructions here
63
+ 1. when testing local application, a `config.ru` exists that can be used to `rackup` the server.
22
64
 
23
- ## Contributing
24
65
 
25
- 1. Fork it ( https://github.com/[my-github-username]/dock_test/fork )
26
- 2. Create your feature branch (`git checkout -b my-new-feature`)
27
- 3. Commit your changes (`git commit -am 'Add some feature'`)
28
- 4. Push to the branch (`git push origin my-new-feature`)
29
- 5. Create a new Pull Request
66
+ [Rack::Test]: https://github.com/brynary/rack-test
67
+ [newark]: https://github.com/mje113/newark
68
+ [grape]: https://github.com/intridea/grape
69
+ [rails-api]: https://github.com/rails-api/rails-api
Binary file
@@ -10,7 +10,7 @@ module DockTest
10
10
  skip_test_to_avoid_side_efforts
11
11
  end
12
12
 
13
- uri = URI.join(DockTest.url, path)
13
+ uri = URI.parse(full_url(DockTest.url, path))
14
14
 
15
15
  if DockTest.localhost?
16
16
  uri.port = DockTest.port
@@ -71,5 +71,12 @@ module DockTest
71
71
  def skip_test_to_avoid_side_efforts
72
72
  skip('this test is skipped in order to avoid potential side effects.')
73
73
  end
74
+
75
+ # cleanse and combine url and path to retrieve a valid full url
76
+ def full_url(url, path)
77
+ url = url[0..1] if url.end_with?('/')
78
+ path = path[1..-1] if path.start_with?('/')
79
+ "#{url}/#{path}"
80
+ end
74
81
  end
75
82
  end
@@ -1,3 +1,3 @@
1
1
  module DockTest
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dock_test
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jack Xu
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-07-22 00:00:00.000000000 Z
11
+ date: 2014-07-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: multi_json
@@ -95,6 +95,7 @@ files:
95
95
  - Rakefile
96
96
  - config.ru
97
97
  - dock_test.gemspec
98
+ - dock_test_logo.jpeg
98
99
  - lib/dock_test.rb
99
100
  - lib/dock_test/assertions.rb
100
101
  - lib/dock_test/dsl.rb