On 2008-11-14, at 06:29, Mano ah wrote:
can i know how to test a picture upload which dosent interact with db

my code is


 def scan
 #-------

   if request.post?

     image = Image.new

     image.blob= params[:image][:blob]

     image.save_picture

   end
--

Hi Mano. It doesn't really matter whether or not your "picture" model interacts with a database. Simply use mocks and stubs when speccing #scan , and you'll be good. For example:

describe '#scan' do
  describe 'receives a POST request' do
    before :each do
      # mock an Image instance
      # stub Image#new
    end

    it 'should create a new Image'
    it "should set the new image's 'blob' attribute"
    it 'should save the new image'
  end

  describe 'receives a non-POST request' do
    # stuff here
  end
end

Obviously you have to fill in the contents of those #it blocks, but that's really all you need.
-Nick
_______________________________________________
rspec-users mailing list
rspec-users@rubyforge.org
http://rubyforge.org/mailman/listinfo/rspec-users

Reply via email to