Sha256: 8251c60089c0fbca3def1ad905bd5b759529fc3c41f138411b3c98bf67b9f795

Contents?: true

Size: 1.75 KB

Versions: 8

Compression:

Stored size: 1.75 KB

Contents

$:.unshift File.join(File.dirname(__FILE__))
require 'bench_spec_helper'
require 'rest_client'

describe "ResultSpec" do
  # it_should_behave_like "BenchSpecHelper"

  include Utils
  it_behaves_like "BenchSpecHelper" do
    before(:each) do
      @s1 = [{"foo" => {"bar" => "cake"}}]
      @s2 = [{"foo" => {"bar" => "cake1"}},{"hello" => "world"}]
      @result = Result.new("marker",:get,"some/url",0,1)
      client = mock("RestClient")
      client.stub!(:headers).and_return({'header1'=>'headervalue1'})
      client.stub!(:cookies).and_return({'session1'=>'sessval1'})
      client.stub!(:code).and_return(200)
      client.stub!(:to_s).and_return(@s1.to_json)
      @result.last_response = client
    end

    describe "test @last_response wrapper" do

      it "should return 'code'" do
        @result.code.should == 200
      end

      it "should return 'body'" do
        JSON.parse(@result.body).should == @s1
      end

      it "should return 'cookies'" do
        @result.cookies.should == {'session1'=>'sessval1'}
      end

      it "shhould return 'headers'" do
        @result.headers.should == {'header1'=>'headervalue1'}
      end

    end

    it "should compare two array/hash structures" do
      compare(:expected,@s1,:actual,@s2).should == [{:expected=>"cake", 
        :path=>[0, "foo", "bar"], :actual=>"cake1"}, 
        {:expected=>nil, :path=>[1], :actual=>{"hello"=>"world"}}]
    end

    it "should verify body" do
      @result.should_receive(:bench_log).exactly(8).times
      @result.verify_body(@s2.to_json)
      @result.verification_error.should == 1
    end  

    it "should verify code" do
      @result.should_receive(:bench_log).exactly(4).times
      @result.verify_code(500)
      @result.verification_error.should == 1
    end
  end
  
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
rhoconnect-4.0.4 bench/spec/result_spec.rb
rhoconnect-4.0.3 bench/spec/result_spec.rb
rhoconnect-4.0.2 bench/spec/result_spec.rb
rhoconnect-4.0.1 bench/spec/result_spec.rb
rhoconnect-4.0.0 bench/spec/result_spec.rb
rhoconnect-4.0.0.beta.24 bench/spec/result_spec.rb
rhoconnect-4.0.0.beta.10 bench/spec/result_spec.rb
rhoconnect-4.0.0.beta.12 bench/spec/result_spec.rb