rsimpy 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.document +5 -0
- data/.gitignore +7 -0
- data/LICENSE +20 -0
- data/README.rdoc +21 -0
- data/Rakefile +96 -0
- data/VERSION.yml +4 -0
- data/bin/simp +68 -0
- data/features/links/adding_a_link.feature +47 -0
- data/features/links/querying_links.feature +46 -0
- data/features/links/steps/link_steps.rb +39 -0
- data/features/notes/query_note.feature +27 -0
- data/features/notes/remove_note.feature +11 -0
- data/features/notes/save_note.feature +36 -0
- data/features/notes/steps/note_steps.rb +46 -0
- data/features/support/env.rb +22 -0
- data/features/tags/merge_tags.feature +13 -0
- data/features/tags/querying_tags.feature +19 -0
- data/features/tags/remove_tag.feature +11 -0
- data/features/tags/rename_tag.feature +12 -0
- data/features/tags/split_tag.feature +13 -0
- data/features/tags/steps/tag_steps.rb +49 -0
- data/lib/base_service.rb +28 -0
- data/lib/client.rb +45 -0
- data/lib/configuration.rb +21 -0
- data/lib/errors/connection_error.rb +6 -0
- data/lib/errors/required_field_missing_error.rb +9 -0
- data/lib/errors/user_not_provided_error.rb +4 -0
- data/lib/links.rb +62 -0
- data/lib/parameters.rb +120 -0
- data/lib/posting_service.rb +27 -0
- data/lib/profile_storage_service.rb +47 -0
- data/lib/querying_service.rb +31 -0
- data/lib/rsimpy.rb +62 -0
- data/lib/user.rb +31 -0
- data/rsimpy.gemspec +128 -0
- data/test/client_test.rb +40 -0
- data/test/configuration_test.rb +27 -0
- data/test/deleting_service_test.rb +51 -0
- data/test/fixtures/test +5 -0
- data/test/fixtures/user_pass +5 -0
- data/test/links_test.rb +47 -0
- data/test/parameters_test.rb +61 -0
- data/test/posting_service_test.rb +45 -0
- data/test/profile_storage_service_test.rb +34 -0
- data/test/querying_service_test.rb +31 -0
- data/test/r_simpy_test.rb +74 -0
- data/test/required_field_missing_error_test.rb +11 -0
- data/test/responsive.rb +154 -0
- data/test/storage_builder.rb +16 -0
- data/test/storage_service_mock.rb +16 -0
- data/test/test_helper.rb +18 -0
- data/test/user_not_provided_error_test.rb +7 -0
- data/test/user_test.rb +34 -0
- metadata +182 -0
    
        data/test/fixtures/test
    ADDED
    
    
    
        data/test/links_test.rb
    ADDED
    
    | @@ -0,0 +1,47 @@ | |
| 1 | 
            +
            require 'test_helper'
         | 
| 2 | 
            +
            require 'fakeweb'
         | 
| 3 | 
            +
             | 
| 4 | 
            +
            class LinksSaveTest < Test::Unit::TestCase
         | 
| 5 | 
            +
              def setup
         | 
| 6 | 
            +
                FakeWeb.clean_registry
         | 
| 7 | 
            +
                FakeWeb.allow_net_connect = false
         | 
| 8 | 
            +
              end
         | 
| 9 | 
            +
             | 
| 10 | 
            +
              def test_public_posting
         | 
| 11 | 
            +
                FakeWeb.register_uri(:post, "http://USERNAME:PASSWORD@www.simpy.com:80/simpy/api/rest/SaveLink.do?accessType=1&href=http%3A%2F%2Fwww.example.com¬e=This+is+a+fine+example+of+an+example&src=rsimpy&tags=one%2C+two%2C+three&title=This+is+my+title&urlNickname=Example", :string => post_response)
         | 
| 12 | 
            +
             | 
| 13 | 
            +
                links = RSimpy::Links.new 'USERNAME', 'PASSWORD'
         | 
| 14 | 
            +
                params = RSimpy::Parameters.new
         | 
| 15 | 
            +
             | 
| 16 | 
            +
                params[:title] = "This is my title"
         | 
| 17 | 
            +
                params[:href] = "http://www.example.com"
         | 
| 18 | 
            +
                params[:tags] = "one, two, three"
         | 
| 19 | 
            +
                params[:urlNickname] = "Example"
         | 
| 20 | 
            +
                params[:note] = "This is a fine example of an example"
         | 
