Sha256: 737c8515488b7920089bf6133c1814c521bb6a99595dab1ca1c2ae5702ddc6b4

Contents?: true

Size: 1.74 KB

Versions: 35

Compression:

Stored size: 1.74 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 "shold return 'code'" do
        @result.code.should == 200
      end

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

      it "shold 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

35 entries across 35 versions & 1 rubygems

Version Path
rhoconnect-3.4.5 bench/spec/result_spec.rb
rhoconnect-3.4.4 bench/spec/result_spec.rb
rhoconnect-3.4.3 bench/spec/result_spec.rb
rhoconnect-3.4.2 bench/spec/result_spec.rb
rhoconnect-3.3.6 bench/spec/result_spec.rb
rhoconnect-3.3.5 bench/spec/result_spec.rb
rhoconnect-3.3.4 bench/spec/result_spec.rb
rhoconnect-3.3.3 bench/spec/result_spec.rb
rhoconnect-3.3.2 bench/spec/result_spec.rb
rhoconnect-3.3.1 bench/spec/result_spec.rb
rhoconnect-3.3.1.beta4 bench/spec/result_spec.rb
rhoconnect-3.3.1.beta3 bench/spec/result_spec.rb
rhoconnect-3.3.1.beta2 bench/spec/result_spec.rb
rhoconnect-3.2.1 bench/spec/result_spec.rb
rhoconnect-3.2.0 bench/spec/result_spec.rb
rhoconnect-3.2.0.beta5 bench/spec/result_spec.rb
rhoconnect-3.2.0.beta4 bench/spec/result_spec.rb
rhoconnect-3.2.0.beta3 bench/spec/result_spec.rb
rhoconnect-3.2.0.beta2 bench/spec/result_spec.rb
rhoconnect-3.2.0.beta1 bench/spec/result_spec.rb