hermitage 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +20 -0
- data/.rspec +2 -0
- data/.rvmrc +1 -0
- data/.travis.yml +4 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +175 -0
- data/Rakefile +7 -0
- data/app/assets/javascripts/hermitage.js.coffee +263 -0
- data/config.ru +7 -0
- data/hermitage.gemspec +33 -0
- data/lib/generators/hermitage/install_generator.rb +17 -0
- data/lib/generators/hermitage/templates/hermitage.rb +29 -0
- data/lib/hermitage/defaults.rb +31 -0
- data/lib/hermitage/engine.rb +6 -0
- data/lib/hermitage/railtie.rb +9 -0
- data/lib/hermitage/version.rb +3 -0
- data/lib/hermitage/view_helpers.rb +42 -0
- data/lib/hermitage.rb +13 -0
- data/spec/dummy/README.rdoc +28 -0
- data/spec/dummy/Rakefile +6 -0
- data/spec/dummy/app/assets/images/.keep +0 -0
- data/spec/dummy/app/assets/images/0-full.png +0 -0
- data/spec/dummy/app/assets/images/0-thumbnail.png +0 -0
- data/spec/dummy/app/assets/images/1-full.png +0 -0
- data/spec/dummy/app/assets/images/1-thumbnail.png +0 -0
- data/spec/dummy/app/assets/images/2-full.png +0 -0
- data/spec/dummy/app/assets/images/2-thumbnail.png +0 -0
- data/spec/dummy/app/assets/javascripts/application.js +15 -0
- data/spec/dummy/app/assets/stylesheets/application.css +13 -0
- data/spec/dummy/app/controllers/application_controller.rb +5 -0
- data/spec/dummy/app/controllers/concerns/.keep +0 -0
- data/spec/dummy/app/controllers/images_controller.rb +8 -0
- data/spec/dummy/app/helpers/application_helper.rb +2 -0
- data/spec/dummy/app/mailers/.keep +0 -0
- data/spec/dummy/app/models/.keep +0 -0
- data/spec/dummy/app/models/concerns/.keep +0 -0
- data/spec/dummy/app/models/dummy.rb +32 -0
- data/spec/dummy/app/views/images/index.html.erb +1 -0
- data/spec/dummy/app/views/layouts/application.html.erb +14 -0
- data/spec/dummy/bin/bundle +3 -0
- data/spec/dummy/bin/rails +4 -0
- data/spec/dummy/bin/rake +4 -0
- data/spec/dummy/config/application.rb +31 -0
- data/spec/dummy/config/boot.rb +5 -0
- data/spec/dummy/config/database.yml +25 -0
- data/spec/dummy/config/environment.rb +5 -0
- data/spec/dummy/config/environments/development.rb +29 -0
- data/spec/dummy/config/environments/production.rb +80 -0
- data/spec/dummy/config/environments/test.rb +36 -0
- data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/dummy/config/initializers/filter_parameter_logging.rb +4 -0
- data/spec/dummy/config/initializers/inflections.rb +16 -0
- data/spec/dummy/config/initializers/mime_types.rb +5 -0
- data/spec/dummy/config/initializers/secret_token.rb +12 -0
- data/spec/dummy/config/initializers/session_store.rb +3 -0
- data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/spec/dummy/config/locales/en.yml +23 -0
- data/spec/dummy/config/routes.rb +3 -0
- data/spec/dummy/config.ru +4 -0
- data/spec/dummy/db/schema.rb +16 -0
- data/spec/dummy/lib/assets/.keep +0 -0
- data/spec/dummy/log/.keep +0 -0
- data/spec/dummy/log/development.log +0 -0
- data/spec/dummy/public/404.html +58 -0
- data/spec/dummy/public/422.html +58 -0
- data/spec/dummy/public/500.html +57 -0
- data/spec/dummy/public/favicon.ico +0 -0
- data/spec/features/engine_spec.rb +8 -0
- data/spec/features/navigation_spec.rb +90 -0
- data/spec/features/render_gallery_spec.rb +19 -0
- data/spec/features/scale_spec.rb +78 -0
- data/spec/features/viewer_spec.rb +40 -0
- data/spec/generators/install_spec.rb +19 -0
- data/spec/lib/hermitage/defaults_spec.rb +18 -0
- data/spec/lib/hermitage/railtie_spec.rb +7 -0
- data/spec/lib/hermitage/view_helpers_spec.rb +71 -0
- data/spec/lib/hermitage_spec.rb +11 -0
- data/spec/spec_helper.rb +26 -0
- metadata +362 -0
@@ -0,0 +1,58 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>The change you wanted was rejected (422)</title>
|
5
|
+
<style>
|
6
|
+
body {
|
7
|
+
background-color: #EFEFEF;
|
8
|
+
color: #2E2F30;
|
9
|
+
text-align: center;
|
10
|
+
font-family: arial, sans-serif;
|
11
|
+
}
|
12
|
+
|
13
|
+
div.dialog {
|
14
|
+
width: 25em;
|
15
|
+
margin: 4em auto 0 auto;
|
16
|
+
border: 1px solid #CCC;
|
17
|
+
border-right-color: #999;
|
18
|
+
border-left-color: #999;
|
19
|
+
border-bottom-color: #BBB;
|
20
|
+
border-top: #B00100 solid 4px;
|
21
|
+
border-top-left-radius: 9px;
|
22
|
+
border-top-right-radius: 9px;
|
23
|
+
background-color: white;
|
24
|
+
padding: 7px 4em 0 4em;
|
25
|
+
}
|
26
|
+
|
27
|
+
h1 {
|
28
|
+
font-size: 100%;
|
29
|
+
color: #730E15;
|
30
|
+
line-height: 1.5em;
|
31
|
+
}
|
32
|
+
|
33
|
+
body > p {
|
34
|
+
width: 33em;
|
35
|
+
margin: 0 auto 1em;
|
36
|
+
padding: 1em 0;
|
37
|
+
background-color: #F7F7F7;
|
38
|
+
border: 1px solid #CCC;
|
39
|
+
border-right-color: #999;
|
40
|
+
border-bottom-color: #999;
|
41
|
+
border-bottom-left-radius: 4px;
|
42
|
+
border-bottom-right-radius: 4px;
|
43
|
+
border-top-color: #DADADA;
|
44
|
+
color: #666;
|
45
|
+
box-shadow:0 3px 8px rgba(50, 50, 50, 0.17);
|
46
|
+
}
|
47
|
+
</style>
|
48
|
+
</head>
|
49
|
+
|
50
|
+
<body>
|
51
|
+
<!-- This file lives in public/422.html -->
|
52
|
+
<div class="dialog">
|
53
|
+
<h1>The change you wanted was rejected.</h1>
|
54
|
+
<p>Maybe you tried to change something you didn't have access to.</p>
|
55
|
+
</div>
|
56
|
+
<p>If you are the application owner check the logs for more information.</p>
|
57
|
+
</body>
|
58
|
+
</html>
|
@@ -0,0 +1,57 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>We're sorry, but something went wrong (500)</title>
|
5
|
+
<style>
|
6
|
+
body {
|
7
|
+
background-color: #EFEFEF;
|
8
|
+
color: #2E2F30;
|
9
|
+
text-align: center;
|
10
|
+
font-family: arial, sans-serif;
|
11
|
+
}
|
12
|
+
|
13
|
+
div.dialog {
|
14
|
+
width: 25em;
|
15
|
+
margin: 4em auto 0 auto;
|
16
|
+
border: 1px solid #CCC;
|
17
|
+
border-right-color: #999;
|
18
|
+
border-left-color: #999;
|
19
|
+
border-bottom-color: #BBB;
|
20
|
+
border-top: #B00100 solid 4px;
|
21
|
+
border-top-left-radius: 9px;
|
22
|
+
border-top-right-radius: 9px;
|
23
|
+
background-color: white;
|
24
|
+
padding: 7px 4em 0 4em;
|
25
|
+
}
|
26
|
+
|
27
|
+
h1 {
|
28
|
+
font-size: 100%;
|
29
|
+
color: #730E15;
|
30
|
+
line-height: 1.5em;
|
31
|
+
}
|
32
|
+
|
33
|
+
body > p {
|
34
|
+
width: 33em;
|
35
|
+
margin: 0 auto 1em;
|
36
|
+
padding: 1em 0;
|
37
|
+
background-color: #F7F7F7;
|
38
|
+
border: 1px solid #CCC;
|
39
|
+
border-right-color: #999;
|
40
|
+
border-bottom-color: #999;
|
41
|
+
border-bottom-left-radius: 4px;
|
42
|
+
border-bottom-right-radius: 4px;
|
43
|
+
border-top-color: #DADADA;
|
44
|
+
color: #666;
|
45
|
+
box-shadow:0 3px 8px rgba(50, 50, 50, 0.17);
|
46
|
+
}
|
47
|
+
</style>
|
48
|
+
</head>
|
49
|
+
|
50
|
+
<body>
|
51
|
+
<!-- This file lives in public/500.html -->
|
52
|
+
<div class="dialog">
|
53
|
+
<h1>We're sorry, but something went wrong.</h1>
|
54
|
+
</div>
|
55
|
+
<p>If you are the application owner check the logs for more information.</p>
|
56
|
+
</body>
|
57
|
+
</html>
|
File without changes
|
@@ -0,0 +1,90 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe 'navigation', type: :feature, js: true do
|
4
|
+
|
5
|
+
# Workaround for clicking exactly on the specified position of the element
|
6
|
+
def click_at(selector, offset_x, offset_y)
|
7
|
+
x = evaluate_script("$('#{selector}').position().left + $('#{selector}').outerWidth() * #{offset_x}")
|
8
|
+
y = evaluate_script("$('#{selector}').position().top + $('#{selector}').outerHeight() * #{offset_y}")
|
9
|
+
page.driver.click(x, y)
|
10
|
+
end
|
11
|
+
|
12
|
+
def click_at_left(selector)
|
13
|
+
click_at(selector, 0.25, 0.5)
|
14
|
+
end
|
15
|
+
|
16
|
+
def click_at_right(selector)
|
17
|
+
click_at(selector, 0.75, 0.5)
|
18
|
+
end
|
19
|
+
|
20
|
+
|
21
|
+
shared_examples 'navigation to next' do
|
22
|
+
before(:each) { click_action.call() }
|
23
|
+
|
24
|
+
it 'shows next image and shows the first image after end of the gallery' do
|
25
|
+
# Wait until 2-full.png image will be shown
|
26
|
+
page.should have_no_css('img[src="/assets/1-full.png"]')
|
27
|
+
page.should have_css('img[src="/assets/2-full.png"]')
|
28
|
+
page.all('img.current').length.should == 1
|
29
|
+
|
30
|
+
# Then click
|
31
|
+
click_action.call()
|
32
|
+
|
33
|
+
# Now there is only 0-full.png image on the screen
|
34
|
+
page.should have_no_css('img[src="/assets/2-full.png"]')
|
35
|
+
page.should have_css('img[src="/assets/0-full.png"]')
|
36
|
+
page.all('img.current').length.should == 1
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
shared_examples 'navigation to previous' do
|
41
|
+
before(:each) { click_action.call() }
|
42
|
+
|
43
|
+
it 'shows previous image and shows the last image after first' do
|
44
|
+
# Wait until 0-full.png image will be shown
|
45
|
+
page.should have_no_css('img[src="/assets/1-full.png"]')
|
46
|
+
page.should have_css('img[src="/assets/0-full.png"]')
|
47
|
+
page.all('img.current').length.should == 1
|
48
|
+
|
49
|
+
# Then click
|
50
|
+
click_action.call()
|
51
|
+
|
52
|
+
# Now there is only 2-full.png image on the screen
|
53
|
+
page.should have_no_css('img[src="/assets/0-full.png"]')
|
54
|
+
page.should have_css('img[src="/assets/2-full.png"]')
|
55
|
+
page.all('img.current').length.should == 1
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
|
60
|
+
before(:each) do
|
61
|
+
visit images_path
|
62
|
+
page.first('a[href="/assets/1-full.png"]').click
|
63
|
+
page.should have_css('img.current') # Wait for loading before testing
|
64
|
+
end
|
65
|
+
|
66
|
+
describe 'by clicking on image' do
|
67
|
+
describe 'at the right side' do
|
68
|
+
let(:click_action) { Proc.new { click_at_right('img.current') } }
|
69
|
+
it_behaves_like 'navigation to next'
|
70
|
+
end
|
71
|
+
|
72
|
+
describe 'at the left side' do
|
73
|
+
let(:click_action) { Proc.new { click_at_left('img.current') } }
|
74
|
+
it_behaves_like 'navigation to previous'
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
describe 'by clicking on navigation button' do
|
79
|
+
describe 'right' do
|
80
|
+
let(:click_action) { Proc.new { page.find('#navigation-right').click() } }
|
81
|
+
it_behaves_like 'navigation to next'
|
82
|
+
end
|
83
|
+
|
84
|
+
describe 'left' do
|
85
|
+
let(:click_action) { Proc.new { page.find('#navigation-left').click() } }
|
86
|
+
it_behaves_like 'navigation to previous'
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe 'render gallery', type: :feature, js: true do
|
4
|
+
|
5
|
+
before(:each) { visit images_path }
|
6
|
+
|
7
|
+
it 'renders unordered list of links that contain images' do
|
8
|
+
page.should have_selector('ul li a[rel=hermitage] img')
|
9
|
+
end
|
10
|
+
|
11
|
+
it 'has invisible layer for hermitage' do
|
12
|
+
page.should have_css('div#hermitage', visible: false)
|
13
|
+
end
|
14
|
+
|
15
|
+
it 'fills images array' do
|
16
|
+
evaluate_script("images").should == ['/assets/0-full.png', '/assets/1-full.png', '/assets/2-full.png']
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
@@ -0,0 +1,78 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe 'scale', type: :feature, js: true do
|
4
|
+
|
5
|
+
def width(selector)
|
6
|
+
evaluate_script("$('#{selector}').outerWidth()")
|
7
|
+
end
|
8
|
+
|
9
|
+
def height(selector)
|
10
|
+
evaluate_script("$('#{selector}').outerHeight()")
|
11
|
+
end
|
12
|
+
|
13
|
+
before(:each) do
|
14
|
+
visit images_path
|
15
|
+
page.driver.resize(window_width, window_height)
|
16
|
+
page.first('a[rel=hermitage]').click
|
17
|
+
page.should have_css('img.current')
|
18
|
+
end
|
19
|
+
|
20
|
+
context 'exceed the bounds of window by width' do
|
21
|
+
let(:window_width) { 400 }
|
22
|
+
let(:window_height) { 1000 }
|
23
|
+
|
24
|
+
it 'scales the image' do
|
25
|
+
width('.current').should == 176
|
26
|
+
height('.current').should == 176
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
context 'exceed the bounds of window by height' do
|
31
|
+
let(:window_width) { 1000 }
|
32
|
+
let(:window_height) { 300 }
|
33
|
+
|
34
|
+
it 'scales the image' do
|
35
|
+
width('.current').should == 200
|
36
|
+
height('.current').should == 200
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
context 'exceed the bounds of window by both dimensions' do
|
41
|
+
let(:window_width) { 400 }
|
42
|
+
let(:window_height) { 300 }
|
43
|
+
|
44
|
+
it 'scales the image to the minimum scale coefficient' do
|
45
|
+
width('.current').should == 176
|
46
|
+
height('.current').should == 176
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
context 'window is smaller than minimum allowed size' do
|
51
|
+
|
52
|
+
shared_examples 'minimum allowed size' do
|
53
|
+
it 'scales the image to the minimal allowed size' do
|
54
|
+
width('.current').should == 100
|
55
|
+
height('.current').should == 100
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
context 'by width' do
|
60
|
+
let(:window_width) { 200 }
|
61
|
+
let(:window_height) { 1000 }
|
62
|
+
it_behaves_like 'minimum allowed size'
|
63
|
+
end
|
64
|
+
|
65
|
+
context 'by height' do
|
66
|
+
let(:window_width) { 1000 }
|
67
|
+
let(:window_height) { 200 }
|
68
|
+
it_behaves_like 'minimum allowed size'
|
69
|
+
end
|
70
|
+
|
71
|
+
context 'by both dimensions' do
|
72
|
+
let(:window_width) { 200 }
|
73
|
+
let(:window_height) { 200 }
|
74
|
+
it_behaves_like 'minimum allowed size'
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe 'viewer', type: :feature, js: true do
|
4
|
+
|
5
|
+
before(:each) do
|
6
|
+
visit images_path
|
7
|
+
page.first('a[rel=hermitage]').click
|
8
|
+
end
|
9
|
+
|
10
|
+
it 'makes hermitage layer visible' do
|
11
|
+
page.should have_css('div#hermitage')
|
12
|
+
end
|
13
|
+
|
14
|
+
it 'has shadow overlay' do
|
15
|
+
page.should have_css('div#hermitage div#overlay')
|
16
|
+
end
|
17
|
+
|
18
|
+
it 'has full size image' do
|
19
|
+
page.should have_css("div#hermitage img[src='/assets/0-full.png']")
|
20
|
+
end
|
21
|
+
|
22
|
+
it 'has left navigation button' do
|
23
|
+
page.should have_css("div#hermitage div#navigation-left")
|
24
|
+
end
|
25
|
+
|
26
|
+
it 'has right navigation button' do
|
27
|
+
page.should have_css("div#hermitage div#navigation-right")
|
28
|
+
end
|
29
|
+
|
30
|
+
describe 'visitor clicks on shadow in the viewer' do
|
31
|
+
# Workaround for clicking at the shadow div
|
32
|
+
before(:each) { evaluate_script "$('#overlay').click()" }
|
33
|
+
|
34
|
+
it 'hides hermitage layer and removes everything from it' do
|
35
|
+
page.should_not have_css('div#hermitage')
|
36
|
+
page.find('div#hermitage', visible: false).all('*').length.should == 0
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'genspec'
|
3
|
+
|
4
|
+
describe 'hermitage:install' do
|
5
|
+
|
6
|
+
within_source_root do
|
7
|
+
FileUtils.mkdir_p 'app/assets/javascripts'
|
8
|
+
FileUtils.touch 'app/assets/javascripts/application.js'
|
9
|
+
end
|
10
|
+
|
11
|
+
it 'generates configuration file at config/initializer' do
|
12
|
+
subject.should generate('config/initializers/hermitage.rb')
|
13
|
+
end
|
14
|
+
|
15
|
+
it "should inject a require into application.js file" do
|
16
|
+
subject.should inject_into_file('app/assets/javascripts/application.js', "\n//= require hermitage", after: %r{^//= require +['"]?jquery['"]?$})
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Hermitage::Defaults do
|
4
|
+
describe '#to_hash' do
|
5
|
+
it "returns hash with symbolized constants' names as keys" do
|
6
|
+
Hermitage::Defaults.to_hash().should == {
|
7
|
+
attribute_full_size: 'file.url',
|
8
|
+
attribute_thumbnail: 'file.url(:thumbnail)',
|
9
|
+
list_tag: :ul,
|
10
|
+
item_tag: :li,
|
11
|
+
list_class: 'thumbnails',
|
12
|
+
item_class: 'span4',
|
13
|
+
link_class: 'thumbnail',
|
14
|
+
image_class: nil
|
15
|
+
}
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,71 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'dummy/app/models/dummy'
|
3
|
+
|
4
|
+
describe Hermitage::ViewHelpers, type: :helper do
|
5
|
+
|
6
|
+
# Reset Hermitage configs because they should not be shared among specs
|
7
|
+
before(:each) { Hermitage.configs = { default: Hermitage::Defaults.to_hash() } }
|
8
|
+
|
9
|
+
let(:template) { ActionView::Base.new }
|
10
|
+
|
11
|
+
describe '#render_gallery_for' do
|
12
|
+
let(:images) { Array.new(2) { |i| DummyImage.new(i.to_s) } }
|
13
|
+
let(:expected) { '<ul class="thumbnails"><li class="span4"><a class="thumbnail" href="/assets/0-full.png" rel="hermitage"><img alt="0 thumbnail" src="/assets/0-thumbnail.png" /></a></li><li class="span4"><a class="thumbnail" href="/assets/1-full.png" rel="hermitage"><img alt="1 thumbnail" src="/assets/1-thumbnail.png" /></a></li></ul>' }
|
14
|
+
|
15
|
+
context 'no options' do
|
16
|
+
subject { template.render_gallery_for images }
|
17
|
+
it { should == expected }
|
18
|
+
end
|
19
|
+
|
20
|
+
context 'with options' do
|
21
|
+
|
22
|
+
context 'attribute_full_size and attribute_thumbnail' do
|
23
|
+
subject { template.render_gallery_for images, attribute_full_size: 'photo', attribute_thumbnail: 'photo(:thumbnail)' }
|
24
|
+
let(:images) { Array.new(2) { |i| DummyPhoto.new(i.to_s) } }
|
25
|
+
it { should == expected }
|
26
|
+
end
|
27
|
+
|
28
|
+
context 'list_tag and item_tag' do
|
29
|
+
subject { template.render_gallery_for images, list_tag: :div, item_tag: :div }
|
30
|
+
let(:expected) { '<div class="thumbnails"><div class="span4"><a class="thumbnail" href="/assets/0-full.png" rel="hermitage"><img alt="0 thumbnail" src="/assets/0-thumbnail.png" /></a></div><div class="span4"><a class="thumbnail" href="/assets/1-full.png" rel="hermitage"><img alt="1 thumbnail" src="/assets/1-thumbnail.png" /></a></div></div>' }
|
31
|
+
it { should == expected }
|
32
|
+
end
|
33
|
+
|
34
|
+
context 'list_class, item_class, link_class and image_class' do
|
35
|
+
subject { template.render_gallery_for images, list_class: nil, item_class: nil, link_class: 'thumb link', image_class: 'thumb' }
|
36
|
+
let(:expected) { '<ul><li><a class="thumb link" href="/assets/0-full.png" rel="hermitage"><img alt="0 thumbnail" class="thumb" src="/assets/0-thumbnail.png" /></a></li><li><a class="thumb link" href="/assets/1-full.png" rel="hermitage"><img alt="1 thumbnail" class="thumb" src="/assets/1-thumbnail.png" /></a></li></ul>' }
|
37
|
+
it { should == expected }
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
context 'with configs' do
|
42
|
+
|
43
|
+
before(:each) { Hermitage.configs[:dummy_images] = { list_class: 'images-thumbnails' } }
|
44
|
+
|
45
|
+
let(:expected) { '<ul class="images-thumbnails"><li class="span4"><a class="thumbnail" href="/assets/0-full.png" rel="hermitage"><img alt="0 thumbnail" src="/assets/0-thumbnail.png" /></a></li><li class="span4"><a class="thumbnail" href="/assets/1-full.png" rel="hermitage"><img alt="1 thumbnail" src="/assets/1-thumbnail.png" /></a></li></ul>' }
|
46
|
+
subject { template.render_gallery_for images }
|
47
|
+
it { should == expected }
|
48
|
+
|
49
|
+
context 'with overwritten defaults' do
|
50
|
+
|
51
|
+
before(:each) do
|
52
|
+
Hermitage.configs[:default].merge!({
|
53
|
+
list_class: 'default-thumbnails',
|
54
|
+
item_class: 'span3'
|
55
|
+
})
|
56
|
+
end
|
57
|
+
|
58
|
+
let(:expected) { '<ul class="images-thumbnails"><li class="span3"><a class="thumbnail" href="/assets/0-full.png" rel="hermitage"><img alt="0 thumbnail" src="/assets/0-thumbnail.png" /></a></li><li class="span3"><a class="thumbnail" href="/assets/1-full.png" rel="hermitage"><img alt="1 thumbnail" src="/assets/1-thumbnail.png" /></a></li></ul>' }
|
59
|
+
it { should == expected }
|
60
|
+
|
61
|
+
context 'and with options' do
|
62
|
+
subject { template.render_gallery_for images, list_class: 'custom-thumbnails' }
|
63
|
+
let(:expected) { '<ul class="custom-thumbnails"><li class="span3"><a class="thumbnail" href="/assets/0-full.png" rel="hermitage"><img alt="0 thumbnail" src="/assets/0-thumbnail.png" /></a></li><li class="span3"><a class="thumbnail" href="/assets/1-full.png" rel="hermitage"><img alt="1 thumbnail" src="/assets/1-thumbnail.png" /></a></li></ul>' }
|
64
|
+
it { should == expected }
|
65
|
+
end
|
66
|
+
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
end
|
71
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Hermitage do
|
4
|
+
it 'should has a version' do
|
5
|
+
Hermitage::VERSION.should_not be_nil
|
6
|
+
end
|
7
|
+
|
8
|
+
it { should respond_to(:configs) }
|
9
|
+
its(:configs) { should be_kind_of(Hash) }
|
10
|
+
its(:configs) { should include(:default) }
|
11
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
# Configure Rails Envinronment
|
2
|
+
ENV["RAILS_ENV"] = "test"
|
3
|
+
require File.expand_path("../dummy/config/environment.rb", __FILE__)
|
4
|
+
|
5
|
+
require 'rspec/rails'
|
6
|
+
require 'capybara/poltergeist'
|
7
|
+
|
8
|
+
ENGINE_RAILS_ROOT=File.join(File.dirname(__FILE__), '../')
|
9
|
+
|
10
|
+
# Requires supporting ruby files with custom matchers and macros, etc,
|
11
|
+
# in spec/support/ and its subdirectories.
|
12
|
+
Dir[File.join(ENGINE_RAILS_ROOT, "spec/support/**/*.rb")].each {|f| require f }
|
13
|
+
|
14
|
+
RSpec.configure do |config|
|
15
|
+
config.treat_symbols_as_metadata_keys_with_true_values = true
|
16
|
+
config.run_all_when_everything_filtered = true
|
17
|
+
config.filter_run :focus
|
18
|
+
|
19
|
+
# Run specs in random order to surface order dependencies. If you find an
|
20
|
+
# order dependency and want to debug it, you can fix the order by providing
|
21
|
+
# the seed, which is printed after each run.
|
22
|
+
# --seed 1234
|
23
|
+
config.order = 'random'
|
24
|
+
end
|
25
|
+
|
26
|
+
Capybara.javascript_driver = :poltergeist
|