File tree 3 files changed +12
-12
lines changed
spec/lib/amazon_product_api
3 files changed +12
-12
lines changed Original file line number Diff line number Diff line change 10
10
<%= hidden_field_tag 'image_height' , item . image_height %>
11
11
12
12
< td >
13
- <% if item . has_valid_image ? %>
13
+ <% if item . valid_image ? %>
14
14
<%= image_tag item . image_url , width : item . image_width ,
15
15
height : item . image_height %>
16
16
<% end %>
Original file line number Diff line number Diff line change @@ -31,7 +31,7 @@ def valid?
31
31
price != "$0.00"
32
32
end
33
33
34
- def has_valid_image ?
34
+ def valid_image ?
35
35
image . valid?
36
36
end
37
37
Original file line number Diff line number Diff line change 14
14
end
15
15
16
16
describe "#valid_image?" do
17
- context "when all image attributes are valid" do
18
- subject { AmazonProductAPI ::SearchItem . new ( image_url : "image url" ,
19
- image_height : 600 ,
20
- image_width : 800 ) }
21
- it { should have_valid_image }
17
+ it "returns true for valid data " do
18
+ item = AmazonProductAPI ::SearchItem . new ( image_url : "image url" ,
19
+ image_height : 600 ,
20
+ image_width : 800 )
21
+ expect ( item . valid_image? ) . to eq true
22
22
end
23
23
24
- context "when there is no image url " do
25
- subject { AmazonProductAPI ::SearchItem . new ( image_url : nil ,
26
- image_height : 100 ,
27
- image_width : 100 ) }
28
- it { should_not have_valid_image }
24
+ it "returns false for invalid data " do
25
+ item = AmazonProductAPI ::SearchItem . new ( image_url : nil ,
26
+ image_height : 600 ,
27
+ image_width : 800 )
28
+ expect ( item . valid_image? ) . to eq false
29
29
end
30
30
end
31
31
end
You can’t perform that action at this time.
0 commit comments