| 21 | 
            +
             | 
| 22 | 
            +
                response = links.save params
         | 
| 23 | 
            +
             | 
| 24 | 
            +
                assert_equal "0", links.status_code
         | 
| 25 | 
            +
                assert_equal 'Link saved successfully.', links.status_message
         | 
| 26 | 
            +
              end
         | 
| 27 | 
            +
             | 
| 28 | 
            +
              def test_private_posting
         | 
| 29 | 
            +
                FakeWeb.register_uri(:post, "http://USERNAME:PASSWORD@www.simpy.com:80/simpy/api/rest/SaveLink.do?accessType=0&href=http%3A%2F%2Fwww.example.com¬e=This+is+a+fine+example+of+an+example&src=rsimpy&tags=one%2C+two%2C+three&title=This+is+my+title&urlNickname=Example", :string => post_response)
         | 
| 30 | 
            +
             | 
| 31 | 
            +
                links = RSimpy::Links.new 'USERNAME', 'PASSWORD'
         | 
| 32 | 
            +
                params = RSimpy::Parameters.new
         | 
| 33 | 
            +
             | 
| 34 | 
            +
                params[:title] = "This is my title"
         | 
| 35 | 
            +
                params[:href] = "http://www.example.com"
         | 
| 36 | 
            +
                params[:tags] = "one, two, three"
         | 
| 37 | 
            +
                params[:accessType] = :private
         | 
| 38 | 
            +
                params[:urlNickname] = "Example"
         | 
| 39 | 
            +
                params[:note] = "This is a fine example of an example"
         | 
| 40 | 
            +
             | 
| 41 | 
            +
                response = links.save params
         | 
| 42 | 
            +
             
         | 
| 43 | 
            +
                assert_equal "0", links.status_code
         | 
| 44 | 
            +
                assert_equal 'Link saved successfully.', links.status_message
         | 
| 45 | 
            +
              end
         | 
| 46 | 
            +
            end
         | 
| 47 | 
            +
             | 
| @@ -0,0 +1,61 @@ | |
| 1 | 
            +
            require 'test_helper'
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            class ParametersTest < Test::Unit::TestCase
         | 
| 4 | 
            +
              def test_can_initialize_with_hash
         | 
| 5 | 
            +
                params = RSimpy::Parameters.new :foo => 'bar'
         | 
| 6 | 
            +
                assert_equal 'bar', params[:foo]
         | 
| 7 | 
            +
              end
         | 
| 8 | 
            +
             | 
| 9 | 
            +
              def test_can_convert_to_querystring
         | 
| 10 | 
            +
                params = RSimpy::Parameters.new :foo => 'bar', :baz => 2
         | 
| 11 | 
            +
                assert_equal "baz=2&foo=bar&src=rsimpy", params.to_querystring
         | 
| 12 | 
            +
              end
         | 
| 13 | 
            +
             | 
| 14 | 
            +
              def test_empty_querystring_converts_to_empty_string
         | 
| 15 | 
            +
                params = RSimpy::Parameters.new 
         | 
| 16 | 
            +
                assert_equal "src=rsimpy", params.to_querystring
         | 
| 17 | 
            +
              end
         | 
| 18 | 
            +
             | 
| 19 | 
            +
              def test_can_add_value_to_params
         | 
| 20 | 
            +
                params = RSimpy::Parameters.new 
         | 
| 21 | 
            +
                params.add('myThang', 2)
         | 
| 22 | 
            +
                assert_equal "myThang=2&src=rsimpy", params.to_querystring
         | 
| 23 | 
            +
              end
         | 
| 24 | 
            +
             | 
| 25 | 
            +
             | 
| 26 | 
            +
              def test_querystring_formats_href
         | 
| 27 | 
            +
                params = RSimpy::Parameters.new :href => "www.example.com"
         | 
| 28 | 
            +
                assert(CGI.unescape(params.to_querystring).include? "http://www.example.com")
         | 
| 29 | 
            +
              end
         | 
| 30 | 
            +
             | 
| 31 | 
            +
              def test_querystring_formats_tags_if_array
         | 
| 32 | 
            +
                params = RSimpy::Parameters.new :tags => ['foo', 'bar']
         | 
| 33 | 
            +
                assert(CGI.unescape(params.to_querystring).include? "foo, bar")
         | 
| 34 | 
            +
              end
         | 
| 35 | 
            +
             | 
