Skip to content

Commit

Permalink
adds basic unit tests for error module
Browse files Browse the repository at this point in the history
  • Loading branch information
gruis committed Apr 3, 2013
1 parent 78b6965 commit 83cf16e
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 0 deletions.
47 changes: 47 additions & 0 deletions spec/error_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
require File.expand_path("../spec_helper", __FILE__)

describe SinatraWebsocket::Error::StandardError do
it "should be tagged with SinatraWebsocket::Error" do
subject.should be_a SinatraWebsocket::Error
end
end

describe SinatraWebsocket::Error::ConfigurationError do
it "should be tagged with SinatraWebsocket::Error" do
subject.should be_a SinatraWebsocket::Error
end
end

describe SinatraWebsocket::Error::ConnectionError do
it "should be tagged with SinatraWebsocket::Error" do
subject.should be_a SinatraWebsocket::Error
end
end

describe "Sinatra::Request" do
context "the request is not a websocket request" do
subject { Sinatra::Request.new({})}
describe "#websocket?" do
it { subject.websocket?.should be_nil }
end
describe "#websocket" do
it do
expect {
subject.websocket
}.to raise_error(SinatraWebsocket::Error::ConnectionError)
end
end
end
end

describe "Sinatra::Websoket::Connection" do
context "the request does not have an async callback" do
describe ".from_env" do
it "should raise SinatraWebsocket::Error::ConfigurationError" do
expect {
SinatraWebsocket::Connection.from_env({})
}.to raise_error(SinatraWebsocket::Error::ConfigurationError)
end
end
end
end
9 changes: 9 additions & 0 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
require "rspec"
require "sinatra"
require "sinatra-websocket"

module SinatraWebsocket
module Test

end
end

0 comments on commit 83cf16e

Please sign in to comment.