autogen_rspec 0.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (2) hide show
  1. data/lib/autogen_rspec.rb +43 -0
  2. metadata +46 -0
@@ -0,0 +1,43 @@
1
+ module AutogenSpec
2
+
3
+ def self.log_test
4
+ begin
5
+ f = File.open('tmp/test.txt','a')
6
+ temp = ''
7
+
8
+ str = "it 'should ' do \n"
9
+ str = str + "\n# cookies #{cookies.inspect} \n"
10
+ if request.env['REQUEST_METHOD'] == 'GET' or request.env['REQUEST_METHOD'] == 'DELETE'
11
+ str = str + "#{request.env['REQUEST_METHOD'].downcase} '#{request.env['REQUEST_URI']}',{'HTTP_ACCEPT' => '#{request.env['HTTP_ACCEPT']}'} \n"
12
+ else
13
+ temp = ap(CGI.unescape(request.raw_post)) rescue ''
14
+ str = str + "\n# req = " + temp.to_s + "\n\n"
15
+
16
+ temp = ap(JSON.parse(CGI.unescape(request.raw_post))) rescue ''
17
+ str = str + "\n# " + temp.to_s + "\n\n"
18
+
19
+ str = str + "#{request.env['REQUEST_METHOD'].downcase} '#{request.env['REQUEST_URI']}',CGI.escape(req),{'HTTP_ACCEPT' => '#{request.env['HTTP_ACCEPT']}'} \n"
20
+ end
21
+
22
+ str = str + "assert_equal #{status},status,@response.body \n"
23
+ str = str + "assert_equal '#{response.content_type}', @response.content_type \n"
24
+
25
+ if response.content_type == 'application/json'
26
+ resp_hash = JSON.parse(response.body)
27
+ keys = ap resp_hash.keys, {:index => false}
28
+ str = str + 'resp_hash = JSON.parse(response.body)' + "\n"
29
+ str = str + keys.inspect + '.each {|x| assert_equal true,resp_hash.has_key?(x),"Did not find key \#{x} in json"}' + "\n"
30
+ else
31
+ # str = str + "assert_equal #{response.body},@response.body\n"
32
+ end
33
+ str = str + "end\n"
34
+
35
+ rescue Exception => e
36
+ str = "Logging test error ... #{e}, #{e.backtrace}"
37
+ end
38
+
39
+ f.write("\n\n#{str}")
40
+ f.fsync
41
+ end
42
+
43
+ end
metadata ADDED
@@ -0,0 +1,46 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: autogen_rspec
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - John Abraham
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-09-26 00:00:00.000000000 Z
13
+ dependencies: []
14
+ description: ''
15
+ email: jef.abraham@gmail.com
16
+ executables: []
17
+ extensions: []
18
+ extra_rdoc_files: []
19
+ files:
20
+ - lib/autogen_rspec.rb
21
+ homepage:
22
+ licenses: []
23
+ post_install_message:
24
+ rdoc_options: []
25
+ require_paths:
26
+ - lib
27
+ required_ruby_version: !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ! '>='
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
33
+ required_rubygems_version: !ruby/object:Gem::Requirement
34
+ none: false
35
+ requirements:
36
+ - - ! '>='
37
+ - !ruby/object:Gem::Version
38
+ version: '0'
39
+ requirements: []
40
+ rubyforge_project:
41
+ rubygems_version: 1.8.25
42
+ signing_key:
43
+ specification_version: 3
44
+ summary: This gem is used to create rspec for an already running project
45
+ test_files: []
46
+ has_rdoc: