monet 0.2.3 → 0.2.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.ruby-version +1 -1
- data/.travis.yml +7 -0
- data/Gemfile +1 -1
- data/lib/monet/baseless_image.rb +5 -1
- data/lib/monet/baseline_control.rb +30 -17
- data/lib/monet/capture.rb +28 -27
- data/lib/monet/capture_map.rb +11 -3
- data/lib/monet/changeset.rb +4 -0
- data/lib/monet/config.rb +18 -11
- data/lib/monet/image.rb +67 -0
- data/lib/monet/router.rb +71 -0
- data/lib/monet/tasks.rb +10 -7
- data/lib/monet/version.rb +1 -1
- data/lib/monet.rb +4 -29
- data/spec/capture_map_spec.rb +5 -50
- data/spec/capture_spec.rb +59 -33
- data/spec/cassettes/spider-config.yml +33784 -0
- data/spec/cassettes/spider-map.yml +33782 -0
- data/spec/config_spec.rb +14 -8
- data/spec/fixtures/baselines/lance.com/.DS_Store +0 -0
- data/spec/fixtures/baselines/lance.com/lance.com-1024-diff.png +0 -0
- data/spec/fixtures/baselines/lance.com/lance.com-1024.png +0 -0
- data/spec/fixtures/baselines/lance.com/lance.com|aboutus-1024.png +0 -0
- data/spec/fixtures/captures/lance.com/lance.com-1024.png +0 -0
- data/spec/fixtures/spider-config.yaml +8 -0
- data/spec/fixtures/thumbnails/lance.com/.DS_Store +0 -0
- data/spec/fixtures/thumbnails/lance.com/lance.com-1024.png +0 -0
- data/spec/image_spec.rb +36 -0
- data/spec/router_spec.rb +90 -0
- data/spec/spec_helper.rb +2 -0
- data/spec/tmp/test.png +0 -0
- metadata +31 -7
- data/lib/monet/path_router.rb +0 -70
- data/spec/cassettes/spider.yml +0 -28572
- data/spec/path_router_spec.rb +0 -59
data/spec/capture_spec.rb
CHANGED
@@ -1,12 +1,17 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
require 'chunky_png'
|
4
|
+
require 'monet'
|
4
5
|
require 'monet/capture'
|
5
6
|
|
6
7
|
describe Monet::Capture do
|
7
8
|
Given(:path) { File.expand_path './spec/tmp/output' }
|
8
|
-
Given(:url) { "
|
9
|
-
Given(:capture_agent) {
|
9
|
+
Given(:url) { "https://google.com" }
|
10
|
+
Given(:capture_agent) { create_capture(config) }
|
11
|
+
|
12
|
+
def create_capture(config)
|
13
|
+
Monet::Capture.new config
|
14
|
+
end
|
10
15
|
|
11
16
|
after(:all) do
|
12
17
|
Dir.glob("#{path}/**/*.png").each do |file|
|
@@ -14,57 +19,78 @@ describe Monet::Capture do
|
|
14
19
|
end
|
15
20
|
end
|
16
21
|
|
17
|
-
context "
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
22
|
+
context "simple config" do
|
23
|
+
Given(:config) do
|
24
|
+
Monet::Config.config do |c|
|
25
|
+
c.base_url = "https://google.com"
|
26
|
+
c.capture_dir = File.join(path, "captures")
|
27
|
+
c.thumbnail_dir = File.join(path, "thumbnails")
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
context "can capture a path" do
|
32
|
+
When { capture_agent.capture(url, "#{path}/google.com/google.com-280.png") }
|
33
|
+
Then { File.exist?("#{path}/google.com/google.com-280.png").should be_true }
|
23
34
|
end
|
24
35
|
|
25
|
-
context "
|
26
|
-
Given(:
|
27
|
-
|
28
|
-
|
29
|
-
Then { final.should be_a(Monet::Config) }
|
30
|
-
Then { final.capture_dir.should == path }
|
36
|
+
context "can capture an image object" do
|
37
|
+
Given(:img) { Monet::Image.new(File.join(path, "google.com", "google.com|chrome-1024.png")) }
|
38
|
+
When { capture_agent.capture("#{url}/chrome", img) }
|
39
|
+
Then { File.exist?("#{path}/google.com/google.com|chrome-1024.png").should be_true }
|
31
40
|
end
|
32
41
|
end
|
33
42
|
|
34
43
|
context "converts name properly" do
|
35
|
-
Given(:
|
36
|
-
|
37
|
-
|
44
|
+
Given(:config) { Monet::Config.config {|c|
|
45
|
+
c.base_url = url
|
46
|
+
c.capture_dir = path
|
47
|
+
c.dimensions = [900]
|
48
|
+
c.map = ["/"]
|
49
|
+
}}
|
50
|
+
When { capture_agent.capture_all }
|
51
|
+
Then { File.exist?("#{path}/google.com/google.com-900.png").should be_true }
|
38
52
|
end
|
39
53
|
|
40
54
|
context "captures all dimensions requested" do
|
41
|
-
Given(:
|
42
|
-
|
43
|
-
|
44
|
-
|
55
|
+
Given(:config) { Monet::Config.config {|c|
|
56
|
+
c.base_url = url
|
57
|
+
c.capture_dir = path
|
58
|
+
c.dimensions = [900, 1400]
|
59
|
+
c.map = ["/"]
|
60
|
+
}}
|
61
|
+
When { capture_agent.capture_all }
|
62
|
+
Then { File.exist?("#{path}/google.com/google.com-900.png").should be_true }
|
63
|
+
Then { File.exist?("#{path}/google.com/google.com-1400.png").should be_true }
|
45
64
|
end
|
46
65
|
|
47
66
|
context "captures defualt size as 1024" do
|
48
|
-
Given(:
|
49
|
-
|
50
|
-
|
67
|
+
Given(:config) { Monet::Config.config {|c|
|
68
|
+
c.base_url = "https://www.facebook.com"
|
69
|
+
c.capture_dir = path
|
70
|
+
c.map = ["/"]
|
71
|
+
}}
|
72
|
+
When { capture_agent.capture_all }
|
73
|
+
Then { File.exist?("#{path}/www.facebook.com/www.facebook.com-1024.png").should be_true }
|
51
74
|
end
|
52
75
|
|
53
|
-
context "
|
54
|
-
Given(:thumb_path) { "#{path}/thumbnails/www.spider.io/www.spider.io
|
55
|
-
Given(:
|
56
|
-
|
57
|
-
|
58
|
-
|
76
|
+
context "capturing" do
|
77
|
+
Given(:thumb_path) { "#{path}/thumbnails/www.spider.io/www.spider.io-1024.png" }
|
78
|
+
Given(:config) { Monet::Config.config do |c|
|
79
|
+
c.capture_dir = path
|
80
|
+
c.thumbnail_dir = File.join(path, "thumbnails")
|
81
|
+
c.base_url = "https://www.spider.io"
|
82
|
+
c.thumbnail = true
|
83
|
+
c.map = ["/"]
|
84
|
+
end
|
59
85
|
}
|
60
|
-
When { capture_agent.
|
86
|
+
When { capture_agent.capture_all }
|
61
87
|
|
62
88
|
context "can thumbnail an image" do
|
63
|
-
Then { File.exist?("#{path}/www.spider.io/www.spider.io
|
89
|
+
Then { File.exist?("#{path}/www.spider.io/www.spider.io-1024.png").should be_true }
|
64
90
|
And { File.exist?(thumb_path).should be_true }
|
65
91
|
end
|
66
92
|
|
67
|
-
context "
|
93
|
+
context "thumbnail sizes to 200x200" do
|
68
94
|
When(:thumb) { ChunkyPNG::Image.from_file(thumb_path) }
|
69
95
|
Then { thumb.width.should == 200 }
|
70
96
|
And { thumb.height.should == 200 }
|