Skip to content

fixed image component and added missing img specs, #157 #158

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 10, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/concepts/matestack/ui/core/img/img.haml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
= image_tag(@tag_attributes, ActionController::Base.helpers.asset_path(options[:path]), height: options[:height], width: options[:width], alt: options[:alt]])
%img{@tag_attributes}
9 changes: 9 additions & 0 deletions app/concepts/matestack/ui/core/img/img.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
module Matestack::Ui::Core::Img
class Img < Matestack::Ui::Core::Component::Static

def setup
@tag_attributes.merge!({
src: ActionController::Base.helpers.asset_path(options[:path]),
height: options[:height],
width: options[:width],
alt: options[:alt]
})
end

end
end
Binary file added spec/dummy/app/assets/images/matestack-logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
20 changes: 20 additions & 0 deletions spec/usage/components/img_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
require_relative '../../support/utils'
include Utils

describe 'Img Component', type: :feature, js: true do

it 'Renders an image tag on the page' do

class ExamplePage < Matestack::Ui::Page
def response
components {
img path: 'matestack-logo.png', width: 500, height: 300, alt: "logo"
}
end
end

visit '/example'

expect(page).to have_xpath("//img[contains(@src,'matestack-logo') and @alt='logo' and @width='500' and @height='300']")
end
end