How to start write test for gems?

I have some experience with testing Rails application using Rspec.

But now i tried to write tests for simple gem:
I know it will not be easy, but i want to learn this. Could you give me some tips or send some links how to started or example of good simple tests in gems because this is i think much more difficult then testing web applications.

What should i test first?
In first spec i think I should check Agent class?


require File.expand_path(File.dirname(FILE) + ‘/spec_helper’)

describe “Soup Client” do
before do
@agent =
it “should connect to soup” do == “

But this spec of course fails.

@@ -1,2 +1,19 @@
+ @agent=
+ #<Faraday::Connection:0xa87f834
+ @builder=
+ #<Faraday::Builder:0xa87f58c
+ @handlers=
+ [Faraday::Request::UrlEncoded,
+ Faraday::Response::Logger,
+ Faraday::Adapter::NetHttp]>,
+ @headers={},
+ @host=“”,
+ @options={},
+ @parallel_manager=nil,
+ @params={},
+ @path_prefix="/",
+ @port=nil,
+ @scheme=“https”,
+ @ssl={}>>
# ./spec/soup_spec.rb:8:in `block (2 levels) in <top (required)>’

I would like to learn how to get access to this variables like @host @builder and how to test each one. Any tips?

Thanks in advance