Skip to content

Commit

Permalink
setting not config defaults to nil
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanb committed Jan 15, 2012
1 parent 335f6e6 commit c1c42be
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
1 change: 1 addition & 0 deletions lib/generators/private_pub/templates/private_pub.yml
Expand Up @@ -7,3 +7,4 @@ test:
production:
server: "http://example.com/faye"
secret_token: "<%= ActiveSupport::SecureRandom.hex(32) %>"
signature_expiration: 3600 # one hour
5 changes: 1 addition & 4 deletions lib/private_pub.rb
Expand Up @@ -11,10 +11,7 @@ class << self
attr_reader :config

def reset_config
@config = {
:server => "http://localhost:9292/faye",
:signature_expiration => 60 * 60, # one hour
}
@config = {}
end

def load_config(filename, environment)
Expand Down
3 changes: 2 additions & 1 deletion spec/private_pub/faye_extension_spec.rb
Expand Up @@ -24,7 +24,8 @@
message["error"].should be_nil
end

it "has an error when signature is just expired" do
it "has an error when signature just expired" do
PrivatePub.config[:signature_expiration] = 1
sub = PrivatePub.subscription(:timestamp => 123, :channel => "hello")
@message["subscription"] = sub[:channel]
@message["ext"]["private_pub_signature"] = sub[:signature]
Expand Down
11 changes: 6 additions & 5 deletions spec/private_pub_spec.rb
Expand Up @@ -5,12 +5,12 @@
PrivatePub.reset_config
end

it "defaults server to localhost:9292/faye" do
PrivatePub.config[:server].should == "http://localhost:9292/faye"
it "defaults server to nil" do
PrivatePub.config[:server].should be_nil
end

it "defaults signature_expiration to 1 hour" do
PrivatePub.config[:signature_expiration].should == 60 * 60
it "defaults signature_expiration to nil" do
PrivatePub.config[:signature_expiration].should be_nil
end

it "defaults subscription timestamp to current time in milliseconds" do
Expand Down Expand Up @@ -76,8 +76,9 @@
end

it "publish message as json to server using Net::HTTP" do
PrivatePub.config[:server] = "http://localhost"
message = stub(:to_json => "message_json")
Net::HTTP.should_receive(:post_form).with(URI.parse(PrivatePub.config[:server]), :message => "message_json").and_return(:result)
Net::HTTP.should_receive(:post_form).with(URI.parse("http://localhost"), :message => "message_json").and_return(:result)
PrivatePub.publish_message(message).should == :result
end

Expand Down

0 comments on commit c1c42be

Please sign in to comment.