spec/gems_spec.rb in gems-0.0.4 vs spec/gems_spec.rb in gems-0.0.5

- old
+ new

@@ -1,13 +1,21 @@ require 'helper' describe Gems do context "when delegating to a client" do before do + Gems.configure do |config| + config.username = 'nick@gemcutter.org' + config.password = 'schwwwwing' + end stub_get("/api/v1/gems/rails.json").to_return(:body => fixture("rails.json")) end + after do + Gems.reset + end + it "should get the correct resource" do Gems.info('rails') a_get("/api/v1/gems/rails.json").should have_been_made end @@ -23,8 +31,45 @@ end describe ".new" do it "should return a Gems::Client" do Gems.new.should be_a Gems::Client + end + end + + describe ".format" do + it "should return the default format" do + Gems.format.should == Gems::Configuration::DEFAULT_FORMAT + end + end + + describe ".format=" do + it "should set the format" do + Gems.format = 'xml' + Gems.format.should == 'xml' + end + end + + describe ".user_agent" do + it "should return the default user agent" do + Gems.user_agent.should == Gems::Configuration::DEFAULT_USER_AGENT + end + end + + describe ".user_agent=" do + it "should set the user_agent" do + Gems.user_agent = 'Custom User Agent' + Gems.user_agent.should == 'Custom User Agent' + end + end + + describe ".configure" do + Gems::Configuration::VALID_OPTIONS_KEYS.each do |key| + it "should set the #{key}" do + Gems.configure do |config| + config.send("#{key}=", key) + Gems.send(key).should == key + end + end end end end