goodall 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ YzA5NTMzYTExNzgxNmNkODAyZWE2ZTY5OTI2NTA0NzgxOGUwNWI0YQ==
5
+ data.tar.gz: !binary |-
6
+ NjBkZTI1ODFlNTNiNWYwYzk4ZjJkOWY3ZDUwMzY5ZTgxZjAxZWJhMA==
7
+ SHA512:
8
+ metadata.gz: !binary |-
9
+ Y2JkMGI2MmM0NDcxZDU4Yzg3ZjAyYjMxZDViYWQ3MGM3OWJmZjkyNTFmZWY3
10
+ N2U0MDc2NTNmZWJiMDBhZDc1MmYzMjA1ZTFkODkxMzllODM1YmU0NTYxZjFm
11
+ NTA3OWVmOTI0ZGEyNzZkOTM1Mzg4ZmMxZDE1N2JmNzk0ZmQ4MjI=
12
+ data.tar.gz: !binary |-
13
+ YWQ2YmEwOWVhZjVjNjkwNGZiMTllYTM1MWFmZTQwNGQ2OGYyYmViZDkwZDg3
14
+ ODdlNDY0YTE2ZTczNWU1MjRkNzkwMzMyNDE1NmMzYWVlMWM4NjZiMmEwODcx
15
+ MWEzOGY4Y2IxYzU2YjIyMWQ2M2FhMGVjNGZhMmYzMzE5NjFlNDA=
data/.gitignore CHANGED
@@ -1,3 +1,6 @@
1
+ .rvmrc
2
+ .ruby-version
3
+ .ruby-gemset
1
4
  *.gem
2
5
  *.rbc
3
6
  .bundle
data/README.md CHANGED
@@ -143,6 +143,18 @@ The steps "I get (.+)" and "the response should be valid json" are steps I
143
143
  will use in almost every scenario, so it is the perfect place for the Goodall
144
144
  calls. Using Goodall in these frequently used steps is key for ease-of-use.
145
145
 
146
+ You can tell Goodall to not document a cucumber scenario by using the
147
+ `@dont-document` tag:
148
+
149
+ ```Gherkin
150
+ Scenario: this will be documented
151
+ Given some steps
152
+
153
+ @dont-document
154
+ Scenario: this will not be documented
155
+ Given some steps
156
+ ```
157
+
146
158
  _IMPORTANT NOTE_: Using the cucumber helpers, Goodall will NOT log unless
147
159
  executed via the rake task "rake cucumber:document". To force Goodall to
148
160
  log, please set the environment variable 'ENABLE_GOODALL' to a non-nil
@@ -240,7 +252,7 @@ automatically set the output file and triggers the tests.
240
252
 
241
253
  ```ruby
242
254
  # Rakefile
243
- require 'goodall/rake_task'
255
+ require 'goodall/rake_task' if %w[development test].include? Rails.env
244
256
  ```
245
257
 
246
258
  This unlocks the following rake commands:
data/lib/goodall.rb CHANGED
@@ -9,6 +9,7 @@ class Goodall
9
9
  include Singleton
10
10
 
11
11
  @@enabled = false #:nodoc:
12
+ @@skipping = false #:nodoc:
12
13
  @@output_path = './api_docs.txt' #:nodoc:
13
14
  @@registered_handlers = {} #:nodoc:
14
15
 
@@ -47,6 +48,26 @@ class Goodall
47
48
  self.enabled = false
48
49
  end
49
50
 
51
+ # Flag to denote that documenting temporarily disabled?
52
+ def self.skipping?
53
+ @@skipping
54
+ end
55
+
56
+ # Enable the temporarily disable documenting flag
57
+ def self.skipping_on!
58
+ self.skipping = true
59
+ end
60
+
61
+ # Disable the temporarily disable documenting flag
62
+ def self.skipping_off!
63
+ self.skipping = false
64
+ end
65
+
66
+ # set the skipping value explicity
67
+ def self.skipping=(val)
68
+ @@skipping=!!val
69
+ end
70
+
50
71
  # write to the currently open output file
51
72
  def self.write(str)
52
73
  writer.write(str) if enabled?