| 36 | 
            +
              def test_querystring_formats_tags_if_array
         | 
| 37 | 
            +
                params = RSimpy::Parameters.new :tags => "foo, bar"
         | 
| 38 | 
            +
                assert(CGI.unescape(params.to_querystring).include? "foo, bar")
         | 
| 39 | 
            +
              end
         | 
| 40 | 
            +
              
         | 
| 41 | 
            +
              def test_querystring_formats_dates
         | 
| 42 | 
            +
                now = Date.new(2009, 1, 9)
         | 
| 43 | 
            +
                params = RSimpy::Parameters.new :some_date => now 
         | 
| 44 | 
            +
                assert(CGI.unescape(params.to_querystring).include? "some_date=2009-01-09")
         | 
| 45 | 
            +
              end
         | 
| 46 | 
            +
             | 
| 47 | 
            +
              def test_querystring_formats_access_type
         | 
| 48 | 
            +
                params = RSimpy::Parameters.new :accessType => :private
         | 
| 49 | 
            +
                assert(CGI.unescape(params.to_querystring).include? "accessType=0")
         | 
| 50 | 
            +
              end
         | 
| 51 | 
            +
             | 
| 52 | 
            +
              def test_querystring_will_sort_parameters
         | 
| 53 | 
            +
                params = RSimpy::Parameters.new :foo => 'bar', :bar => 'baz', :cheese => 'cheddar'
         | 
| 54 | 
            +
                assert_equal 'bar=baz&cheese=cheddar&foo=bar&src=rsimpy', params.to_querystring
         | 
| 55 | 
            +
              end
         | 
| 56 | 
            +
             | 
| 57 | 
            +
              def test_querystring_adds_source
         | 
| 58 | 
            +
                params = RSimpy::Parameters.new :foo => 'bar'
         | 
| 59 | 
            +
                assert(CGI.unescape(params.to_querystring).include? "src=rsimpy")
         | 
| 60 | 
            +
              end
         | 
| 61 | 
            +
            end
         | 
| @@ -0,0 +1,45 @@ | |
| 1 | 
            +
            require 'test_helper'
         | 
| 2 | 
            +
            require 'cgi'
         | 
| 3 | 
            +
             | 
| 4 | 
            +
            class LinkPostingServiceCanDoABasicPost < Test::Unit::TestCase
         | 
| 5 | 
            +
              #http://www.simpy.com/doc/api/rest/SaveLink
         | 
| 6 | 
            +
             | 
| 7 | 
            +
              def setup
         | 
| 8 | 
            +
                FakeWeb.clean_registry
         | 
| 9 | 
            +
                FakeWeb.allow_net_connect = false
         | 
| 10 | 
            +
             | 
| 11 | 
            +
                @client = RSimpy::Client.new(RSimpy::User.new("USERNAME","PASSWORD"))
         | 
| 12 | 
            +
                @action = "/SaveLink.do"
         | 
| 13 | 
            +
              end
         | 
| 14 | 
            +
             | 
| 15 | 
            +
              def test_basic_post
         | 
| 16 | 
            +
                FakeWeb.register_uri(:post, "http://USERNAME:PASSWORD@www.simpy.com:80/simpy/api/rest/SaveLink.do?accessType=1&href=http%3A%2F%2Fexample.com&src=rsimpy&title=Example", :string => post_response)
         | 
| 17 | 
            +
             | 
| 18 | 
            +
                params = RSimpy::Parameters.new :href => "http://example.com", :title => "Example", :accessType => :public
         | 
| 19 | 
            +
                service = RSimpy::PostingService.new(RSimpy::SAVE_LINK, @client)
         | 
| 20 | 
            +
                response = service.execute params
         | 
| 21 | 
            +
             | 
| 22 | 
            +
                assert service.success
         | 
| 23 | 
            +
              end
         | 
| 24 | 
            +
            end
         | 
| 25 | 
            +
             | 
| 26 | 
            +
            class LinkPostingServiceResponses < Test::Unit::TestCase
         | 
| 27 | 
            +
             | 
| 28 | 
            +
              def setup
         | 
| 29 | 
            +
                FakeWeb.clean_registry
         | 
| 30 | 
            +
                FakeWeb.allow_net_connect = false
         | 
| 31 | 
            +
             | 
| 32 | 
            +
                @client = RSimpy::Client.new(RSimpy::User.new("USERNAME","PASSWORD"))
         | 
