dock_test 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +53 -13
- data/dock_test_logo.jpeg +0 -0
- data/lib/dock_test/methods.rb +8 -1
- data/lib/dock_test/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8df485fce515216c5708b86194832e7d86b4f86c
|
4
|
+
data.tar.gz: df50712cf65788a3abe2bbf4206bc7fa94325c4a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
4
|
+
### Description
|
4
5
|
|
5
|
-
|
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
|
-
|
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
|
-
$
|
58
|
+
$ bundle exec rake test
|
59
|
+
$ DOCK_ENV=product bundle exec rake test
|
18
60
|
|
19
|
-
|
61
|
+
### Assumptions
|
20
62
|
|
21
|
-
|
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
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
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
|
data/dock_test_logo.jpeg
ADDED
Binary file
|
data/lib/dock_test/methods.rb
CHANGED
@@ -10,7 +10,7 @@ module DockTest
|
|
10
10
|
skip_test_to_avoid_side_efforts
|
11
11
|
end
|
12
12
|
|
13
|
-
uri = URI.
|
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
|
data/lib/dock_test/version.rb
CHANGED
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.
|
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-
|
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
|