Hello everyone,


I'm trying to get to grips with the new allow syntax (for stubbing) in 
rspec 3.0 and would really appreciate someone looking at my code and 
telling me whether it's right(or wrong).

*download.rb*

class Download
  def download_file
    # code to download a file 
  end

  def valid_json
    # code to verify downloaded file is file type json
  endend

*download_spec.rb*

require 'spec_helper'
require 'json_spec'  

describe Download do 
  let(:download)  {Download.new}

  describe "#download_file" do
    it 'downloads a file from remote file location ' do
      allow(download).to receive(:exist).and_return(true)
      download.download_file
      expect(download).to have_received(:exist).and_return(true)    
    end 
  end   

  describe "#valid_json" do
    it 'confirms downloaded file is JSON' do
      # download.to_json.should have_json_path("id")
      # download.to_json.should have_json_type(Integer).at_path("id")
      expect(download.to_json).to have_json_path("id")
      expect(download.to_json).to have_json_type(Integer).at_path("id")
    end 
  endend  

Many thanks in advance!

-- 
You received this message because you are subscribed to the Google Groups 
"rspec" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rspec/3ace07ec-b440-47e5-9c09-ce6c14109f53%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to