| 33 | 
            +
              end
         | 
| 34 | 
            +
             | 
| 35 | 
            +
              def test_successful_response
         | 
| 36 | 
            +
                FakeWeb.register_uri(:post, "http://USERNAME:PASSWORD@www.simpy.com:80/simpy/api/rest/SaveLink.do?accessType=1&href=http%3A%2F%2Fexample.com&src=rsimpy&title=foo", :string => delete_response)
         | 
| 37 | 
            +
             | 
| 38 | 
            +
                service = RSimpy::PostingService.new(RSimpy::SAVE_LINK, @client)
         | 
| 39 | 
            +
                response = service.execute RSimpy::Parameters.new :href => "http://example.com", :title => "foo", :accessType => :public
         | 
| 40 | 
            +
             | 
| 41 | 
            +
                assert service.success
         | 
| 42 | 
            +
                assert_equal "0", service.status_code
         | 
| 43 | 
            +
                assert_equal "Link deleted successfully.", service.status_message
         | 
| 44 | 
            +
              end
         | 
| 45 | 
            +
            end
         | 
| @@ -0,0 +1,34 @@ | |
| 1 | 
            +
            require 'test_helper'
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            class ProfileStorageServiceTest < Test::Unit::TestCase
         | 
| 4 | 
            +
              context "basic operations" do
         | 
| 5 | 
            +
                setup do
         | 
| 6 | 
            +
                  @fixture_path = File.join ['test', 'fixtures', 'user_pass']
         | 
| 7 | 
            +
                  @service = RSimpy::ProfileStorageService.new  @fixture_path
         | 
| 8 | 
            +
                end
         | 
| 9 | 
            +
             | 
| 10 | 
            +
                should "have a default location of ~/.rsimpy" do
         | 
| 11 | 
            +
                  path = File.expand_path(File.join(['~', '.rsimpy']))
         | 
| 12 | 
            +
                  assert_equal path, @service.default_location
         | 
| 13 | 
            +
                end
         | 
| 14 | 
            +
             | 
| 15 | 
            +
                should "be stored? if config file exists" do
         | 
| 16 | 
            +
                  assert @service.stored?
         | 
| 17 | 
            +
                  assert !RSimpy::ProfileStorageService.new('wubba').stored?
         | 
| 18 | 
            +
                end
         | 
| 19 | 
            +
              end
         | 
| 20 | 
            +
             | 
| 21 | 
            +
              should "store_data" do
         | 
| 22 | 
            +
                fixture_path = File.join ['test', 'fixtures', 'test']
         | 
| 23 | 
            +
             | 
| 24 | 
            +
                service = RSimpy::ProfileStorageService.new  fixture_path
         | 
| 25 | 
            +
                user = RSimpy::User.new 'foo','bar'
         | 
| 26 | 
            +
                service.save user
         | 
| 27 | 
            +
             | 
| 28 | 
            +
                service = RSimpy::ProfileStorageService.new  fixture_path
         | 
| 29 | 
            +
                login, pass = service.get.credentials
         | 
| 30 | 
            +
             | 
| 31 | 
            +
                assert_equal 'foo', login
         | 
| 32 | 
            +
                assert_equal 'bar', pass
         | 
| 33 | 
            +
              end
         | 
| 34 | 
            +
            end
         | 
| @@ -0,0 +1,31 @@ | |
| 1 | 
            +
            require 'test_helper'
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            class LinkQueryingServiceCanDoABasicRequest < Test::Unit::TestCase
         | 
| 4 | 
            +
              def setup
         | 
| 5 | 
            +
                FakeWeb.clean_registry
         | 
| 6 | 
            +
                FakeWeb.allow_net_connect = false
         | 
| 7 | 
            +
             | 
| 8 | 
            +
                @client = RSimpy::Client.new(RSimpy::User.new("USERNAME","PASSWORD"))
         | 
| 9 | 
            +
                @action = "/GetLinks.do?"
         | 
| 10 | 
            +
              end
         | 
| 11 | 
            +
             | 
| 12 | 
            +
              def test_build_basic_link
         | 
| 13 | 
            +
                params = RSimpy::Parameters.new
         | 
| 14 | 
            +
                link = RSimpy::QueryingService.new(RSimpy::GET_LINKS, @client).build_link(params)
         | 
