tarantula 0.5.0 → 0.5.1

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG CHANGED
@@ -1,3 +1,6 @@
1
+ v0.5.1
2
+ * Rescue exceptions for Rails 3 integration tests and return them as 404/500 responses.
3
+
1
4
  v0.5.0
2
5
  * Handle rails 3.2 link methods
3
6
  * Renamed Relevance::Tarantula::Link#method to #meth
@@ -1,4 +1,4 @@
1
- source :rubygems
1
+ source "https://rubygems.org"
2
2
 
3
3
  gemspec :path => "../"
4
4
  gem 'rails', '~> 2.3.14', :group => :development
@@ -1,4 +1,4 @@
1
- source :rubygems
1
+ source "https://rubygems.org"
2
2
 
3
3
  gemspec :path => "../"
4
4
  gem 'rails', '~> 3.2.13', :group => :development
@@ -11,8 +11,8 @@ module Relevance
11
11
 
12
12
  def self.rails_integration_test(integration_test, options = {})
13
13
  t = Crawler.new
14
- t.max_url_length = options[:max_url_length] if options[:max_url_length]
15
- t.proxy = RailsIntegrationProxy.new(integration_test)
14
+ t.max_url_length = options[:max_url_length] if options[:max_url_length]
15
+ t.proxy = RailsIntegrationProxy.new(integration_test)
16
16
  t.handlers << HtmlDocumentHandler.new(t)
17
17
  t.handlers << InvalidHtmlHandler.new
18
18
  t.log_grabber = Relevance::Tarantula::LogGrabber.new(File.join(rails_root, "log/test.log"))
@@ -33,22 +33,36 @@ module Relevance
33
33
 
34
34
  [:get, :post, :put, :delete].each do |verb|
35
35
  define_method(verb) do |url, *args|
36
- integration_test.send(verb, url, *args)
37
- response = integration_test.response
36
+ response = nil
37
+ begin
38
+ integration_test.send(verb, url, *args)
39
+ response = integration_test.response
40
+ rescue *error_classes => e
41
+ response = integration_test.response
42
+ alter_response(response, '404', e.message + "\n\n" + e.backtrace.join("\n"))
43
+ rescue Exception => e
44
+ response = integration_test.response
45
+ alter_response(response, '500', e.message + "\n\n" + e.backtrace.join("\n"))
46
+ end
38
47
  patch_response(url, response)
39
48
  response
40
49
  end
41
50
  end
42
51
 
52
+ def alter_response(response, code, body)
53
+ response.meta.attr_accessor :code
54
+ response.code = code
55
+ response.body = body
56
+ response
57
+ end
58
+
43
59
  def patch_response(url, response)
44
60
  if response.code == '404'
45
61
  if File.exist?(static_content_path(url))
46
62
  case ext = File.extension(url)
47
63
  when /html|te?xt|css|js|jpe?g|gif|psd|png|eps|pdf|ico/
48
- response.body = static_content_file(url)
49
64
  response.headers["type"] = "text/#{ext}" # readable as response.content_type
50
- response.meta.attr_accessor :code
51
- response.code = "200"
65
+ alter_response(response, '200', static_content_file(url))
52
66
  else
53
67
  log "Skipping unknown type #{url}"
54
68
  end
@@ -61,6 +75,7 @@ module Relevance
61
75
  end
62
76
  end
63
77
 
78
+
64
79
  def static_content_file(url)
65
80
  File.read(static_content_path(url))
66
81
  end
@@ -68,6 +83,14 @@ module Relevance
68
83
  def static_content_path(url)
69
84
  File.expand_path(File.join(rails_root, "public", url))
70
85
  end
86
+
87
+ private
88
+ def error_classes
89
+ defined?(ActionController::RoutingError) ?
90
+ [ActiveRecord::RecordNotFound, ActionController::RoutingError] :
91
+ [ActiveRecord::RecordNotFound]
92
+ end
93
+
71
94
  end
72
95
 
73
96
  end
@@ -1,5 +1,5 @@
1
1
  module Relevance
2
2
  module Tarantula
3
- VERSION = "0.5.0"
3
+ VERSION = "0.5.1"
4
4
  end
5
5
  end
@@ -43,7 +43,19 @@ describe "Relevance::Tarantula::RailsIntegrationProxy" do
43
43
  Relevance::Tarantula::RailsIntegrationProxy.new(o)
44
44
  o.methods(false).map(&:to_s).sort.should == %w{response response=}
45
45
  end
46
+ end
46
47
 
48
+ describe "Relevance::Tarantula::RailsIntegrationProxy errors" do
49
+ it "alters response to contain the error message" do
50
+ @rip = Relevance::Tarantula::RailsIntegrationProxy.new(stub)
51
+ @response = Struct.new(:body, :code).new(nil, nil)
52
+ @rip.integration_test = stub_everything(:response => @response) do |stub|
53
+ stub.stubs(:get).raises(Exception, 'Internal Server Error')
54
+ end
55
+ response = @rip.get("/url")
56
+ response.code.should == '500'
57
+ response.body.should =~ /\AInternal Server Error\n\n/
58
+ end
47
59
  end
48
60
 
49
61
  describe "Relevance::Tarantula::RailsIntegrationProxy patching" do
metadata CHANGED
@@ -1,144 +1,136 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: tarantula
3
- version: !ruby/object:Gem::Version
4
- hash: 11
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.5.1
5
5
  prerelease:
6
- segments:
7
- - 0
8
- - 5
9
- - 0
10
- version: 0.5.0
11
6
  platform: ruby
12
- authors:
7
+ authors:
13
8
  - Relevance, Inc.
14
9
  autorequire:
15
10
  bindir: bin
16
11
  cert_chain: []
17
-
18
- date: 2013-04-12 00:00:00 Z
19
- dependencies:
20
- - !ruby/object:Gem::Dependency
12
+ date: 2013-05-24 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
21
15
  name: htmlentities
22
- prerelease: false
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: 4.3.0
23
22
  type: :runtime
24
- version_requirements: &id001 !ruby/object:Gem::Requirement
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
25
  none: false
26
- requirements:
26
+ requirements:
27
27
  - - ~>
28
- - !ruby/object:Gem::Version
29
- hash: 51
30
- segments:
31
- - 4
32
- - 3
33
- - 0
28
+ - !ruby/object:Gem::Version
34
29
  version: 4.3.0
35
- requirement: *id001
36
- - !ruby/object:Gem::Dependency
30
+ - !ruby/object:Gem::Dependency
37
31
  name: hpricot
38
- prerelease: false
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ~>
36
+ - !ruby/object:Gem::Version
37
+ version: 0.8.4
39
38
  type: :runtime
40
- version_requirements: &id002 !ruby/object:Gem::Requirement
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
41
  none: false
42
- requirements:
42
+ requirements:
43
43
  - - ~>
44
- - !ruby/object:Gem::Version
45
- hash: 55
46
- segments:
47
- - 0
48
- - 8
49
- - 4
44
+ - !ruby/object:Gem::Version
50
45
  version: 0.8.4
51
- requirement: *id002
52
- - !ruby/object:Gem::Dependency
46
+ - !ruby/object:Gem::Dependency
53
47
  name: rspec
54
- prerelease: false
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ~>
52
+ - !ruby/object:Gem::Version
53
+ version: 2.12.0
55
54
  type: :development
56
- version_requirements: &id003 !ruby/object:Gem::Requirement
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
57
  none: false
58
- requirements:
58
+ requirements:
59
59
  - - ~>
60
- - !ruby/object:Gem::Version
61
- hash: 63
62
- segments:
63
- - 2
64
- - 12
65
- - 0
60
+ - !ruby/object:Gem::Version
66
61
  version: 2.12.0
67
- requirement: *id003
68
- - !ruby/object:Gem::Dependency
62
+ - !ruby/object:Gem::Dependency
69
63
  name: rdoc
70
- prerelease: false
64
+ requirement: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ~>
68
+ - !ruby/object:Gem::Version
69
+ version: 3.12.0
71
70
  type: :development
72
- version_requirements: &id004 !ruby/object:Gem::Requirement
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
73
  none: false
74
- requirements:
74
+ requirements:
75
75
  - - ~>
76
- - !ruby/object:Gem::Version
77
- hash: 55
78
- segments:
79
- - 3
80
- - 12
81
- - 0
76
+ - !ruby/object:Gem::Version
82
77
  version: 3.12.0
83
- requirement: *id004
84
- - !ruby/object:Gem::Dependency
78
+ - !ruby/object:Gem::Dependency
85
79
  name: log_buddy
86
- prerelease: false
80
+ requirement: !ruby/object:Gem::Requirement
81
+ none: false
82
+ requirements:
83
+ - - ~>
84
+ - !ruby/object:Gem::Version
85
+ version: 0.6.0
87
86
  type: :development
88
- version_requirements: &id005 !ruby/object:Gem::Requirement
87
+ prerelease: false
88
+ version_requirements: !ruby/object:Gem::Requirement
89
89
  none: false