@@ -58,7 +79,7 @@ class Goodall
58
79
  # * +:path+ - a string of the path (URL/URI) of the request
59
80
  # * +:payload+ - the parameters sent, e.g. post body. Usually a hash.
60
81
  def self.document_request(method, path, payload=nil)
61
- return unless enabled?
82
+ return unless should_document?
62
83
 
63
84
  str = "#{method.to_s.upcase}: #{path}"
64
85
 
@@ -75,7 +96,7 @@ class Goodall
75
96
  #
76
97
  # * +:payload - the data returned from the request, e.g. response.body. `payload` will be run through the current handler and be pretty-printed to the output file.
77
98
  def self.document_response(payload, status=nil)
78
- return unless enabled?
99
+ return unless should_document?
79
100
 
80
101
  if payload
81
102
  payload = current_handler.parse_payload(payload)
@@ -127,6 +148,11 @@ class Goodall
127
148
  @@registered_handlers.map{|k,v| [k,v]}
128
149
  end
129
150
 
151
+ # Is goodall enabled and are NOT in skipping mode?
152
+ def self.should_document?
153
+ enabled? && !skipping?
154
+ end
155
+
130
156
  private
131
157
 
132
158
  def self.current_handler
@@ -2,6 +2,14 @@ require 'goodall'
2
2
  require 'goodall/command_line_enable'
3
3
 
4
4
  Before do |scenario|
5
+
6
+ # skip scenarios that have the '@dont-document' tag
7
+ if scenario.source_tags.map(&:name).include?('@dont-document')
8
+ Goodall.skipping_on!
9
+ end
10
+
11
+ next if Goodall.skipping?
12
+
5
13
  if scenario.feature != $current_feature
6
14
  $current_feature = scenario.feature
7
15
  Goodall.write("\n")
@@ -10,4 +18,8 @@ Before do |scenario|
10
18
  Goodall.write("\n")
11
19
  Goodall.write("Scenario: #{scenario.name}")
12
20
  Goodall.write("\n")
21
+ end
22
+
23
+ After do |scenario|
24
+ Goodall.skipping_off! if Goodall.skipping?
13
25
  end
@@ -1,3 +1,3 @@
1
1
  class Goodall
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
@@ -16,6 +16,7 @@ describe Goodall do
16
16
 
17
17
  after(:each) do
18
18
  Goodall.disable
19
+ Goodall.skipping_off!
19
20
  end
20
21
 
21
22
  describe ".output_path" do
@@ -42,6 +43,19 @@ describe Goodall do
42
43
  end
43
44
  end
44
45
 
46
+ describe ".skipping?" do
47
+ it "must be true if goodall is in skipping mode" do
48
+ klass.skipping_on!
49
+
50
+ expect(klass.skipping?).to be_true
51
+ end
52
+ it "must be false if goodall is in not skipping mode" do
53
+ klass.skipping_off!
54
+
55
+ expect(klass.skipping?).to be_false
56
+ end
57
+ end
58
+
45
59
  describe ".write" do
46
60
  context "Goodall is enabled" do
47
61
  before(:each) { klass.enable; }
@@ -217,4 +231,37 @@ describe Goodall do
217
231
  end
218
232
  end
219
233
  end
234
+
235
+ describe ".should_document?" do
236
+
237
+ context "enabled is true" do
238
+ before(:each) { klass.enable }
239
+
240
+ context "skipping is false" do
241
+ before(:each) { klass.skipping=false }
242
+
243
+ it "should be true" do
244
+ expect(klass.should_document?).to be_true
245
+ end
246
+ end
247
+
248
+ context "skipping is true" do
249
+ before(:each) { klass.skipping=true }
250
+
251
+ it "should be false" do
252
+ expect(klass.should_document?).to be_false
253
+ end
254
+ end
255
+
256
+ end
257
+
258
+ context "enabled is false" do
259
+ before(:each) { klass.disable }
260
+
261
+ it "should be false" do
262
+ expect(klass.should_document?).to be_false
263
+ end
264
+ end
265
+
266
+ end
220
267
  end
metadata CHANGED
@@ -1,20 +1,18 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: goodall
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
5
- prerelease:
4
+ version: 0.0.4
6
5
  platform: ruby
7
6
  authors:
