Skip to content

Commit d7de479

Browse files
authored
Merge pull request #158 from basemate/fix_issue_157
fixed image component and added missing img specs, #157
2 parents 6dd7fe5 + 4e476d0 commit d7de479

File tree

4 files changed

+30
-1
lines changed

4 files changed

+30
-1
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
= image_tag(@tag_attributes, ActionController::Base.helpers.asset_path(options[:path]), height: options[:height], width: options[:width], alt: options[:alt]])
1+
%img{@tag_attributes}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
module Matestack::Ui::Core::Img
22
class Img < Matestack::Ui::Core::Component::Static
33

4+
def setup
5+
@tag_attributes.merge!({
6+
src: ActionController::Base.helpers.asset_path(options[:path]),
7+
height: options[:height],
8+
width: options[:width],
9+
alt: options[:alt]
10+
})
11+
end
12+
413
end
514
end
Loading

spec/usage/components/img_spec.rb

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
require_relative '../../support/utils'
2+
include Utils
3+
4+
describe 'Img Component', type: :feature, js: true do
5+
6+
it 'Renders an image tag on the page' do
7+
8+
class ExamplePage < Matestack::Ui::Page
9+
def response
10+
components {
11+
img path: 'matestack-logo.png', width: 500, height: 300, alt: "logo"
12+
}
13+
end
14+
end
15+
16+
visit '/example'
17+
18+
expect(page).to have_xpath("//img[contains(@src,'matestack-logo') and @alt='logo' and @width='500' and @height='300']")
19+
end
20+
end

0 commit comments

Comments
 (0)