diff --git a/app/views/items/_item.html.erb b/app/views/items/_item.html.erb
index fd0f619..e5e1406 100644
--- a/app/views/items/_item.html.erb
+++ b/app/views/items/_item.html.erb
@@ -10,7 +10,7 @@
<%= hidden_field_tag 'image_height', item.image_height %>
- <% if item.has_valid_image? %>
+ <% if item.valid_image? %>
<%= image_tag item.image_url, width: item.image_width,
height: item.image_height %>
<% end %>
diff --git a/lib/amazon_product_api/search_item.rb b/lib/amazon_product_api/search_item.rb
index 6e2467c..2e97536 100644
--- a/lib/amazon_product_api/search_item.rb
+++ b/lib/amazon_product_api/search_item.rb
@@ -31,7 +31,7 @@ def valid?
price != "$0.00"
end
- def has_valid_image?
+ def valid_image?
image.valid?
end
diff --git a/spec/lib/amazon_product_api/search_item_spec.rb b/spec/lib/amazon_product_api/search_item_spec.rb
index 4b6c18f..c5720b8 100644
--- a/spec/lib/amazon_product_api/search_item_spec.rb
+++ b/spec/lib/amazon_product_api/search_item_spec.rb
@@ -14,18 +14,18 @@
end
describe "#valid_image?" do
- context "when all image attributes are valid" do
- subject { AmazonProductAPI::SearchItem.new(image_url: "image url",
- image_height: 600,
- image_width: 800) }
- it { should have_valid_image }
+ it "returns true for valid data" do
+ item = AmazonProductAPI::SearchItem.new(image_url: "image url",
+ image_height: 600,
+ image_width: 800)
+ expect(item.valid_image?).to eq true
end
- context "when there is no image url" do
- subject { AmazonProductAPI::SearchItem.new(image_url: nil,
- image_height: 100,
- image_width: 100) }
- it { should_not have_valid_image }
+ it "returns false for invalid data" do
+ item = AmazonProductAPI::SearchItem.new(image_url: nil,
+ image_height: 600,
+ image_width: 800)
+ expect(item.valid_image?).to eq false
end
end
end
|