watchdocs-rails 0.11.0 → 0.11.1

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
  SHA1:
3
- metadata.gz: 623cd0977c17c12f52dcb6d73669296483905b9b
4
- data.tar.gz: 25b282a6b8cb5cb0b969e6aed7265b22b0156ec9
3
+ metadata.gz: 3c9fb1e8ab7a57922c4fe9a91887f91fcb6a823d
4
+ data.tar.gz: dff08d2ed4c6fcbf6074125bed97330208824c96
5
5
  SHA512:
6
- metadata.gz: 0c19e929f480150be5276579d777247c472759e68abba1ff740e25820894c482aced4af0bc2d86e63e1761723c22bcf052568cb8141d1814629fe35617a63286
7
- data.tar.gz: f2860ed94519961867e5ec9fe329415684fe0a0d1cfaf87b347f98ed670016d2a932de6351c30bba187764612eaac13bc792e4b42a513bf192c46beb227c605e
6
+ metadata.gz: 1b2d9370b160061c26ddd88b8e72072732fdee4ecf9b5c11f12e1c707b1251739b3f6535da05057736c6e2a77cf9da2c9ed96c23a94754cf36cb9cc4be99d6c7
7
+ data.tar.gz: 387cea833226ed95d6419bfa8e0231cc255fa69b543b301ec949876277b3b2b487acd0be379aaa48267770fdb3c47e495fa0b61bff2c53333e055c6ef09f2fb9
data/README.md CHANGED
@@ -18,19 +18,27 @@ and run
18
18
  bundle
19
19
  ```
20
20
 
21
+ and then fire the installation script
22
+
23
+ ```
24
+ rails g watchdocs:install --app_id your_app_id --app_secret your_app_secret
25
+ ```
26
+
27
+ and your are good to go! Go to the usage section to for details.
28
+
29
+
21
30
  ## Configuration
22
31
 
23
- Create `config/initializers/watchdocs.rb` and configure the gem with your project credentials:
32
+ After running installation script you can change the configuration in `config/initializers/watchdocs.rb` which looks like that:
24
33
 
25
34
  ```ruby
26
35
  Watchdocs::Rails.configure do |c|
27
- c.app_id = 'YourAPPid'
28
- c.app_secret = 'YourAPPsecret'
36
+ c.app_id = 'your_app_id'
37
+ c.app_secret = 'your_app_secret'
29
38
  end
30
39
  ```
31
40
 
32
- You can get them from your project's Settings page.
33
- All configuration settings are listed below.
41
+ All configuration options are listed below.
34
42
 
35
43
  ### buffer_size
36
44
 
@@ -68,7 +76,9 @@ App Secret key which you can get for your Watchdocs project in settings section.
68
76
 
69
77
  You can enable Watchdocs to record request while executing specs or making manual tests. You can of course do both at the same time if you want.
70
78
 
71
- ### Tests
79
+ **NOTE:**: If you've fired installation script, you don't have to copy any code from this section as the script gracefully did it for you.
80
+
81
+ ### Specs
72
82
 
73
83
  If you have some requests specs or features specs that call JSON API then add this line to your `config/environments/test.rb`.
74
84
 
@@ -128,6 +138,13 @@ VCR.configure do |c|
128
138
  end
129
139
  ```
130
140
 
141
+ #### Running specs
142
+
143
+ Run your specs as usual. Watchdocs will let you know about recorderd API calls.
144
+
145
+ **NOTE:** Watchdocs doesn't work with controller specs as they don't actually make full reqests (that's why we don't recommend them). If you have controllers specs only don't worry and go to the next section to see how you can use Watchdocs in your project.
146
+
147
+
131
148
  ### Development (manual tests)
132
149
 
133
150
  If you don't have any request specs yet, you can add the following line to `config/environments/development.rb`.
@@ -30,8 +30,8 @@ module Watchdocs
30
30
  end
31
31
 
32
32
  def install_with_specs
33
- if yes?('Do you have any request specs? Would you like to use Watchdocs with them in test environment? [y,n]')
34
- application(nil, env: 'test') do
33
+ if yes?('Do you want to generate docs on your test run? (requires feature/request specs) [y,n]')
34
+ environment(nil, env: 'test') do
35
35
  'config.middleware.insert(0, Watchdocs::Rails::Middleware)'
36
36
  end
37
37
  if yes?(' Do you test with RSpec? [y,n]')
@@ -78,8 +78,8 @@ module Watchdocs
78
78
  end
79
79
 
80
80
  def install_with_runtime
81
- if yes?('Do you want to record your API endpoints in developent environment? [y,n]')
82
- application(nil, env: 'development') do
81
+ if yes?('Do you want to generate docs from your local API calls? (in development env) [y,n]')
82
+ environment(nil, env: 'development') do
83
83
  'config.middleware.insert(0, Watchdocs::Rails::Middleware)'
84
84
  end
85
85
  if yes?(' Do you use Procfile to run your app? [y,n]')
@@ -104,8 +104,31 @@ module Watchdocs
104
104
  END
105
105
  puts info.light_blue
106
106
  end
107
- puts 'Setup is completed. Now run your app and make some requests!
108
- Check app.watchdocs.io after a minute or so.'.green
107
+ puts 'Setup is completed. Now run your app and make some requests! Check app.watchdocs.io after a minute or so.'.green
108
+ end
109
+
110
+ private
111
+
112
+ def environment(data = nil, options = {})
113
+ sentinel = /class [a-z_:]+ < Rails::Application/i
114
+ env_file_sentinel = /\.configure do/
115
+ data = yield if !data && block_given?
116
+
117
+ in_root do
118
+ if options[:env].nil?
119
+ inject_into_file 'config/application.rb',
120
+ "\n #{data}",
121
+ after: sentinel,
122
+ verbose: false
123
+ else
124
+ Array(options[:env]).each do |env|
125
+ inject_into_file "config/environments/#{env}.rb",
126
+ "\n #{data}",
127
+ after: env_file_sentinel,
128
+ verbose: false
129
+ end
130
+ end
131
+ end
109
132
  end
110
133
  end
111
134
  end
@@ -1,5 +1,5 @@
1
1
  module Watchdocs
2
2
  module Rails
3
- VERSION = '0.11.0'
3
+ VERSION = '0.11.1'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: watchdocs-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.11.0
4
+ version: 0.11.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - mazikwyry
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-06-05 00:00:00.000000000 Z
11
+ date: 2017-06-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler