tarantula 0.4.3 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG CHANGED
@@ -1,3 +1,9 @@
1
+ v0.5.0
2
+ * Handle rails 3.2 link methods
3
+ * Renamed Relevance::Tarantula::Link#method to #meth
4
+ * Ensure tests pass with latest Rails 2 and 3
5
+ * Add notice for deprecating ruby 1.8 in 0.6.0
6
+
1
7
  v0.4.3
2
8
  * Fix rake tasks #25 [cldwalker]
3
9
  * Remove removing String#chars #18 [cldwalker]
@@ -16,6 +16,10 @@ just let RubyGems handle it). Add it to your Gemfile as normal:
16
16
 
17
17
  gem "tarantula"
18
18
 
19
+ Or for Rails 3 applications:
20
+
21
+ gem 'tarantula', :require => 'tarantula-rails3'
22
+
19
23
  === Crawling Your App
20
24
 
21
25
  Use the included rake task to create a Rails integration test that will allow Tarantula to crawl your
data/Rakefile CHANGED
@@ -1,6 +1,7 @@
1
1
  require 'rake'
2
2
  require 'rake/testtask'
3
3
  require 'rdoc/task'
4
+ require "bundler/gem_tasks"
4
5
  Dir["lib/relevance/tasks/*.rake"].each {|f| load f }
5
6
 
6
7
  begin
@@ -1,4 +1,4 @@
1
1
  source :rubygems
2
2
 
3
3
  gemspec :path => "../"
4
- gem 'rails', '~> 3.0.10', :group => :development
4
+ gem 'rails', '~> 3.2.13', :group => :development
@@ -4,6 +4,12 @@ require 'active_support'
4
4
  require 'action_controller'
5
5
  require 'htmlentities'
6
6
 
7
+ if RUBY_VERSION < '1.9.1'
8
+ warn "***************************************************"
9
+ warn "tarantula will stop supporting ruby 1.8.x in 0.6.0."
10
+ warn "***************************************************"
11
+ end
12
+
7
13
  module Relevance; end
8
14
  module Relevance; module CoreExtensions; end; end
9
15
  module Relevance
@@ -10,7 +10,7 @@ module Relevance
10
10
  def protect_against_forgery?
11
11
  false
12
12
  end
13
- #fast fix for rails3
13
+ #fast fix for rails3
14
14
  def method_javascript_function(method, url = '', href = nil)
15
15
  action = (href && url.size > 0) ? "'#{url}'" : 'this.href'
16
16
  submit_function =
@@ -27,11 +27,11 @@ module Relevance
27
27
  submit_function << "s.setAttribute('name', '#{request_forgery_protection_token}'); s.setAttribute('value', '#{escape_javascript form_authenticity_token}'); f.appendChild(s);"
28
28
  end
29
29
  submit_function << "f.submit();"
30
- end
30
+ end
31
31
  end
32
32
 
33
33
  METHOD_REGEXPS = {}
34
- [:put, :delete, :post].each do |m|
34
+ [:put, :delete, :post, :patch].each do |m|
35
35
  # remove submit from the end so we'll match with or without forgery protection
36
36
  s = method_javascript_function(m).gsub( /f.submit();/, "" )
37
37
  # don't just match this.href in case a different url was passed originally
@@ -46,7 +46,7 @@ module Relevance
46
46
 
47
47
  if String === link || link.nil?
48
48
  @href = transform_url(link)
49
- @method = :get
49
+ @meth = :get
50
50
  else # should be a tag
51
51
  @href = link['href'] ? transform_url(link['href'].downcase) : nil
52
52
  @tag = link
@@ -54,23 +54,24 @@ module Relevance
54
54
  end
55
55
 
56
56
  def crawl
57
- response = crawler.follow(method, href)
57
+ response = crawler.follow(meth, href)
58
58
  log "Response #{response.code} for #{self}"
59
59
  crawler.handle_link_results(self, make_result(response))
60
60
  end
61
61
 
62
62
  def make_result(response)
63
- crawler.make_result(:method => method,
63
+ crawler.make_result(:method => meth,
64
64
  :url => href,
65
65
  :response => response,
66
66
  :referrer => referrer)
67
67
  end
68
68
 
69
- def method
70
- @method ||= begin
69
+ def meth
70
+ @meth ||= begin
71
71
  (@tag &&
72
- [:put, :delete, :post].detect do |m| # post should be last since it's least specific
73
- @tag['onclick'] =~ METHOD_REGEXPS[m]
72
+ [:put, :delete, :post, :patch].detect do |m| # post should be last since it's least specific
73
+ @tag['onclick'] =~ METHOD_REGEXPS[m] ||
74
+ @tag['data-method'] == m.to_s.downcase
74
75
  end) ||
75
76
  :get
76
77
  end
@@ -82,7 +83,7 @@ module Relevance
82
83
 
83
84
  def ==(obj)
84
85
  obj.respond_to?(:href) && obj.respond_to?(:method) &&
85
- self.href.to_s == obj.href.to_s && self.method.to_s == obj.method.to_s
86
+ self.href.to_s == obj.href.to_s && self.meth.to_s == obj.meth.to_s
86
87
  end
87
88
  alias :eql? :==
88
89
 
@@ -91,7 +92,7 @@ module Relevance
91
92
  end
92
93
 
93
94
  def to_s
94
- "<Relevance::Tarantula::Link href=#{href}, method=#{method}>"
95
+ "<Relevance::Tarantula::Link href=#{href}, method=#{meth}>"
95
96
  end
96
97
 
97
98
  end
@@ -1,5 +1,5 @@
1
1
  module Relevance
2
2
  module Tarantula
3
- VERSION = "0.4.3"
3
+ VERSION = "0.5.0"
4
4
  end
5
5
  end
@@ -26,7 +26,7 @@ describe 'Relevance::Tarantula::HtmlReportHelper#wrap_stack_trace_line' do
26
26
  line = %{/action_controller/filters.rb:697:in `call_filters'}
27
27
  @reporter.stubs(:textmate_url).returns("ide_url")
28
28
  html = @reporter.wrap_stack_trace_line(line)
29
- html.should == "<a href='ide_url'>/action_controller/filters.rb:697</a>:in `call_filters'"
29
+ html.should include "<a href='ide_url'>/action_controller/filters.rb:697</a>:in `call_filters"
30
30
  end
31
31
 
32
32
  it "converts html entities for non-stack trace lines" do
@@ -2,83 +2,107 @@ require "spec_helper"
2
2
 
3
3
  describe "Relevance::Tarantula::Link" do
4
4
  include ActionView::Helpers::UrlHelper
5
-
5
+
6
6
  it "does not raise an error when initializing without href attribtue" do
7
7
  link = make_link(Hpricot('<a="/foo">foo</a>').at('a'))
8
8
  link.href.should == nil
9
- link.method.should == :get
9
+ link.meth.should == :get
10
10
  end
11
11
 
12
12
  it "parses anchor tags" do
13
13
  link = make_link(Hpricot('<a href="/foo">foo</a>').at('a'))
14
14
  link.href.should == '/foo'
15
- link.method.should == :get
15
+ link.meth.should == :get
16
16
  end
17
17
 
18
18
  it "parses anchor tags with POST 'method'" do
19
19
  link = make_link(Hpricot(%Q{<a href="/foo" onclick="#{Relevance::Tarantula::Link.method_javascript_function(:post)}">foo</a>}).at('a'))
20
20
  link.href.should == '/foo'
21
- link.method.should == :post
21
+ link.meth.should == :post
22
+ end
23
+
24
+ it "parses anchor tags with POST data-method" do
25
+ link = make_link(Hpricot(%Q{<a href="/foo" data-method="post">foo</a>}).at('a'))
26
+ link.href.should == '/foo'
27
+ link.meth.should == :post
22
28
  end
23
29
 
24
30
  it "parses anchor tags with PUT 'method'" do
25
31
  link = make_link(Hpricot(%Q{<a href="/foo" onclick="#{Relevance::Tarantula::Link.method_javascript_function(:put)}">foo</a>}).at('a'))
26
32
  link.href.should == '/foo'
27
- link.method.should == :put
33
+ link.meth.should == :put
34
+ end
35
+
36
+ it "parses anchor tags with PUT data-method" do
37
+ link = make_link(Hpricot(%Q{<a href="/foo" data-method="put">foo</a>}).at('a'))
38
+ link.href.should == '/foo'
39
+ link.meth.should == :put
40
+ end
41
+
42
+ it "parses anchor tags with PATCH data-method" do
43
+ link = make_link(Hpricot(%Q{<a href="/foo" data-method="patch">foo</a>}).at('a'))
44
+ link.href.should == '/foo'
45
+ link.meth.should == :patch
28
46
  end
29
47
 
30
48
  it "parses anchor tags with DELETE 'method'" do
31
49
  link = make_link(Hpricot(%Q{<a href="/foo" onclick="#{Relevance::Tarantula::Link.method_javascript_function(:delete)}">foo</a>}).at('a'))
32
50
  link.href.should == '/foo'
33
- link.method.should == :delete
51
+ link.meth.should == :delete
52
+ end
53
+
54
+ it "parses anchor tags with DELETE data-method" do
55
+ link = make_link(Hpricot(%Q{<a href="/foo" data-method="delete">foo</a>}).at('a'))
56
+ link.href.should == '/foo'
57
+ link.meth.should == :delete
34
58
  end
35
59
 
36
60
  it "parses link tags with text" do
37
61
  link = make_link(Hpricot('<link href="/bar">bar</a>').at('link'))
38
62
  link.href.should == '/bar'
39
- link.method.should == :get
63
+ link.meth.should == :get
40
64
  end
41
-
65
+
42
66
  it "parses link tags without text" do
43
67
  link = make_link(Hpricot('<link href="/bar" />').at('link'))
44
68
  link.href.should == '/bar'
45
- link.method.should == :get
69
+ link.meth.should == :get
46
70
  end
47
-
71
+
48
72
  it 'remembers link referrer if there is one' do
49
73
  link = make_link('/url', stub_everything, '/some-referrer')
50
74
  link.referrer.should == '/some-referrer'
51
75
  end
52
-
76
+
53
77
  it "does two things when crawled: follow, log, and handle" do
54
78
  crawler = Relevance::Tarantula::Crawler.new
55
79
  link = make_link('/foo', crawler)
56
-
80
+
57
81
  response = stub(:code => "200")
58
82
  crawler.expects(:follow).returns(response)
59
83
  link.expects(:log)
60
84
  crawler.expects(:handle_link_results)
61
-
85
+
62
86
  link.crawl
63
87
  end
64
-
88
+
65
89
  # method_javascript_function needs this method
66
90
  def protect_against_forgery?
67
91
  false
68
92
  end
69
-
93
+
70
94
  end
71
95
 
72
96
  describe "possible conflict when user has an AR model named Link" do
73
97
  it "does not taint Object with Relevance::Tarantula" do
74
98
  Object.ancestors.should_not include(Relevance::Tarantula)
75
99
  end
76
-
100
+
77
101
  it "doesnt break with a Link model" do
78
102
  lambda {
79
103
  class Link < ActiveRecord::Base
80
104
  end
81
105
  }.should_not raise_error
82
106
  end
83
-
107
+
84
108
  end
@@ -17,9 +17,9 @@ Gem::Specification.new do |s|
17
17
  s.add_runtime_dependency "htmlentities", "~> 4.3.0"
18
18
  s.add_runtime_dependency "hpricot", "~> 0.8.4"
19
19
 
20
- s.add_development_dependency "rspec", "~> 2.8.0"
20
+ s.add_development_dependency "rspec", "~> 2.12.0"
21
21
  s.add_development_dependency 'rdoc', '~> 3.12.0'
22
22
  s.add_development_dependency "log_buddy", "~> 0.6.0"
23
- s.add_development_dependency "mocha", "~> 0.9.12"
23
+ s.add_development_dependency "mocha", "~> 0.13.2"
24
24
  s.add_development_dependency "rails", ">= 2.3.0"
25
25
  end
metadata CHANGED
@@ -1,101 +1,144 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: tarantula
3
- version: !ruby/object:Gem::Version
4
- version: 0.4.3
3
+ version: !ruby/object:Gem::Version
4
+ hash: 11
5
5
  prerelease:
6
+ segments:
7
+ - 0
8
+ - 5
9
+ - 0
10
+ version: 0.5.0
6
11
  platform: ruby
7
- authors:
12
+ authors:
8
13
  - Relevance, Inc.
9
14
  autorequire:
10
15
  bindir: bin
11
16
  cert_chain: []
12
- date: 2012-02-24 00:00:00.000000000Z
13
- dependencies:
14
- - !ruby/object:Gem::Dependency
17
+
18
+ date: 2013-04-12 00:00:00 Z
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
15
21
  name: htmlentities
16
- requirement: &70200734539400 !ruby/object:Gem::Requirement
22
+ prerelease: false
23
+ type: :runtime
24
+ version_requirements: &id001 !ruby/object:Gem::Requirement
17
25
  none: false
18
- requirements:
26
+ requirements:
19
27
  - - ~>
20
- - !ruby/object:Gem::Version
28
+ - !ruby/object:Gem::Version
29
+ hash: 51
30
+ segments:
31
+ - 4
32
+ - 3
33
+ - 0
21
34
  version: 4.3.0
22
- type: :runtime
23
- prerelease: false
24
- version_requirements: *70200734539400
25
- - !ruby/object:Gem::Dependency
35
+ requirement: *id001
36
+ - !ruby/object:Gem::Dependency
26
37
  name: hpricot
27
- requirement: &70200734538900 !ruby/object:Gem::Requirement
38
+ prerelease: false
39
+ type: :runtime
40
+ version_requirements: &id002 !ruby/object:Gem::Requirement
28
41
  none: false
29
- requirements:
42
+ requirements:
30
43
  - - ~>
31
- - !ruby/object:Gem::Version
44
+ - !ruby/object:Gem::Version
45
+ hash: 55
46
+ segments:
47
+ - 0
48
+ - 8
49
+ - 4
32
50
  version: 0.8.4
33
- type: :runtime
34
- prerelease: false
35
- version_requirements: *70200734538900
36
- - !ruby/object:Gem::Dependency
51
+ requirement: *id002
52
+ - !ruby/object:Gem::Dependency
37
53
  name: rspec
38
- requirement: &70200734538440 !ruby/object:Gem::Requirement
54
+ prerelease: false
55
+ type: :development
56
+ version_requirements: &id003 !ruby/object:Gem::Requirement
39
57
  none: false
40
- requirements:
58
+ requirements:
41
59
  - - ~>
42
- - !ruby/object:Gem::Version
43
- version: 2.8.0
44
- type: :development
45
- prerelease: false
46
- version_requirements: *70200734538440
47
- - !ruby/object:Gem::Dependency
60
+ - !ruby/object:Gem::Version
61
+ hash: 63
62
+ segments:
63
+ - 2
64
+ - 12
65
+ - 0
66
+ version: 2.12.0
67
+ requirement: *id003
68
+ - !ruby/object:Gem::Dependency
48
69
  name: rdoc
49
- requirement: &70200734537980 !ruby/object:Gem::Requirement
70
+ prerelease: false
71
+ type: :development
72
+ version_requirements: &id004 !ruby/object:Gem::Requirement
50
73
  none: false
51
- requirements:
74
+ requirements:
52
75
  - - ~>
53
- - !ruby/object:Gem::Version
76
+ - !ruby/object:Gem::Version
77
+ hash: 55
78
+ segments:
79
+ - 3
80
+ - 12
81
+ - 0
54
82
  version: 3.12.0
55
- type: :development
56
- prerelease: false
57
- version_requirements: *70200734537980
58
- - !ruby/object:Gem::Dependency
83
+ requirement: *id004
84
+ - !ruby/object:Gem::Dependency
59
85
  name: log_buddy
60
- requirement: &70200734537520 !ruby/object:Gem::Requirement
86
+ prerelease: false
87
+ type: :development
88
+ version_requirements: &id005 !ruby/object:Gem::Requirement
61
89
  none: false
62
- requirements:
90
+ requirements:
63
91
  - - ~>
64
- - !ruby/object:Gem::Version
92
+ - !ruby/object:Gem::Version
93
+ hash: 7
94
+ segments:
95
+ - 0
96
+ - 6
97
+ - 0
65
98
  version: 0.6.0
66
- type: :development
67
- prerelease: false
68
- version_requirements: *70200734537520
69
- - !ruby/object:Gem::Dependency
99
+ requirement: *id005
100
+ - !ruby/object:Gem::Dependency
70
101
  name: mocha
71
- requirement: &70200724830800 !ruby/object:Gem::Requirement
102
+ prerelease: false
103
+ type: :development
104
+ version_requirements: &id006 !ruby/object:Gem::Requirement
72
105
  none: false
73
- requirements:
106
+ requirements:
74
107
  - - ~>
75
- - !ruby/object:Gem::Version
76
- version: 0.9.12
77
- type: :development
78
- prerelease: false
79
- version_requirements: *70200724830800
80
- - !ruby/object:Gem::Dependency
108
+ - !ruby/object:Gem::Version
109
+ hash: 47
110
+ segments:
111
+ - 0
112
+ - 13
113
+ - 2
114
+ version: 0.13.2
115
+ requirement: *id006
116
+ - !ruby/object:Gem::Dependency
81
117
  name: rails
82
- requirement: &70200724830340 !ruby/object:Gem::Requirement
118
+ prerelease: false
119
+ type: :development
120
+ version_requirements: &id007 !ruby/object:Gem::Requirement
83
121
  none: false
84
- requirements:
85
- - - ! '>='
86
- - !ruby/object:Gem::Version
122
+ requirements:
123
+ - - ">="
124
+ - !ruby/object:Gem::Version
125
+ hash: 3
126
+ segments:
127
+ - 2
128
+ - 3
129
+ - 0
87
130
  version: 2.3.0
88
- type: :development
89
- prerelease: false
90
- version_requirements: *70200724830340
91
- description: Tarantula is a big fuzzy spider. It crawls your Rails 2.3 and 3.x applications,
92
- fuzzing data to see what breaks.
93
- email:
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:
94
134
  - opensource@thinkrelevance.com
95
135
  executables: []
136
+
96
137
  extensions: []
138
+
97
139
  extra_rdoc_files: []
98
- files:
140
+
141
+ files:
99
142
  - .autotest
100
143
  - .gitignore
101
144
  - .rvmrc
@@ -186,27 +229,36 @@ files:
186
229
  - vendor/xss-shield/test/test_safe_string.rb
187
230
  homepage: https://github.com/relevance/tarantula
188
231
  licenses: []
232
+
189
233
  post_install_message:
190
234
  rdoc_options: []
191
- require_paths:
235
+
236
+ require_paths:
192
237
  - lib
193
- required_ruby_version: !ruby/object:Gem::Requirement
238
+ required_ruby_version: !ruby/object:Gem::Requirement
194
239
  none: false
195
- requirements:
196
- - - ! '>='
197
- - !ruby/object:Gem::Version
198
- version: '0'
199
- required_rubygems_version: !ruby/object:Gem::Requirement
240
+ requirements:
241
+ - - ">="
242
+ - !ruby/object:Gem::Version
243
+ hash: 3
244
+ segments:
245
+ - 0
246
+ version: "0"
247
+ required_rubygems_version: !ruby/object:Gem::Requirement
200
248
  none: false
201
- requirements:
202
- - - ! '>='
203
- - !ruby/object:Gem::Version
204
- version: '0'
249
+ requirements:
250
+ - - ">="
251
+ - !ruby/object:Gem::Version
252
+ hash: 3
253
+ segments:
254
+ - 0
255
+ version: "0"
205
256
  requirements: []
257
+
206
258
  rubyforge_project:
207
- rubygems_version: 1.8.16
259
+ rubygems_version: 1.8.21
208
260
  signing_key:
209
261
  specification_version: 3
210
262
  summary: A big hairy fuzzy spider that crawls your site, wreaking havoc
211
- test_files:
263
+ test_files:
212
264
  - template/tarantula_test.rb