Sha256: 9c555f9e11b4e5e62b2952de3589670e1914cab42a8eb5194f4513c42969e731

Contents?: true

Size: 1.24 KB

Versions: 2

Compression:

Stored size: 1.24 KB

Contents

require File.expand_path("#{File.dirname(__FILE__)}/../../unit_spec_helper")

module JsSpec
  module Resources
    describe SuiteFinish do
    attr_reader :stdout, :suite_finish, :suite
    before do
      @stdout = StringIO.new
      SuiteFinish.const_set(:STDOUT, stdout)
      @suite = Suite.new('foobar')
      @suite_finish = SuiteFinish.new(suite)
    end

    after do
      SuiteFinish.__send__(:remove_const, :STDOUT)
    end

    describe ".post" do
      describe "when the request has no guid" do
        it "writes the body of the request to stdout" do
          body = "The text in the POST body"
          request = Rack::Request.new({'rack.input' => StringIO.new("text=#{body}")})
          request.body.string.should == "text=#{body}"
          response = Rack::Response.new

          suite_finish.post(request, response)
          stdout.string.should == "#{body}\n"
        end

        it "returns an empty string" do
          body = "The text in the POST body"
          request = Rack::Request.new({'rack.input' => StringIO.new("text=#{body}")})
          request.body.string.should == "text=#{body}"
          response = Rack::Response.new

          suite_finish.post(request, response).should == ""
        end
      end
    end
  end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
js_spec-0.2.0 spec/unit/js_spec/resources/suite_finish_spec.rb
js_spec-0.2.1 spec/unit/js_spec/resources/suite_finish_spec.rb