90
- requirements:
90
+ requirements:
91
91
  - - ~>
92
- - !ruby/object:Gem::Version
93
- hash: 7
94
- segments:
95
- - 0
96
- - 6
97
- - 0
92
+ - !ruby/object:Gem::Version
98
93
  version: 0.6.0
99
- requirement: *id005
100
- - !ruby/object:Gem::Dependency
94
+ - !ruby/object:Gem::Dependency
101
95
  name: mocha
102
- prerelease: false
96
+ requirement: !ruby/object:Gem::Requirement
97
+ none: false
98
+ requirements:
99
+ - - ~>
100
+ - !ruby/object:Gem::Version
101
+ version: 0.13.2
103
102
  type: :development
104
- version_requirements: &id006 !ruby/object:Gem::Requirement
103
+ prerelease: false
104
+ version_requirements: !ruby/object:Gem::Requirement
105
105
  none: false
106
- requirements:
106
+ requirements:
107
107
  - - ~>
108
- - !ruby/object:Gem::Version
109
- hash: 47
110
- segments:
111
- - 0
112
- - 13
113
- - 2
108
+ - !ruby/object:Gem::Version
114
109
  version: 0.13.2
115
- requirement: *id006
116
- - !ruby/object:Gem::Dependency
110
+ - !ruby/object:Gem::Dependency
117
111
  name: rails
118
- prerelease: false
112
+ requirement: !ruby/object:Gem::Requirement
113
+ none: false
114
+ requirements:
115
+ - - ! '>='
116
+ - !ruby/object:Gem::Version
117
+ version: 2.3.0
119
118
  type: :development
120
- version_requirements: &id007 !ruby/object:Gem::Requirement
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
121
  none: false
122
- requirements:
123
- - - ">="
124
- - !ruby/object:Gem::Version
125
- hash: 3
126
- segments:
127
- - 2
128
- - 3
129
- - 0
122
+ requirements:
123
+ - - ! '>='
124
+ - !ruby/object:Gem::Version
130
125
  version: 2.3.0
131
- requirement: *id007
132
- description: Tarantula is a big fuzzy spider. It crawls your Rails 2.3 and 3.x applications, fuzzing data to see what breaks.
133
- email:
126
+ description: Tarantula is a big fuzzy spider. It crawls your Rails 2.3 and 3.x applications,
127
+ fuzzing data to see what breaks.
128
+ email:
134
129
  - opensource@thinkrelevance.com
135
130
  executables: []
136
-
137
131
  extensions: []
138
-
139
132
  extra_rdoc_files: []
140
-
141
- files:
133
+ files:
142
134
  - .autotest
143
135
  - .gitignore
144
136
  - .rvmrc
@@ -229,36 +221,33 @@ files:
229
221
  - vendor/xss-shield/test/test_safe_string.rb
230
222
  homepage: https://github.com/relevance/tarantula
231
223
  licenses: []
232
-
233
224
  post_install_message:
234
225
  rdoc_options: []
235
-
236
- require_paths:
226
+ require_paths:
237
227
  - lib
238
- required_ruby_version: !ruby/object:Gem::Requirement
228
+ required_ruby_version: !ruby/object:Gem::Requirement
239
229
  none: false
240
- requirements:
241
- - - ">="
242
- - !ruby/object:Gem::Version
243
- hash: 3
244
- segments:
230
+ requirements:
231
+ - - ! '>='
232
+ - !ruby/object:Gem::Version
233
+ version: '0'
234
+ segments:
245
235
  - 0
246
- version: "0"
247
- required_rubygems_version: !ruby/object:Gem::Requirement
236
+ hash: -3645130857833541584
237
+ required_rubygems_version: !ruby/object:Gem::Requirement
248
238
  none: false
249
- requirements:
250
- - - ">="
251
- - !ruby/object:Gem::Version
252
- hash: 3
253
- segments:
239
+ requirements:
240
+ - - ! '>='
241
+ - !ruby/object:Gem::Version
242
+ version: '0'
243
+ segments:
254
244
  - 0
255
- version: "0"
245
+ hash: -3645130857833541584
256
246
  requirements: []
257
-
258
247
  rubyforge_project:
259
- rubygems_version: 1.8.21
248
+ rubygems_version: 1.8.24
260
249
  signing_key:
261
250
  specification_version: 3
262
251
  summary: A big hairy fuzzy spider that crawls your site, wreaking havoc
263
- test_files:
252
+ test_files:
264
253
  - template/tarantula_test.rb