8
7
  - Matthew Nielsen
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-09-04 00:00:00.000000000 Z
11
+ date: 2013-11-06 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: multi_json
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
17
  - - ! '>='
20
18
  - !ruby/object:Gem::Version
@@ -22,7 +20,6 @@ dependencies:
22
20
  type: :runtime
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
24
  - - ! '>='
28
25
  - !ruby/object:Gem::Version
@@ -30,7 +27,6 @@ dependencies:
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: tolerate_json
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
31
  - - ! '>='
36
32
  - !ruby/object:Gem::Version
@@ -38,7 +34,6 @@ dependencies:
38
34
  type: :runtime
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
38
  - - ! '>='
44
39
  - !ruby/object:Gem::Version
@@ -46,7 +41,6 @@ dependencies:
46
41
  - !ruby/object:Gem::Dependency
47
42
  name: bundler
48
43
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
44
  requirements:
51
45
  - - ~>
52
46
  - !ruby/object:Gem::Version
@@ -54,7 +48,6 @@ dependencies:
54
48
  type: :development
55
49
  prerelease: false
56
50
  version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
51
  requirements:
59
52
  - - ~>
60
53
  - !ruby/object:Gem::Version
@@ -62,7 +55,6 @@ dependencies:
62
55
  - !ruby/object:Gem::Dependency
63
56
  name: rake
64
57
  requirement: !ruby/object:Gem::Requirement
65
- none: false
66
58
  requirements:
67
59
  - - ! '>='
68
60
  - !ruby/object:Gem::Version
@@ -70,7 +62,6 @@ dependencies:
70
62
  type: :development
71
63
  prerelease: false
72
64
  version_requirements: !ruby/object:Gem::Requirement
73
- none: false
74
65
  requirements:
75
66
  - - ! '>='
76
67
  - !ruby/object:Gem::Version
@@ -78,7 +69,6 @@ dependencies:
78
69
  - !ruby/object:Gem::Dependency
79
70
  name: rspec
80
71
  requirement: !ruby/object:Gem::Requirement
81
- none: false
82
72
  requirements:
83
73
  - - ! '>='
84
74
  - !ruby/object:Gem::Version
@@ -86,7 +76,6 @@ dependencies:
86
76
  type: :development
87
77
  prerelease: false
88
78
  version_requirements: !ruby/object:Gem::Requirement
89
- none: false
90
79
  requirements:
91
80
  - - ! '>='
92
81
  - !ruby/object:Gem::Version
@@ -102,7 +91,6 @@ extra_rdoc_files: []
102
91
  files:
103
92
  - .gitignore
104
93
  - .rspec
105
- - .rvmrc
106
94
  - .travis.yml
107
95
  - Gemfile
108
96
  - LICENSE.txt
@@ -128,27 +116,26 @@ files:
128
116
  homepage: http://github.com/xunker/goodall
129
117
  licenses:
130
118
  - MIT
119
+ metadata: {}
131
120
  post_install_message:
132
121
  rdoc_options: []
133
122
  require_paths:
134
123
  - lib
135
124
  required_ruby_version: !ruby/object:Gem::Requirement
136
- none: false
137
125
  requirements:
138
126
  - - ! '>='
139
127
  - !ruby/object:Gem::Version
140
128
  version: '0'
141
129
  required_rubygems_version: !ruby/object:Gem::Requirement
142
- none: false
143
130
  requirements:
144
131
  - - ! '>='
145
132
  - !ruby/object:Gem::Version
146
133
  version: '0'
147
134
  requirements: []
148
135
  rubyforge_project:
149
- rubygems_version: 1.8.25
136
+ rubygems_version: 2.1.10
150
137
  signing_key:
151
- specification_version: 3
138
+ specification_version: 4
152
139
  summary: Goodall provides an easy interface for documenting your API while you write
153
140
  your tests. It is compatible with Rspec, Cucumber and test-unit, as well as others.
154
141
  Goodall is named after Jane Goodall who has spent her life observing and documenting
data/.rvmrc DELETED
@@ -1,3 +0,0 @@
1
- rvm --create use 1.9.3@goodall
2
- #rvm --create use ree@goodall
3
- #rvm --create use 2.0.0@goodall