spec/helpers/form_helpers_spec.rb in papercrop-0.2.0 vs spec/helpers/form_helpers_spec.rb in papercrop-0.3.0

- old
+ new

@@ -2,11 +2,11 @@ describe "Form Helpers" do before do @landscape = Landscape.new(:name => "Mountains") - @landscape.picture = open("test_app/test/fixtures/matterhorn.jpg") + @landscape.picture = open(mountains_img_path) @landscape.save @box = nil end @@ -15,14 +15,14 @@ form_for @landscape do |f| @box = f.cropbox(:picture) end @box = HTML::Document.new(@box) - assert_select @box.root, 'input#landscape_picture_original_w', :value => "1024.0" - assert_select @box.root, 'input#landscape_picture_original_h', :value => "768.0" - assert_select @box.root, 'input#landscape_picture_box_w', :value => "1024.0" - assert_select @box.root, 'input#picture_aspect', :value => @landscape.picture_aspect.to_s + assert_select @box.root, 'input#landscape_picture_original_w[value="1024"]' + assert_select @box.root, 'input#landscape_picture_original_h[value="768"]' + assert_select @box.root, 'input#landscape_picture_box_w[value="1024"]' + assert_select @box.root, "input#picture_aspect[value=\"#{@landscape.picture_aspect.to_s}\"]" assert_select @box.root, 'input#picture_crop_x' assert_select @box.root, 'input#picture_crop_y' assert_select @box.root, 'input#picture_crop_w' assert_select @box.root, 'input#picture_crop_h' @@ -36,30 +36,40 @@ form_for @landscape do |f| @box = f.cropbox(:picture, :width => 400) end @box = HTML::Document.new(@box) - assert_select @box.root, 'input#landscape_picture_box_w', :value => "400" + assert_select @box.root, 'input#landscape_picture_box_w[value="400"]' end + it "builds the crop box with unlocked aspect flag" do + form_for @landscape do |f| + @box = f.cropbox(:picture, :width => 400, :aspect => false) + end + @box = HTML::Document.new(@box) + + assert_select @box.root, 'input#picture_aspect[value="false"]' + end + + it "builds the preview box" do form_for @landscape do |f| @box = f.crop_preview(:picture) end @box = HTML::Document.new(@box) - assert_select @box.root, 'div#picture_crop_preview_wrapper', :style => "width:100px; height:75px; overflow:hidden" do - assert_select 'img#picture_crop_preview', :src => @landscape.picture.path(:original) + assert_select @box.root, 'div#picture_crop_preview_wrapper[style="width:100px; height:75px; overflow:hidden"]' do + assert_select "img#picture_crop_preview[src=\"#{@landscape.picture.url(:original)}\"]" end end it "build the preview box with different width" do form_for @landscape do |f| @box = f.crop_preview(:picture, :width => 40) end @box = HTML::Document.new(@box) - assert_select @box.root, 'div#picture_crop_preview_wrapper', :style => "width:40px; height:30px; overflow:hidden" + assert_select @box.root, 'div#picture_crop_preview_wrapper[style="width:40px; height:30px; overflow:hidden"]' end -end \ No newline at end of file +end