| 15 | 
            +
                assert(/#{@action}/ =~ link)
         | 
| 16 | 
            +
              end   
         | 
| 17 | 
            +
             | 
| 18 | 
            +
              def test_basic_get
         | 
| 19 | 
            +
                FakeWeb.register_uri(:get, "http://USERNAME:PASSWORD@www.simpy.com:80/simpy/api/rest/GetLinks.do?src=rsimpy", :string => get_response)
         | 
| 20 | 
            +
             | 
| 21 | 
            +
                service = RSimpy::QueryingService.new(RSimpy::GET_LINKS, @client)
         | 
| 22 | 
            +
                response = service.execute RSimpy::Parameters.new
         | 
| 23 | 
            +
                assert service.success
         | 
| 24 | 
            +
              end
         | 
| 25 | 
            +
             | 
| 26 | 
            +
              def test_src_is_set
         | 
| 27 | 
            +
                params = RSimpy::Parameters.new
         | 
| 28 | 
            +
                link = RSimpy::QueryingService.new(RSimpy::GET_LINKS, @client).build_link(params)
         | 
| 29 | 
            +
                assert(/src=rsimpy/ =~ link)
         | 
| 30 | 
            +
              end
         | 
| 31 | 
            +
            end
         | 
| @@ -0,0 +1,74 @@ | |
| 1 | 
            +
            require 'test_helper'
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            class RSimpyTest < Test::Unit::TestCase
         | 
| 4 | 
            +
              include RSimpy
         | 
| 5 | 
            +
             | 
| 6 | 
            +
              context "should be a mixin with simple operations for getting links" do
         | 
| 7 | 
            +
                setup do
         | 
| 8 | 
            +
                  FakeWeb.clean_registry
         | 
| 9 | 
            +
                  FakeWeb.allow_net_connect = false
         | 
| 10 | 
            +
                end
         | 
| 11 | 
            +
             | 
| 12 | 
            +
                should "make getting links easy" do
         | 
| 13 | 
            +
                  FakeWeb.register_uri(:get, "http://USERNAME:PASSWORD@www.simpy.com:80/simpy/api/rest/GetLinks.do?src=rsimpy", :string => get_response)
         | 
| 14 | 
            +
             | 
| 15 | 
            +
                  result = get_links :login => 'USERNAME', :pass => 'PASSWORD'
         | 
| 16 | 
            +
                  assert result[:success]
         | 
| 17 | 
            +
                  assert result.has_key? "links"
         | 
| 18 | 
            +
                end
         | 
| 19 | 
            +
             | 
| 20 | 
            +
                should "make getting links for a tag easy" do
         | 
| 21 | 
            +
                  FakeWeb.register_uri(:get, "http://USERNAME:PASSWORD@www.simpy.com:80/simpy/api/rest/GetLinks.do?q=foo&src=rsimpy", :string => get_response)
         | 
| 22 | 
            +
             | 
| 23 | 
            +
                  result = get_links :params => RSimpy::Parameters.new( :q => "foo" ), :login => 'USERNAME', :pass => 'PASSWORD'
         | 
| 24 | 
            +
                  assert result[:success]
         | 
| 25 | 
            +
                  assert result.has_key? "links"
         | 
| 26 | 
            +
                end
         | 
| 27 | 
            +
             | 
| 28 | 
            +
                should "make getting links easier if you pass config file location" do
         | 
| 29 | 
            +
                  FakeWeb.register_uri(:get, "http://USERNAME:PASSWORD@www.simpy.com:80/simpy/api/rest/GetLinks.do?src=rsimpy", :string => get_response)
         | 
| 30 | 
            +
             | 
| 31 | 
            +
                  location = File.join('test', 'fixtures', 'user_pass')
         | 
| 32 | 
            +
                  result = get_links :config_file => location
         | 
| 33 | 
            +
                  assert result[:success]
         | 
| 34 | 
            +
                  assert result.has_key? "links"
         | 
| 35 | 
            +
                end
         | 
| 36 | 
            +
             | 
| 37 | 
            +
                should "get links without date" do
         | 
| 38 | 
            +
                  FakeWeb.register_uri(:get, "http://USERNAME:PASSWORD@www.simpy.com:80/simpy/api/rest/GetLinks.do?src=rsimpy&limit=12&q=waffles", :string => get_response)
         | 
| 39 | 
            +
             | 
| 40 | 
            +
                  result = get_links :params => RSimpy::Parameters.new( :q => "waffles", :limit => 12 ), :login => 'USERNAME', :pass => 'PASSWORD'
         | 
| 41 | 
            +
                  assert result[:success]
         | 
| 42 | 
            +
                  assert result.has_key? "links"
         | 
| 43 | 
            +
                end
         | 
| 44 | 
            +
             | 
| 45 | 
            +
                should "get links by date" do
         | 
| 46 | 
            +
                  FakeWeb.register_uri(:get, "http://USERNAME:PASSWORD@www.simpy.com:80/simpy/api/rest/GetLinks.do?date=2009-10-01&src=rsimpy&limit=12&q=waffles", :string => get_response)
         | 
| 47 | 
            +
             | 
| 48 | 
            +
                  params = RSimpy::Parameters.new( :q => "waffles", :limit => 12, :date => Date.new(2009, 10, 01) )
         | 
| 49 | 
            +
                  result = get_links :params => params, :login => 'USERNAME', :pass => 'PASSWORD'
         | 
| 50 | 
            +
                  assert result[:success]
         | 
| 51 | 
            +
                  assert result.has_key? "links"
         | 
| 52 | 
            +
                end
         | 
| 53 | 
            +
             | 
| 54 | 
            +
                should "get links by date range" do
         | 
| 55 | 
            +
                  FakeWeb.register_uri(:get, "http://USERNAME:PASSWORD@www.simpy.com:80/simpy/api/rest/GetLinks.do?afterDate=2009-10-01&beforeDate=2009-10-10&limit=12&q=waffles&src=rsimpy", :string => get_response)
         | 
| 56 | 
            +
             | 
| 57 | 
            +
                  params = RSimpy::Parameters.new( :q => "waffles", :limit => 12, :beforeDate => Date.new(2009, 10, 10), :afterDate => Date.new(2009, 10, 01))
         | 
| 58 | 
            +
                  result = get_links :params => params, :login => 'USERNAME', :pass => 'PASSWORD'
         | 
| 59 | 
            +
                  assert result[:success]
         | 
| 60 | 
            +
                  assert result.has_key? "links"
         | 
| 61 | 
            +
                end
         | 
| 62 | 
            +
              end
         | 
| 63 | 
            +
             | 
| 64 | 
            +
              context "deleting links" do
         | 
| 65 | 
            +
                should "delete a link" do
         | 
| 66 | 
            +
                  # Simpy uses post for deletion
         | 
| 67 | 
            +
                  FakeWeb.register_uri(:post, "http://USERNAME:PASSWORD@www.simpy.com:80/simpy/api/rest/DeleteLink.do?href=http%3A%2F%2Fwww.example.com&src=rsimpy", :string => delete_response)
         | 
| 68 | 
            +
             | 
| 69 | 
            +
                  result = delete_link :params => RSimpy::Parameters.new(:href => "www.example.com" ), :login => 'USERNAME', :pass => 'PASSWORD'
         | 
| 70 | 
            +
                  assert_equal "0", result['status']['code']
         | 
| 71 | 
            +
                  assert_equal 'Link deleted successfully.', result['status']['message']
         | 
| 72 | 
            +
                end
         | 
| 73 | 
            +
              end
         | 
| 74 | 
            +
            end
         | 
| @@ -0,0 +1,11 @@ | |
| 1 | 
            +
            require 'errors/required_field_missing_error'
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            class RequiredFieldMissingErrorTest < Test::Unit::TestCase
         | 
| 4 | 
            +
                def test_can_get_field
         | 
| 5 | 
            +
                  begin
         | 
| 6 | 
            +
                    raise RSimpy::RequiredFieldMissingError.new "foo"
         | 
| 7 | 
            +
                  rescue RSimpy::RequiredFieldMissingError => e
         | 
| 8 | 
            +
                    assert_equal "foo", e.field
         | 
| 9 | 
            +
                  end
         | 
| 10 | 
            +
                end
         | 
| 11 | 
            +
            end
         | 
    
        data/test/responsive.rb
    ADDED
    
    | @@ -0,0 +1,154 @@ | |
| 1 | 
            +
            module Responsive
         | 
| 2 | 
            +
             | 
| 3 | 
            +
              def get_response
         | 
| 4 | 
            +
                '<?xml version="1.0" encoding="UTF-8"?>
         | 
| 5 | 
            +
             | 
| 6 | 
            +
            <links>
         | 
| 7 | 
            +
              <link accessType="public">
         | 
| 8 | 
            +
                <url>http://www.foobar.com</url>
         | 
| 9 | 
            +
                <modDate>2005-03-15</modDate>
         | 
| 10 | 
            +
                <addDate>2005-03-15</addDate>
         | 
| 11 | 
            +
                <title>FooBar</title>
         | 
| 12 | 
            +
                <nickname>Foo Bar Site</nickname>
         | 
| 13 | 
            +
                <tags>
         | 
| 14 | 
            +
                  <tag>tag1</tag>
         | 
| 15 | 
            +
                  <tag>tag2</tag>
         | 
| 16 | 
            +
                </tags>
         | 
| 17 | 
            +
                <note>note here</note>
         | 
| 18 | 
            +
              </link>
         | 
| 19 | 
            +
              <link accessType="private">
         | 
| 20 | 
            +
                <url>
         | 
| 21 | 
            +
                  http://www.ontopia.net/topicmaps/materials/tm-vs-thesauri.html
         | 
| 22 | 
            +
                </url>
         | 
| 23 | 
            +
                <modDate>2005-03-15</modDate>
         | 
| 24 | 
            +
                <addDate>2005-03-15</addDate>
         | 
| 25 | 
            +
                <title>Metadata? Thesauri? Taxonomies? Topic Maps!</title>
         | 
| 26 | 
            +
                <nickname/>
         | 
| 27 | 
            +
                <tags>
         | 
| 28 | 
            +
                  <tag>topics</tag>
         | 
| 29 | 
            +
                  <tag>tags</tag>
         | 
| 30 | 
            +
                  <tag>taxonomies</tag>
         | 
| 31 | 
            +
                </tags>
         | 
| 32 | 
            +
                <note/>
         | 
| 33 | 
            +
              </link>
         | 
| 34 | 
            +
            </links>'
         | 
| 35 | 
            +
              end
         | 
| 36 | 
            +
             | 
| 37 | 
            +
              def post_response
         | 
| 38 | 
            +
                '<?xml version="1.0" encoding="UTF-8"?>
         | 
| 39 | 
            +
             | 
| 40 | 
            +
            <status>
         | 
| 41 | 
            +
              <code>0</code>
         | 
| 42 | 
            +
              <message>Link saved successfully.</message>
         | 
| 43 | 
            +
            </status>'
         | 
| 44 | 
            +
              end
         | 
| 45 | 
            +
             | 
| 46 | 
            +
              def delete_response
         | 
| 47 | 
            +
                '<?xml version="1.0" encoding="UTF-8"?>
         | 
| 48 | 
            +
             | 
| 49 | 
            +
            <status>
         | 
| 50 | 
            +
              <code>0</code>
         | 
| 51 | 
            +
              <message>Link deleted successfully.</message>
         | 
| 52 | 
            +
            </status>'
         | 
| 53 | 
            +
              end
         | 
| 54 | 
            +
             | 
| 55 | 
            +
              def tag_splitting_response
         | 
| 56 | 
            +
                '<?xml version="1.0" encoding="UTF-8"?>
         | 
| 57 | 
            +
             | 
| 58 | 
            +
            <status>
         | 
| 59 | 
            +
              <code>0</code>
         | 
| 60 | 
            +
              <message>Tag split successfully.</message>
         | 
| 61 | 
            +
            </status>'
         | 
| 62 | 
            +
              end
         | 
| 63 | 
            +
             | 
| 64 | 
            +
              def tag_merging_response
         | 
| 65 | 
            +
                '<?xml version="1.0" encoding="UTF-8"?>
         | 
| 66 | 
            +
             | 
| 67 | 
            +
            <status>
         | 
| 68 | 
            +
              <code>0</code>
         | 
| 69 | 
            +
              <message>Tags merged successfully.</message>
         | 
| 70 | 
            +
            </status>'
         | 
| 71 | 
            +
              end
         | 
| 72 | 
            +
             | 
| 73 | 
            +
              def tag_renaming_response
         | 
| 74 | 
            +
                '<?xml version="1.0" encoding="UTF-8"?>
         | 
| 75 | 
            +
             | 
| 76 | 
            +
            <status>
         | 
| 77 | 
            +
              <code>0</code>
         | 
| 78 | 
            +
              <message>Tag renamed successfully.</message>
         | 
| 79 | 
            +
            </status>'
         | 
| 80 | 
            +
              end
         | 
| 81 | 
            +
             | 
| 82 | 
            +
              def tag_removing_response
         | 
| 83 | 
            +
                '<?xml version="1.0" encoding="UTF-8"?>
         | 
| 84 | 
            +
             | 
| 85 | 
            +
            <status>
         | 
| 86 | 
            +
              <code>0</code>
         | 
| 87 | 
            +
              <message>Tag removed successfully.</message>
         | 
| 88 | 
            +
            </status>'
         | 
| 89 | 
            +
              end
         | 
| 90 | 
            +
             | 
| 91 | 
            +
              def tag_querying_response
         | 
| 92 | 
            +
                '<?xml version="1.0" encoding="UTF-8"?>
         | 
| 93 | 
            +
             | 
| 94 | 
            +
            <tags user="user1">
         | 
| 95 | 
            +
              <tag name="tags" count="22"/>
         | 
| 96 | 
            +
              <tag name="folksonomy" count="15"/>
         | 
| 97 | 
            +
              <tag name="taxonomies" count="10"/>
         | 
| 98 | 
            +
              <tag name="labels" count="7"/>
         | 
| 99 | 
            +
              <tag name="tag1" count="5"/>
         | 
| 100 | 
            +
              <tag name="tag2" count="3"/>
         | 
| 101 | 
            +
              <tag name="topics" count="2"/>
         | 
| 102 | 
            +
            </tags>'
         | 
| 103 | 
            +
              end
         | 
| 104 | 
            +
             | 
| 105 | 
            +
              def note_removing_response
         | 
| 106 | 
            +
                '<?xml version="1.0" encoding="UTF-8"?>
         | 
| 107 | 
            +
             | 
| 108 | 
            +
            <status>
         | 
| 109 | 
            +
              <code>0</code>
         | 
| 110 | 
            +
              <message>Note deleted successfully.</message>
         | 
| 111 | 
            +
            </status>'
         | 
| 112 | 
            +
              end
         | 
| 113 | 
            +
             | 
| 114 | 
            +
              def note_saving_response
         | 
| 115 | 
            +
                '<?xml version="1.0" encoding="UTF-8"?>
         | 
| 116 | 
            +
             | 
| 117 | 
            +
            <status>
         | 
| 118 | 
            +
              <code>0</code>
         | 
| 119 | 
            +
              <message>Note saved successfully.</message>
         | 
| 120 | 
            +
            </status>'
         | 
| 121 | 
            +
              end
         | 
| 122 | 
            +
             | 
| 123 | 
            +
              def note_querying_response
         | 
| 124 | 
            +
                '<?xml version="1.0" encoding="UTF-8"?>
         | 
| 125 | 
            +
             | 
| 126 | 
            +
            <notes>
         | 
| 127 | 
            +
              <note accessType="private">
         | 
| 128 | 
            +
                <uri>http://www.simpy.com/simpy/NoteDetails.do?noteId=666</uri>
         | 
| 129 | 
            +
                <id>666</id>
         | 
| 130 | 
            +
                <modDate>date here</modDate>
         | 
| 131 | 
            +
                <addDate>date here</addDate>
         | 
| 132 | 
            +
                <title>title here</title>
         | 
| 133 | 
            +
                <tags>
         | 
| 134 | 
            +
                  <tag>goober</tag>
         | 
| 135 | 
            +
                  <tag>New York</tag>
         | 
| 136 | 
            +
                </tags>
         | 
| 137 | 
            +
                <description>I like ice-cream</description>
         | 
| 138 | 
            +
              </note>
         | 
| 139 | 
            +
             | 
| 140 | 
            +
              <note accessType="private">
         | 
| 141 | 
            +
                <uri>http://www.simpy.com/simpy/NoteDetails.do?noteId=314159265</uri>
         | 
| 142 | 
            +
                <modDate>date here</modDate>
         | 
| 143 | 
            +
                <addDate>date here</addDate>
         | 
| 144 | 
            +
                <title>title here</title>
         | 
| 145 | 
            +
                <nickname>nickname here</nickname>
         | 
| 146 | 
            +
                <tags>
         | 
| 147 | 
            +
                  <tag>goober</tag>
         | 
| 148 | 
            +
                  <tag>New York</tag>
         | 
| 149 | 
            +
                </tags>
         | 
| 150 | 
            +
                <description>tea with cookies... mmmm</description>
         | 
| 151 | 
            +
              </note>
         | 
| 152 | 
            +
            </notes>'
         | 
| 153 | 
            +
              end
         | 
| 154 | 
            +
            end
         |