remote_partial 0.5.0 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -3,16 +3,8 @@ require 'test_helper'
3
3
  module RemotePartial
4
4
  class PartialTest < ActiveSupport::TestCase
5
5
 
6
- def setup
7
- @partial = Partial.create(
8
- name: :simple,
9
- url: 'http://www.warwickshire.gov.uk',
10
- criteria: 'p:first-child',
11
- repeat_period: 10.minutes
12
- )
13
- @first_p = '<p>One</p>'
14
- @body = "<body><h1>Foo</h1><div>#{@first_p}<p>Bar</p></div></body>"
15
- enable_mock(@partial.url, @body)
6
+ def setup
7
+ create_partial_for('http://www.warwickshire.gov.uk')
16
8
  end
17
9
 
18
10
  def teardown
@@ -30,6 +22,12 @@ module RemotePartial
30
22
  end
31
23
  end
32
24
 
25
+ def test_update_file_with_https_url
26
+ enable_mock("http://www.warwickshire.gov.uk:443/")
27
+ create_partial_for('https://www.warwickshire.gov.uk')
28
+ test_update_file
29
+ end
30
+
33
31
  def test_update_file_with_output_modifier
34
32
  @partial.output_modifier = '{|text| text.gsub(/One/, "Two")}'
35
33
  expected = '<p>Two</p>'
@@ -86,5 +84,18 @@ module RemotePartial
86
84
  test_update_file
87
85
  end
88
86
 
87
+ def create_partial_for(url)
88
+ @first_p = '<p>One</p>'
89
+ @body = "<body><h1>Foo</h1><div>#{@first_p}<p>Bar</p></div></body>"
90
+ enable_mock(url, @body)
91
+
92
+ @partial = Partial.create(
93
+ name: :simple,
94
+ url: url,
95
+ criteria: 'p:first-child',
96
+ repeat_period: 10.minutes
97
+ )
98
+ end
99
+
89
100
  end
90
101
  end
@@ -26,6 +26,21 @@ module RemotePartial
26
26
  assert_equal raw, ResourceManager.get_raw(@url)
27
27
  end
28
28
 
29
+ def test_get_raw_with_http
30
+ url = "https://www.worcestershire.gov.uk"
31
+ enable_mock(url, @body)
32
+ enable_mock("http://www.worcestershire.gov.uk:443")
33
+ uri = URI.parse(url)
34
+ http = Net::HTTP.new(uri.host, uri.port)
35
+ http.use_ssl = true
36
+ http.verify_mode = OpenSSL::SSL::VERIFY_NONE
37
+
38
+ request = Net::HTTP::Get.new(uri.request_uri)
39
+ response = http.request(request)
40
+ raw = response.body
41
+ assert_equal raw, ResourceManager.get_raw(url)
42
+ end
43
+
29
44
  def test_html
30
45
  resource_manager = ResourceManager.new(@url)
31
46
  assert_equal raw_content, resource_manager.html
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: remote_partial
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.6.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-07-30 00:00:00.000000000 Z
12
+ date: 2013-08-22 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
@@ -93,6 +93,7 @@ files:
93
93
  - test/dummy/app/views/demos/_ruby.html.erb
94
94
  - test/dummy/app/views/layouts/application.html.erb
95
95
  - test/dummy/app/views/remote_partials/_clock.html.erb
96
+ - test/dummy/app/views/remote_partials/_wcc.html.erb
96
97
  - test/dummy/app/views/remote_partials/_partial_with_mod.html.erb
97
98
  - test/dummy/app/views/remote_partials/_fixed.html.erb
98
99
  - test/dummy/app/views/remote_partials/_ruby.html.erb
@@ -199,6 +200,7 @@ test_files:
199
200
  - test/dummy/app/views/demos/_ruby.html.erb
200
201
  - test/dummy/app/views/layouts/application.html.erb
201
202
  - test/dummy/app/views/remote_partials/_clock.html.erb
203
+ - test/dummy/app/views/remote_partials/_wcc.html.erb
202
204
  - test/dummy/app/views/remote_partials/_partial_with_mod.html.erb
203
205
  - test/dummy/app/views/remote_partials/_fixed.html.erb
204
206
  - test/dummy/app/views/remote_partials/_ruby.html.erb