spec/session_spec.rb in patron-0.6.0 vs spec/session_spec.rb in patron-0.6.1

- old
+ new

@@ -19,10 +19,12 @@ ## LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, ## OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN ## THE SOFTWARE. ## ## ------------------------------------------------------------------- + + require File.expand_path("./spec") + '/spec_helper.rb' require 'webrick' require 'yaml' require 'base64' require 'fileutils' @@ -284,10 +286,22 @@ response = @session.get("/test") body = YAML::load(response.body) expect(body.header['authorization']).to be == [encode_authz("foo", "bar")] end + it "should store cookies across multiple requests" do + tf = Tempfile.new('cookiejar') + cookie_jar_path = tf.path + + @session.handle_cookies(cookie_jar_path) + response = @session.get("/setcookie").body + + cookie_jar_contents = tf.read + expect(cookie_jar_contents).not_to be_empty + expect(cookie_jar_contents).to include('Netscape HTTP Cookie File') + end + it "should handle cookies if set" do @session.handle_cookies response = @session.get("/setcookie").body expect(YAML::load(response).header['cookie'].first).to be == "session_id=foo123" end @@ -469,13 +483,15 @@ # ------------------------------------------------------------------------ describe 'when debug is enabled' do it 'it should not clobber stderr' do rdev = STDERR.stat.rdev - @session.enable_debug + retval = @session.enable_debug + expect(retval).to eq(@session) expect(STDERR.stat.rdev).to be == rdev - @session.enable_debug + retval = @session.enable_debug + expect(retval).to eq(@session) expect(STDERR.stat.rdev).to be == rdev end end end