facebook-js-stub 0.1.3 → 0.1.4
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/Gemfile +3 -0
 - data/MIT-LICENSE +19 -0
 - data/README.md +88 -0
 - data/Rakefile +10 -0
 - data/{Users/nort/git/facebook-js-stub/lib → lib}/facebook-js-stub.rb +0 -0
 - data/{Users/nort/git/facebook-js-stub/lib → lib}/facebook-js-stub/engine.rb +0 -0
 - data/lib/facebook-js-stub/version.rb +7 -0
 - data/spec/javascripts/api_spec.js +97 -0
 - data/spec/javascripts/get_login_status_spec.js +81 -0
 - data/spec/javascripts/helpers/spec_helper.js +3 -0
 - data/spec/javascripts/login_spec.js +101 -0
 - data/spec/javascripts/support/jasmine.yml +2 -0
 - data/spec/javascripts/support/jasmine_config.rb +23 -0
 - data/spec/javascripts/support/jasmine_runner.rb +32 -0
 - data/src/fb.js +58 -0
 - data/src/fb_stub.js +107 -0
 - data/{Users/nort/git/facebook-js-stub/vendor → vendor}/assets/javascripts/facebook-js-stub.js +0 -0
 - metadata +20 -5
 
    
        data/Gemfile
    ADDED
    
    
    
        data/MIT-LICENSE
    ADDED
    
    | 
         @@ -0,0 +1,19 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            Copyright (C) 2011 by Involver
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            Permission is hereby granted, free of charge, to any person obtaining a copy
         
     | 
| 
      
 4 
     | 
    
         
            +
            of this software and associated documentation files (the "Software"), to deal
         
     | 
| 
      
 5 
     | 
    
         
            +
            in the Software without restriction, including without limitation the rights
         
     | 
| 
      
 6 
     | 
    
         
            +
            to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
         
     | 
| 
      
 7 
     | 
    
         
            +
            copies of the Software, and to permit persons to whom the Software is
         
     | 
| 
      
 8 
     | 
    
         
            +
            furnished to do so, subject to the following conditions:
         
     | 
| 
      
 9 
     | 
    
         
            +
             
     | 
| 
      
 10 
     | 
    
         
            +
            The above copyright notice and this permission notice shall be included in
         
     | 
| 
      
 11 
     | 
    
         
            +
            all copies or substantial portions of the Software.
         
     | 
| 
      
 12 
     | 
    
         
            +
             
     | 
| 
      
 13 
     | 
    
         
            +
            THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
         
     | 
| 
      
 14 
     | 
    
         
            +
            IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
         
     | 
| 
      
 15 
     | 
    
         
            +
            FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
         
     | 
| 
      
 16 
     | 
    
         
            +
            AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
         
     | 
| 
      
 17 
     | 
    
         
            +
            LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
         
     | 
| 
      
 18 
     | 
    
         
            +
            OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
         
     | 
| 
      
 19 
     | 
    
         
            +
            THE SOFTWARE.
         
     | 
    
        data/README.md
    ADDED
    
    | 
         @@ -0,0 +1,88 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # Facebook JS Stub
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            ## Description
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
            This library facilitates the testing of code that interacts with Facebook via the official JavaScript SDK. It does this
         
     | 
| 
      
 6 
     | 
    
         
            +
            by providing a fake `FB` JavaScript module that mimics the official module. It also provides helper methods for
         
     | 
| 
      
 7 
     | 
    
         
            +
            simulating different Facebook states.
         
     | 
| 
      
 8 
     | 
    
         
            +
             
     | 
| 
      
 9 
     | 
    
         
            +
            ## Install
         
     | 
| 
      
 10 
     | 
    
         
            +
             
     | 
| 
      
 11 
     | 
    
         
            +
            ### Jasmine on Rails 3.1
         
     | 
| 
      
 12 
     | 
    
         
            +
             
     | 
| 
      
 13 
     | 
    
         
            +
            If using the edge version of [Jasmine](http://pivotal.github.com/jasmine/) with the Rails 3.1 asset pipeline:
         
     | 
| 
      
 14 
     | 
    
         
            +
             
     | 
| 
      
 15 
     | 
    
         
            +
            1. Add the gem to your Gemfile:
         
     | 
| 
      
 16 
     | 
    
         
            +
             
     | 
| 
      
 17 
     | 
    
         
            +
                    gem "facebook-js-stub", :git => "git://github.com/involver/facebook-js-stub.git"
         
     | 
| 
      
 18 
     | 
    
         
            +
             
     | 
| 
      
 19 
     | 
    
         
            +
            2. Add the `facebook-js-stub.js` asset to your `src_files` in `spec/javascripts/support/jasmine.yml`:
         
     | 
| 
      
 20 
     | 
    
         
            +
             
     | 
| 
      
 21 
     | 
    
         
            +
                    src_files:
         
     | 
| 
      
 22 
     | 
    
         
            +
                      - ...
         
     | 
| 
      
 23 
     | 
    
         
            +
                      - assets/facebook-js-stub.js
         
     | 
| 
      
 24 
     | 
    
         
            +
             
     | 
| 
      
 25 
     | 
    
         
            +
            ### Jasmine on another project
         
     | 
| 
      
 26 
     | 
    
         
            +
             
     | 
| 
      
 27 
     | 
    
         
            +
            1. Copy `vendor/assets/javascripts/facebook-js-stub.js` to `spec/javascripts/helpers/`.
         
     | 
| 
      
 28 
     | 
    
         
            +
            2. If you're explicitly setting helpers in your Jasmine configuration, add the new file:
         
     | 
| 
      
 29 
     | 
    
         
            +
             
     | 
| 
      
 30 
     | 
    
         
            +
                    helper_files:
         
     | 
| 
      
 31 
     | 
    
         
            +
                      - ...
         
     | 
| 
      
 32 
     | 
    
         
            +
                      - helpers/facebook-js-stub.js
         
     | 
| 
      
 33 
     | 
    
         
            +
             
     | 
| 
      
 34 
     | 
    
         
            +
            ## Usage
         
     | 
| 
      
 35 
     | 
    
         
            +
             
     | 
| 
      
 36 
     | 
    
         
            +
            `FB` is a module that simulates the official Facebook JavaScript library.
         
     | 
| 
      
 37 
     | 
    
         
            +
             
     | 
| 
      
 38 
     | 
    
         
            +
            `FBStub` is a module that provides methods for simulating a user's Facebook state and for simulating calls from
         
     | 
| 
      
 39 
     | 
    
         
            +
            Facebook to your callbacks.
         
     | 
| 
      
 40 
     | 
    
         
            +
             
     | 
| 
      
 41 
     | 
    
         
            +
            ### FB.init(options)
         
     | 
| 
      
 42 
     | 
    
         
            +
             
     | 
| 
      
 43 
     | 
    
         
            +
            As with the official Facebook library, you need to initialize it with your Application ID before anything else. Add the
         
     | 
| 
      
 44 
     | 
    
         
            +
            following in a `beforeEach`:
         
     | 
| 
      
 45 
     | 
    
         
            +
             
     | 
| 
      
 46 
     | 
    
         
            +
                FB.init({appId: 123});
         
     | 
| 
      
 47 
     | 
    
         
            +
             
     | 
| 
      
 48 
     | 
    
         
            +
            ### FB.getLoginStatus(callback)
         
     | 
| 
      
 49 
     | 
    
         
            +
             
     | 
| 
      
 50 
     | 
    
         
            +
            The given callback is called immediately and synchronously using the user's Facebook state as set via `FBStub`.
         
     | 
| 
      
 51 
     | 
    
         
            +
             
     | 
| 
      
 52 
     | 
    
         
            +
            See `FBStub.loggedIn()`, `FBStub.notLoggedIn()`, `FBStub.connected()`, and `FBStub.notConnected()`.
         
     | 
| 
      
 53 
     | 
    
         
            +
             
     | 
| 
      
 54 
     | 
    
         
            +
            ### FB.api(path, callback)
         
     | 
| 
      
 55 
     | 
    
         
            +
             
     | 
| 
      
 56 
     | 
    
         
            +
            The given request is recorded. The `callback` is not immediately called but stored for later use.
         
     | 
| 
      
 57 
     | 
    
         
            +
             
     | 
| 
      
 58 
     | 
    
         
            +
            To trigger a simulated response from Facebook, see `FBStub.respondToApiRequest()`.
         
     | 
| 
      
 59 
     | 
    
         
            +
             
     | 
| 
      
 60 
     | 
    
         
            +
            ### FBStub.loggedIn(userId)
         
     | 
| 
      
 61 
     | 
    
         
            +
             
     | 
| 
      
 62 
     | 
    
         
            +
            This simulates a logged in user.
         
     | 
| 
      
 63 
     | 
    
         
            +
             
     | 
| 
      
 64 
     | 
    
         
            +
            ### FBStub.notLoggedIn()
         
     | 
| 
      
 65 
     | 
    
         
            +
             
     | 
| 
      
 66 
     | 
    
         
            +
            This simulates a logged out user.
         
     | 
| 
      
 67 
     | 
    
         
            +
             
     | 
| 
      
 68 
     | 
    
         
            +
            ### FBStub.connected()
         
     | 
| 
      
 69 
     | 
    
         
            +
             
     | 
| 
      
 70 
     | 
    
         
            +
            This simulates a user having authorized the current application.
         
     | 
| 
      
 71 
     | 
    
         
            +
             
     | 
| 
      
 72 
     | 
    
         
            +
            ### FBStub.notConnected()
         
     | 
| 
      
 73 
     | 
    
         
            +
             
     | 
| 
      
 74 
     | 
    
         
            +
            This simulates a user having not authorized the current application.
         
     | 
| 
      
 75 
     | 
    
         
            +
             
     | 
| 
      
 76 
     | 
    
         
            +
            ### FBStub.respondToApiRequest(path, response)
         
     | 
| 
      
 77 
     | 
    
         
            +
             
     | 
| 
      
 78 
     | 
    
         
            +
            This responds to a previously recorded `FB.api()` request matching the given `path`. It will synchronously call the
         
     | 
| 
      
 79 
     | 
    
         
            +
            stored callback with the given `response`.
         
     | 
| 
      
 80 
     | 
    
         
            +
             
     | 
| 
      
 81 
     | 
    
         
            +
            ## Notes
         
     | 
| 
      
 82 
     | 
    
         
            +
             
     | 
| 
      
 83 
     | 
    
         
            +
            * When using `facebook-js-stub.js`, do not include Facebook's official JavaScript library. They both use the `FB`
         
     | 
| 
      
 84 
     | 
    
         
            +
              namespace, so one will override the other.
         
     | 
| 
      
 85 
     | 
    
         
            +
             
     | 
| 
      
 86 
     | 
    
         
            +
            ## License
         
     | 
| 
      
 87 
     | 
    
         
            +
             
     | 
| 
      
 88 
     | 
    
         
            +
            Please see the included license file.
         
     | 
    
        data/Rakefile
    ADDED
    
    
| 
         
            File without changes
         
     | 
| 
         
            File without changes
         
     | 
| 
         @@ -0,0 +1,97 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            describe("FB.api", function () {
         
     | 
| 
      
 2 
     | 
    
         
            +
              var callbacks;
         
     | 
| 
      
 3 
     | 
    
         
            +
             
     | 
| 
      
 4 
     | 
    
         
            +
              beforeEach(function () {
         
     | 
| 
      
 5 
     | 
    
         
            +
                callbacks = {
         
     | 
| 
      
 6 
     | 
    
         
            +
                  api:function () {
         
     | 
| 
      
 7 
     | 
    
         
            +
                  }
         
     | 
| 
      
 8 
     | 
    
         
            +
                };
         
     | 
| 
      
 9 
     | 
    
         
            +
                spyOn(callbacks, 'api');
         
     | 
| 
      
 10 
     | 
    
         
            +
              });
         
     | 
| 
      
 11 
     | 
    
         
            +
             
     | 
| 
      
 12 
     | 
    
         
            +
              describe("when FB has not been initialized", function () {
         
     | 
| 
      
 13 
     | 
    
         
            +
                beforeEach(function () {
         
     | 
| 
      
 14 
     | 
    
         
            +
                  FB.api(callbacks.api);
         
     | 
| 
      
 15 
     | 
    
         
            +
                });
         
     | 
| 
      
 16 
     | 
    
         
            +
             
     | 
| 
      
 17 
     | 
    
         
            +
                it("should not call the callback function", function () {
         
     | 
| 
      
 18 
     | 
    
         
            +
                  expect(callbacks.api).not.toHaveBeenCalled();
         
     | 
| 
      
 19 
     | 
    
         
            +
                });
         
     | 
| 
      
 20 
     | 
    
         
            +
              });
         
     | 
| 
      
 21 
     | 
    
         
            +
             
     | 
| 
      
 22 
     | 
    
         
            +
              describe("when FB has been initialized", function () {
         
     | 
| 
      
 23 
     | 
    
         
            +
                var response;
         
     | 
| 
      
 24 
     | 
    
         
            +
             
     | 
| 
      
 25 
     | 
    
         
            +
                function shared_callback_examples() {
         
     | 
| 
      
 26 
     | 
    
         
            +
                  it("should match open requests", function() {
         
     | 
| 
      
 27 
     | 
    
         
            +
                    expect(FBStub.findApiRequest("/some/path")).toBeDefined();
         
     | 
| 
      
 28 
     | 
    
         
            +
                  });
         
     | 
| 
      
 29 
     | 
    
         
            +
             
     | 
| 
      
 30 
     | 
    
         
            +
                  it("should not yet call the callback function", function() {
         
     | 
| 
      
 31 
     | 
    
         
            +
                    expect(callbacks.api).not.toHaveBeenCalled();
         
     | 
| 
      
 32 
     | 
    
         
            +
                  });
         
     | 
| 
      
 33 
     | 
    
         
            +
             
     | 
| 
      
 34 
     | 
    
         
            +
                  describe("when the API response is triggered for the same path", function() {
         
     | 
| 
      
 35 
     | 
    
         
            +
                    beforeEach(function() {
         
     | 
| 
      
 36 
     | 
    
         
            +
                      FBStub.respondToApiRequest("/some/path", response);
         
     | 
| 
      
 37 
     | 
    
         
            +
                    });
         
     | 
| 
      
 38 
     | 
    
         
            +
             
     | 
| 
      
 39 
     | 
    
         
            +
                    it("should yield the response to the callback function", function() {
         
     | 
| 
      
 40 
     | 
    
         
            +
                      expect(callbacks.api).toHaveBeenCalledWith(response);
         
     | 
| 
      
 41 
     | 
    
         
            +
                    });
         
     | 
| 
      
 42 
     | 
    
         
            +
                  });
         
     | 
| 
      
 43 
     | 
    
         
            +
             
     | 
| 
      
 44 
     | 
    
         
            +
                  describe("when the API response is triggered for a different path", function() {
         
     | 
| 
      
 45 
     | 
    
         
            +
                    beforeEach(function() {
         
     | 
| 
      
 46 
     | 
    
         
            +
                      FBStub.respondToApiRequest("/another/path", response);
         
     | 
| 
      
 47 
     | 
    
         
            +
                    });
         
     | 
| 
      
 48 
     | 
    
         
            +
             
     | 
| 
      
 49 
     | 
    
         
            +
                    it("should not yet call the callback function", function() {
         
     | 
| 
      
 50 
     | 
    
         
            +
                      expect(callbacks.api).not.toHaveBeenCalled();
         
     | 
| 
      
 51 
     | 
    
         
            +
                    });
         
     | 
| 
      
 52 
     | 
    
         
            +
                  });
         
     | 
| 
      
 53 
     | 
    
         
            +
                }
         
     | 
| 
      
 54 
     | 
    
         
            +
             
     | 
| 
      
 55 
     | 
    
         
            +
                describe("when given path and callback params", function() {
         
     | 
| 
      
 56 
     | 
    
         
            +
                  beforeEach(function () {
         
     | 
| 
      
 57 
     | 
    
         
            +
                    FB.init({appId:123});
         
     | 
| 
      
 58 
     | 
    
         
            +
                    FB.api("/some/path", callbacks.api);
         
     | 
| 
      
 59 
     | 
    
         
            +
             
     | 
| 
      
 60 
     | 
    
         
            +
                    response = {
         
     | 
| 
      
 61 
     | 
    
         
            +
                      data: [
         
     | 
| 
      
 62 
     | 
    
         
            +
                        {
         
     | 
| 
      
 63 
     | 
    
         
            +
                          name: "Example",
         
     | 
| 
      
 64 
     | 
    
         
            +
                          access_token: "",
         
     | 
| 
      
 65 
     | 
    
         
            +
                          category: "Community",
         
     | 
| 
      
 66 
     | 
    
         
            +
                          id: "1234567890"
         
     | 
| 
      
 67 
     | 
    
         
            +
                        }
         
     | 
| 
      
 68 
     | 
    
         
            +
                      ]
         
     | 
| 
      
 69 
     | 
    
         
            +
                    };
         
     | 
| 
      
 70 
     | 
    
         
            +
                  });
         
     | 
| 
      
 71 
     | 
    
         
            +
             
     | 
| 
      
 72 
     | 
    
         
            +
                  shared_callback_examples();
         
     | 
| 
      
 73 
     | 
    
         
            +
                });
         
     | 
| 
      
 74 
     | 
    
         
            +
             
     | 
| 
      
 75 
     | 
    
         
            +
                describe("when given path, method ,object, and callback params", function() {
         
     | 
| 
      
 76 
     | 
    
         
            +
                  var myObj = { };
         
     | 
| 
      
 77 
     | 
    
         
            +
             
     | 
| 
      
 78 
     | 
    
         
            +
                  beforeEach(function () {
         
     | 
| 
      
 79 
     | 
    
         
            +
                    FB.init({appId:123});
         
     | 
| 
      
 80 
     | 
    
         
            +
                    FB.api("/some/path", "post", myObj, callbacks.api);
         
     | 
| 
      
 81 
     | 
    
         
            +
             
     | 
| 
      
 82 
     | 
    
         
            +
                    response = {
         
     | 
| 
      
 83 
     | 
    
         
            +
                      data: [
         
     | 
| 
      
 84 
     | 
    
         
            +
                        {
         
     | 
| 
      
 85 
     | 
    
         
            +
                          name: "Example",
         
     | 
| 
      
 86 
     | 
    
         
            +
                          access_token: "",
         
     | 
| 
      
 87 
     | 
    
         
            +
                          category: "Community",
         
     | 
| 
      
 88 
     | 
    
         
            +
                          id: "1234567890"
         
     | 
| 
      
 89 
     | 
    
         
            +
                        }
         
     | 
| 
      
 90 
     | 
    
         
            +
                      ]
         
     | 
| 
      
 91 
     | 
    
         
            +
                    };
         
     | 
| 
      
 92 
     | 
    
         
            +
                  });
         
     | 
| 
      
 93 
     | 
    
         
            +
             
     | 
| 
      
 94 
     | 
    
         
            +
                  shared_callback_examples();
         
     | 
| 
      
 95 
     | 
    
         
            +
                });
         
     | 
| 
      
 96 
     | 
    
         
            +
              });
         
     | 
| 
      
 97 
     | 
    
         
            +
            });
         
     | 
| 
         @@ -0,0 +1,81 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            describe("FB.getLoginStatus", function() {
         
     | 
| 
      
 2 
     | 
    
         
            +
              var callbacks;
         
     | 
| 
      
 3 
     | 
    
         
            +
             
     | 
| 
      
 4 
     | 
    
         
            +
              beforeEach(function() {
         
     | 
| 
      
 5 
     | 
    
         
            +
                callbacks = {
         
     | 
| 
      
 6 
     | 
    
         
            +
                  getLoginStatus: function() {}
         
     | 
| 
      
 7 
     | 
    
         
            +
                };
         
     | 
| 
      
 8 
     | 
    
         
            +
                spyOn(callbacks, 'getLoginStatus');
         
     | 
| 
      
 9 
     | 
    
         
            +
              });
         
     | 
| 
      
 10 
     | 
    
         
            +
             
     | 
| 
      
 11 
     | 
    
         
            +
              describe("when FB has not been initialized", function() {
         
     | 
| 
      
 12 
     | 
    
         
            +
                it("should not call the callback function", function() {
         
     | 
| 
      
 13 
     | 
    
         
            +
                  FB.getLoginStatus(callbacks.getLoginStatus);
         
     | 
| 
      
 14 
     | 
    
         
            +
                  expect(callbacks.getLoginStatus).not.toHaveBeenCalled();
         
     | 
| 
      
 15 
     | 
    
         
            +
                });
         
     | 
| 
      
 16 
     | 
    
         
            +
              });
         
     | 
| 
      
 17 
     | 
    
         
            +
             
     | 
| 
      
 18 
     | 
    
         
            +
              describe("when FB has been initialized", function() {
         
     | 
| 
      
 19 
     | 
    
         
            +
                beforeEach(function() {
         
     | 
| 
      
 20 
     | 
    
         
            +
                  FB.init({appId: 123});
         
     | 
| 
      
 21 
     | 
    
         
            +
                });
         
     | 
| 
      
 22 
     | 
    
         
            +
             
     | 
| 
      
 23 
     | 
    
         
            +
                it("should call the callback function", function() {
         
     | 
| 
      
 24 
     | 
    
         
            +
                  FB.getLoginStatus(callbacks.getLoginStatus);
         
     | 
| 
      
 25 
     | 
    
         
            +
                  expect(callbacks.getLoginStatus).toHaveBeenCalled();
         
     | 
| 
      
 26 
     | 
    
         
            +
                });
         
     | 
| 
      
 27 
     | 
    
         
            +
             
     | 
| 
      
 28 
     | 
    
         
            +
                describe("when the user is logged in", function() {
         
     | 
| 
      
 29 
     | 
    
         
            +
                  beforeEach(function() {
         
     | 
| 
      
 30 
     | 
    
         
            +
                    FBStub.loggedIn({userID: 123});
         
     | 
| 
      
 31 
     | 
    
         
            +
                  });
         
     | 
| 
      
 32 
     | 
    
         
            +
             
     | 
| 
      
 33 
     | 
    
         
            +
                  describe("when the user has authorized the application", function() {
         
     | 
| 
      
 34 
     | 
    
         
            +
                    beforeEach(function() {
         
     | 
| 
      
 35 
     | 
    
         
            +
                      FBStub.connected();
         
     | 
| 
      
 36 
     | 
    
         
            +
                    });
         
     | 
| 
      
 37 
     | 
    
         
            +
             
     | 
| 
      
 38 
     | 
    
         
            +
                    it("should yield a hash with a connected response", function() {
         
     | 
| 
      
 39 
     | 
    
         
            +
                      FB.getLoginStatus(callbacks.getLoginStatus);
         
     | 
| 
      
 40 
     | 
    
         
            +
                      expect(callbacks.getLoginStatus).toHaveBeenCalledWith({
         
     | 
| 
      
 41 
     | 
    
         
            +
                        status : 'connected',
         
     | 
| 
      
 42 
     | 
    
         
            +
                        authResponse: {
         
     | 
| 
      
 43 
     | 
    
         
            +
                          accessToken: '',
         
     | 
| 
      
 44 
     | 
    
         
            +
                          expiresIn: 4095,
         
     | 
| 
      
 45 
     | 
    
         
            +
                          signedRequest: '',
         
     | 
| 
      
 46 
     | 
    
         
            +
                          userID: 123
         
     | 
| 
      
 47 
     | 
    
         
            +
                        }
         
     | 
| 
      
 48 
     | 
    
         
            +
                      });
         
     | 
| 
      
 49 
     | 
    
         
            +
                    });
         
     | 
| 
      
 50 
     | 
    
         
            +
                  });
         
     | 
| 
      
 51 
     | 
    
         
            +
             
     | 
| 
      
 52 
     | 
    
         
            +
                  describe("when the user has not authorized the application", function() {
         
     | 
| 
      
 53 
     | 
    
         
            +
                    beforeEach(function() {
         
     | 
| 
      
 54 
     | 
    
         
            +
                      FBStub.notConnected();
         
     | 
| 
      
 55 
     | 
    
         
            +
                    });
         
     | 
| 
      
 56 
     | 
    
         
            +
             
     | 
| 
      
 57 
     | 
    
         
            +
                    it("should yield a hash with an unauthorized status", function() {
         
     | 
| 
      
 58 
     | 
    
         
            +
                      FB.getLoginStatus(callbacks.getLoginStatus);
         
     | 
| 
      
 59 
     | 
    
         
            +
                      expect(callbacks.getLoginStatus).toHaveBeenCalledWith({
         
     | 
| 
      
 60 
     | 
    
         
            +
                        status: 'not_authorized',
         
     | 
| 
      
 61 
     | 
    
         
            +
                        authResponse: null
         
     | 
| 
      
 62 
     | 
    
         
            +
                      });
         
     | 
| 
      
 63 
     | 
    
         
            +
                    })
         
     | 
| 
      
 64 
     | 
    
         
            +
                  });
         
     | 
| 
      
 65 
     | 
    
         
            +
                });
         
     | 
| 
      
 66 
     | 
    
         
            +
             
     | 
| 
      
 67 
     | 
    
         
            +
                describe("when the user is not logged in", function() {
         
     | 
| 
      
 68 
     | 
    
         
            +
                  beforeEach(function() {
         
     | 
| 
      
 69 
     | 
    
         
            +
                    FBStub.notLoggedIn();
         
     | 
| 
      
 70 
     | 
    
         
            +
                  });
         
     | 
| 
      
 71 
     | 
    
         
            +
             
     | 
| 
      
 72 
     | 
    
         
            +
                  it("should yield a hash an unknown status", function() {
         
     | 
| 
      
 73 
     | 
    
         
            +
                    FB.getLoginStatus(callbacks.getLoginStatus);
         
     | 
| 
      
 74 
     | 
    
         
            +
                    expect(callbacks.getLoginStatus).toHaveBeenCalledWith({
         
     | 
| 
      
 75 
     | 
    
         
            +
                      status: 'unknown',
         
     | 
| 
      
 76 
     | 
    
         
            +
                      authResponse: null
         
     | 
| 
      
 77 
     | 
    
         
            +
                    });
         
     | 
| 
      
 78 
     | 
    
         
            +
                  })
         
     | 
| 
      
 79 
     | 
    
         
            +
                });
         
     | 
| 
      
 80 
     | 
    
         
            +
              });
         
     | 
| 
      
 81 
     | 
    
         
            +
            });
         
     | 
| 
         @@ -0,0 +1,101 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            describe("FB.login", function() {
         
     | 
| 
      
 2 
     | 
    
         
            +
              var callbacks;
         
     | 
| 
      
 3 
     | 
    
         
            +
             
     | 
| 
      
 4 
     | 
    
         
            +
              beforeEach(function() {
         
     | 
| 
      
 5 
     | 
    
         
            +
                callbacks = {
         
     | 
| 
      
 6 
     | 
    
         
            +
                  login: function() {}
         
     | 
| 
      
 7 
     | 
    
         
            +
                };
         
     | 
| 
      
 8 
     | 
    
         
            +
                spyOn(callbacks, 'login');
         
     | 
| 
      
 9 
     | 
    
         
            +
              });
         
     | 
| 
      
 10 
     | 
    
         
            +
             
     | 
| 
      
 11 
     | 
    
         
            +
              describe("when FB has not been initialized", function() {
         
     | 
| 
      
 12 
     | 
    
         
            +
                beforeEach(function() {
         
     | 
| 
      
 13 
     | 
    
         
            +
                  FB.login(callbacks.login);
         
     | 
| 
      
 14 
     | 
    
         
            +
                });
         
     | 
| 
      
 15 
     | 
    
         
            +
             
     | 
| 
      
 16 
     | 
    
         
            +
                describe("when the user logs in and authorizes the application", function() {
         
     | 
| 
      
 17 
     | 
    
         
            +
                  beforeEach(function() {
         
     | 
| 
      
 18 
     | 
    
         
            +
                    FBStub.logInAndAuthorize();
         
     | 
| 
      
 19 
     | 
    
         
            +
                  });
         
     | 
| 
      
 20 
     | 
    
         
            +
             
     | 
| 
      
 21 
     | 
    
         
            +
                  it("should not call the callback function", function() {
         
     | 
| 
      
 22 
     | 
    
         
            +
                    expect(callbacks.login).not.toHaveBeenCalled();
         
     | 
| 
      
 23 
     | 
    
         
            +
                  });
         
     | 
| 
      
 24 
     | 
    
         
            +
                });
         
     | 
| 
      
 25 
     | 
    
         
            +
             
     | 
| 
      
 26 
     | 
    
         
            +
                describe("when the user does not log in or authorize the application", function() {
         
     | 
| 
      
 27 
     | 
    
         
            +
                  beforeEach(function() {
         
     | 
| 
      
 28 
     | 
    
         
            +
                    FBStub.logInAndDeny();
         
     | 
| 
      
 29 
     | 
    
         
            +
                  });
         
     | 
| 
      
 30 
     | 
    
         
            +
             
     | 
| 
      
 31 
     | 
    
         
            +
                  it("should not call the callback function", function() {
         
     | 
| 
      
 32 
     | 
    
         
            +
                    expect(callbacks.login).not.toHaveBeenCalled();
         
     | 
| 
      
 33 
     | 
    
         
            +
                  });
         
     | 
| 
      
 34 
     | 
    
         
            +
                });
         
     | 
| 
      
 35 
     | 
    
         
            +
             
     | 
| 
      
 36 
     | 
    
         
            +
                describe("when the user does not log in", function() {
         
     | 
| 
      
 37 
     | 
    
         
            +
                  beforeEach(function() {
         
     | 
| 
      
 38 
     | 
    
         
            +
                    FBStub.abortLogIn();
         
     | 
| 
      
 39 
     | 
    
         
            +
                  });
         
     | 
| 
      
 40 
     | 
    
         
            +
             
     | 
| 
      
 41 
     | 
    
         
            +
                  it("should not call the callback function", function() {
         
     | 
| 
      
 42 
     | 
    
         
            +
                    expect(callbacks.login).not.toHaveBeenCalled();
         
     | 
| 
      
 43 
     | 
    
         
            +
                  });
         
     | 
| 
      
 44 
     | 
    
         
            +
                });
         
     | 
| 
      
 45 
     | 
    
         
            +
              });
         
     | 
| 
      
 46 
     | 
    
         
            +
             
     | 
| 
      
 47 
     | 
    
         
            +
              describe("when FB has been initialized", function() {
         
     | 
| 
      
 48 
     | 
    
         
            +
                beforeEach(function() {
         
     | 
| 
      
 49 
     | 
    
         
            +
                  FB.init({appId: 123});
         
     | 
| 
      
 50 
     | 
    
         
            +
                  FB.login(callbacks.login);
         
     | 
| 
      
 51 
     | 
    
         
            +
                });
         
     | 
| 
      
 52 
     | 
    
         
            +
             
     | 
| 
      
 53 
     | 
    
         
            +
                it("should not yet call the callback function", function() {
         
     | 
| 
      
 54 
     | 
    
         
            +
                  expect(callbacks.login).not.toHaveBeenCalled();
         
     | 
| 
      
 55 
     | 
    
         
            +
                });
         
     | 
| 
      
 56 
     | 
    
         
            +
             
     | 
| 
      
 57 
     | 
    
         
            +
                describe("when the user logs in and authorizes the application", function() {
         
     | 
| 
      
 58 
     | 
    
         
            +
                  beforeEach(function() {
         
     | 
| 
      
 59 
     | 
    
         
            +
                    FBStub.logInAndAuthorize();
         
     | 
| 
      
 60 
     | 
    
         
            +
                  });
         
     | 
| 
      
 61 
     | 
    
         
            +
             
     | 
| 
      
 62 
     | 
    
         
            +
                  it("should yield an object with an authorized response", function() {
         
     | 
| 
      
 63 
     | 
    
         
            +
                    expect(callbacks.login).toHaveBeenCalledWith({
         
     | 
| 
      
 64 
     | 
    
         
            +
                      status: "connected",
         
     | 
| 
      
 65 
     | 
    
         
            +
                      authResponse: {
         
     | 
| 
      
 66 
     | 
    
         
            +
                        accessToken: "",
         
     | 
| 
      
 67 
     | 
    
         
            +
                        userID: "",
         
     | 
| 
      
 68 
     | 
    
         
            +
                        expiresIn: 4374,
         
     | 
| 
      
 69 
     | 
    
         
            +
                        signedRequest: ""
         
     | 
| 
      
 70 
     | 
    
         
            +
                      }
         
     | 
| 
      
 71 
     | 
    
         
            +
                    });
         
     | 
| 
      
 72 
     | 
    
         
            +
                  });
         
     | 
| 
      
 73 
     | 
    
         
            +
                });
         
     | 
| 
      
 74 
     | 
    
         
            +
             
     | 
| 
      
 75 
     | 
    
         
            +
                describe("when the user logs in and does not authorize the application", function() {
         
     | 
| 
      
 76 
     | 
    
         
            +
                  beforeEach(function() {
         
     | 
| 
      
 77 
     | 
    
         
            +
                    FBStub.logInAndDeny();
         
     | 
| 
      
 78 
     | 
    
         
            +
                  });
         
     | 
| 
      
 79 
     | 
    
         
            +
             
     | 
| 
      
 80 
     | 
    
         
            +
                  it("should yield an object with an authorized status", function() {
         
     | 
| 
      
 81 
     | 
    
         
            +
                    expect(callbacks.login).toHaveBeenCalledWith({
         
     | 
| 
      
 82 
     | 
    
         
            +
                      status: "not_authorized",
         
     | 
| 
      
 83 
     | 
    
         
            +
                      authResponse: null
         
     | 
| 
      
 84 
     | 
    
         
            +
                    });
         
     | 
| 
      
 85 
     | 
    
         
            +
                  });
         
     | 
| 
      
 86 
     | 
    
         
            +
                });
         
     | 
| 
      
 87 
     | 
    
         
            +
             
     | 
| 
      
 88 
     | 
    
         
            +
                describe("when the user does not log in", function() {
         
     | 
| 
      
 89 
     | 
    
         
            +
                  beforeEach(function() {
         
     | 
| 
      
 90 
     | 
    
         
            +
                    FBStub.abortLogIn();
         
     | 
| 
      
 91 
     | 
    
         
            +
                  });
         
     | 
| 
      
 92 
     | 
    
         
            +
             
     | 
| 
      
 93 
     | 
    
         
            +
                  it("should yield an object with an unknown status", function() {
         
     | 
| 
      
 94 
     | 
    
         
            +
                    expect(callbacks.login).toHaveBeenCalledWith({
         
     | 
| 
      
 95 
     | 
    
         
            +
                      status: "unknown",
         
     | 
| 
      
 96 
     | 
    
         
            +
                      authResponse: null
         
     | 
| 
      
 97 
     | 
    
         
            +
                    });
         
     | 
| 
      
 98 
     | 
    
         
            +
                  });
         
     | 
| 
      
 99 
     | 
    
         
            +
                });
         
     | 
| 
      
 100 
     | 
    
         
            +
              });
         
     | 
| 
      
 101 
     | 
    
         
            +
            });
         
     | 
| 
         @@ -0,0 +1,23 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            module Jasmine
         
     | 
| 
      
 2 
     | 
    
         
            +
              class Config
         
     | 
| 
      
 3 
     | 
    
         
            +
             
     | 
| 
      
 4 
     | 
    
         
            +
                # Add your overrides or custom config code here
         
     | 
| 
      
 5 
     | 
    
         
            +
             
     | 
| 
      
 6 
     | 
    
         
            +
              end
         
     | 
| 
      
 7 
     | 
    
         
            +
            end
         
     | 
| 
      
 8 
     | 
    
         
            +
             
     | 
| 
      
 9 
     | 
    
         
            +
             
     | 
| 
      
 10 
     | 
    
         
            +
            # Note - this is necessary for rspec2, which has removed the backtrace
         
     | 
| 
      
 11 
     | 
    
         
            +
            module Jasmine
         
     | 
| 
      
 12 
     | 
    
         
            +
              class SpecBuilder
         
     | 
| 
      
 13 
     | 
    
         
            +
                def declare_spec(parent, spec)
         
     | 
| 
      
 14 
     | 
    
         
            +
                  me = self
         
     | 
| 
      
 15 
     | 
    
         
            +
                  example_name = spec["name"]
         
     | 
| 
      
 16 
     | 
    
         
            +
                  @spec_ids << spec["id"]
         
     | 
| 
      
 17 
     | 
    
         
            +
                  backtrace = @example_locations[parent.description + " " + example_name]
         
     | 
| 
      
 18 
     | 
    
         
            +
                  parent.it example_name, {} do
         
     | 
| 
      
 19 
     | 
    
         
            +
                    me.report_spec(spec["id"])
         
     | 
| 
      
 20 
     | 
    
         
            +
                  end
         
     | 
| 
      
 21 
     | 
    
         
            +
                end
         
     | 
| 
      
 22 
     | 
    
         
            +
              end
         
     | 
| 
      
 23 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,32 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            $:.unshift(ENV['JASMINE_GEM_PATH']) if ENV['JASMINE_GEM_PATH'] # for gem testing purposes
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            require 'rubygems'
         
     | 
| 
      
 4 
     | 
    
         
            +
            require 'jasmine'
         
     | 
| 
      
 5 
     | 
    
         
            +
            jasmine_config_overrides = File.expand_path(File.join(File.dirname(__FILE__), 'jasmine_config.rb'))
         
     | 
| 
      
 6 
     | 
    
         
            +
            require jasmine_config_overrides if File.exist?(jasmine_config_overrides)
         
     | 
| 
      
 7 
     | 
    
         
            +
            if Jasmine::Dependencies.rspec2?
         
     | 
| 
      
 8 
     | 
    
         
            +
              require 'rspec'
         
     | 
| 
      
 9 
     | 
    
         
            +
            else
         
     | 
| 
      
 10 
     | 
    
         
            +
              require 'spec'
         
     | 
| 
      
 11 
     | 
    
         
            +
            end
         
     | 
| 
      
 12 
     | 
    
         
            +
             
     | 
| 
      
 13 
     | 
    
         
            +
            jasmine_config = Jasmine::Config.new
         
     | 
| 
      
 14 
     | 
    
         
            +
            spec_builder = Jasmine::SpecBuilder.new(jasmine_config)
         
     | 
| 
      
 15 
     | 
    
         
            +
             
     | 
| 
      
 16 
     | 
    
         
            +
            should_stop = false
         
     | 
| 
      
 17 
     | 
    
         
            +
             
     | 
| 
      
 18 
     | 
    
         
            +
            if Jasmine::Dependencies.rspec2?
         
     | 
| 
      
 19 
     | 
    
         
            +
              RSpec.configuration.after(:suite) do
         
     | 
| 
      
 20 
     | 
    
         
            +
                spec_builder.stop if should_stop
         
     | 
| 
      
 21 
     | 
    
         
            +
              end
         
     | 
| 
      
 22 
     | 
    
         
            +
            else
         
     | 
| 
      
 23 
     | 
    
         
            +
              Spec::Runner.configure do |config|
         
     | 
| 
      
 24 
     | 
    
         
            +
                config.after(:suite) do
         
     | 
| 
      
 25 
     | 
    
         
            +
                  spec_builder.stop if should_stop
         
     | 
| 
      
 26 
     | 
    
         
            +
                end
         
     | 
| 
      
 27 
     | 
    
         
            +
              end
         
     | 
| 
      
 28 
     | 
    
         
            +
            end
         
     | 
| 
      
 29 
     | 
    
         
            +
             
     | 
| 
      
 30 
     | 
    
         
            +
            spec_builder.start
         
     | 
| 
      
 31 
     | 
    
         
            +
            should_stop = true
         
     | 
| 
      
 32 
     | 
    
         
            +
            spec_builder.declare_suites
         
     | 
    
        data/src/fb.js
    ADDED
    
    | 
         @@ -0,0 +1,58 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            var FB = (function(){
         
     | 
| 
      
 2 
     | 
    
         
            +
              var self = { };
         
     | 
| 
      
 3 
     | 
    
         
            +
             
     | 
| 
      
 4 
     | 
    
         
            +
              self.init = function(options) {
         
     | 
| 
      
 5 
     | 
    
         
            +
                FBStub.appId(options.appId);
         
     | 
| 
      
 6 
     | 
    
         
            +
              };
         
     | 
| 
      
 7 
     | 
    
         
            +
             
     | 
| 
      
 8 
     | 
    
         
            +
              self.login = function(callback) {
         
     | 
| 
      
 9 
     | 
    
         
            +
                if (!FBStub.initialized()) return;
         
     | 
| 
      
 10 
     | 
    
         
            +
                FBStub.loginCallback = callback;
         
     | 
| 
      
 11 
     | 
    
         
            +
              };
         
     | 
| 
      
 12 
     | 
    
         
            +
             
     | 
| 
      
 13 
     | 
    
         
            +
              self.getLoginStatus = function(callback) {
         
     | 
| 
      
 14 
     | 
    
         
            +
                if (!FBStub.initialized()) return;
         
     | 
| 
      
 15 
     | 
    
         
            +
                var status;
         
     | 
| 
      
 16 
     | 
    
         
            +
                var authResponse = null;
         
     | 
| 
      
 17 
     | 
    
         
            +
             
     | 
| 
      
 18 
     | 
    
         
            +
                if (FBStub.isLoggedIn()) {
         
     | 
| 
      
 19 
     | 
    
         
            +
                  if (FBStub.isConnected()) {
         
     | 
| 
      
 20 
     | 
    
         
            +
                    status = "connected";
         
     | 
| 
      
 21 
     | 
    
         
            +
                    authResponse = {
         
     | 
| 
      
 22 
     | 
    
         
            +
                      accessToken: "",
         
     | 
| 
      
 23 
     | 
    
         
            +
                      expiresIn: 4095,
         
     | 
| 
      
 24 
     | 
    
         
            +
                      signedRequest: "",
         
     | 
| 
      
 25 
     | 
    
         
            +
                      userID: FBStub.userID()
         
     | 
| 
      
 26 
     | 
    
         
            +
                    };
         
     | 
| 
      
 27 
     | 
    
         
            +
                  }
         
     | 
| 
      
 28 
     | 
    
         
            +
                  else {
         
     | 
| 
      
 29 
     | 
    
         
            +
                    status = "not_authorized";
         
     | 
| 
      
 30 
     | 
    
         
            +
                  }
         
     | 
| 
      
 31 
     | 
    
         
            +
                }
         
     | 
| 
      
 32 
     | 
    
         
            +
                else {
         
     | 
| 
      
 33 
     | 
    
         
            +
                  status = "unknown";
         
     | 
| 
      
 34 
     | 
    
         
            +
                }
         
     | 
| 
      
 35 
     | 
    
         
            +
             
     | 
| 
      
 36 
     | 
    
         
            +
                callback({
         
     | 
| 
      
 37 
     | 
    
         
            +
                  status: status,
         
     | 
| 
      
 38 
     | 
    
         
            +
                  authResponse: authResponse
         
     | 
| 
      
 39 
     | 
    
         
            +
                });
         
     | 
| 
      
 40 
     | 
    
         
            +
              };
         
     | 
| 
      
 41 
     | 
    
         
            +
             
     | 
| 
      
 42 
     | 
    
         
            +
              self.api = function(path, method, params, callback) {
         
     | 
| 
      
 43 
     | 
    
         
            +
                var callbackMethod;
         
     | 
| 
      
 44 
     | 
    
         
            +
             
     | 
| 
      
 45 
     | 
    
         
            +
                if (typeof method === 'function') {
         
     | 
| 
      
 46 
     | 
    
         
            +
                  callbackMethod = method;
         
     | 
| 
      
 47 
     | 
    
         
            +
                } else {
         
     | 
| 
      
 48 
     | 
    
         
            +
                  if (typeof params == 'function') {
         
     | 
| 
      
 49 
     | 
    
         
            +
                    callbackMethod = params;
         
     | 
| 
      
 50 
     | 
    
         
            +
                  } else {
         
     | 
| 
      
 51 
     | 
    
         
            +
                    callbackMethod = callback;
         
     | 
| 
      
 52 
     | 
    
         
            +
                  }
         
     | 
| 
      
 53 
     | 
    
         
            +
                }
         
     | 
| 
      
 54 
     | 
    
         
            +
                FBStub.addApiRequest(path, callbackMethod);
         
     | 
| 
      
 55 
     | 
    
         
            +
              };
         
     | 
| 
      
 56 
     | 
    
         
            +
             
     | 
| 
      
 57 
     | 
    
         
            +
              return self;
         
     | 
| 
      
 58 
     | 
    
         
            +
            }( ));
         
     | 
    
        data/src/fb_stub.js
    ADDED
    
    | 
         @@ -0,0 +1,107 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            var FBStub = (function() {
         
     | 
| 
      
 2 
     | 
    
         
            +
              var self = { };
         
     | 
| 
      
 3 
     | 
    
         
            +
             
     | 
| 
      
 4 
     | 
    
         
            +
              var state, apiRequests;
         
     | 
| 
      
 5 
     | 
    
         
            +
             
     | 
| 
      
 6 
     | 
    
         
            +
              var initialize = function() {
         
     | 
| 
      
 7 
     | 
    
         
            +
                state = {
         
     | 
| 
      
 8 
     | 
    
         
            +
                  'loggedIn': false,
         
     | 
| 
      
 9 
     | 
    
         
            +
                  'connected': false,
         
     | 
| 
      
 10 
     | 
    
         
            +
                  'appId': null,
         
     | 
| 
      
 11 
     | 
    
         
            +
                  'user': {}
         
     | 
| 
      
 12 
     | 
    
         
            +
                };
         
     | 
| 
      
 13 
     | 
    
         
            +
                apiRequests = { };
         
     | 
| 
      
 14 
     | 
    
         
            +
              };
         
     | 
| 
      
 15 
     | 
    
         
            +
             
     | 
| 
      
 16 
     | 
    
         
            +
              initialize();
         
     | 
| 
      
 17 
     | 
    
         
            +
             
     | 
| 
      
 18 
     | 
    
         
            +
              self.addApiRequest = function(path, callback) {
         
     | 
| 
      
 19 
     | 
    
         
            +
                apiRequests[path] = callback;
         
     | 
| 
      
 20 
     | 
    
         
            +
              };
         
     | 
| 
      
 21 
     | 
    
         
            +
             
     | 
| 
      
 22 
     | 
    
         
            +
              self.findApiRequest = function(path) {
         
     | 
| 
      
 23 
     | 
    
         
            +
                return apiRequests[path];
         
     | 
| 
      
 24 
     | 
    
         
            +
              };
         
     | 
| 
      
 25 
     | 
    
         
            +
             
     | 
| 
      
 26 
     | 
    
         
            +
              self.loggedIn = function(user) {
         
     | 
| 
      
 27 
     | 
    
         
            +
                state.loggedIn = true;
         
     | 
| 
      
 28 
     | 
    
         
            +
                state.user = user || {};
         
     | 
| 
      
 29 
     | 
    
         
            +
              };
         
     | 
| 
      
 30 
     | 
    
         
            +
             
     | 
| 
      
 31 
     | 
    
         
            +
              self.notLoggedIn = function() {
         
     | 
| 
      
 32 
     | 
    
         
            +
                state.loggedIn = false;
         
     | 
| 
      
 33 
     | 
    
         
            +
                state.user = {};
         
     | 
| 
      
 34 
     | 
    
         
            +
              };
         
     | 
| 
      
 35 
     | 
    
         
            +
             
     | 
| 
      
 36 
     | 
    
         
            +
              self.connected = function() {
         
     | 
| 
      
 37 
     | 
    
         
            +
                state.connected = true;
         
     | 
| 
      
 38 
     | 
    
         
            +
              };
         
     | 
| 
      
 39 
     | 
    
         
            +
             
     | 
| 
      
 40 
     | 
    
         
            +
              self.notConnected = function() {
         
     | 
| 
      
 41 
     | 
    
         
            +
                state.connected = false;
         
     | 
| 
      
 42 
     | 
    
         
            +
              };
         
     | 
| 
      
 43 
     | 
    
         
            +
             
     | 
| 
      
 44 
     | 
    
         
            +
              self.isLoggedIn = function() {
         
     | 
| 
      
 45 
     | 
    
         
            +
                return state.loggedIn;
         
     | 
| 
      
 46 
     | 
    
         
            +
              };
         
     | 
| 
      
 47 
     | 
    
         
            +
             
     | 
| 
      
 48 
     | 
    
         
            +
              self.isConnected = function() {
         
     | 
| 
      
 49 
     | 
    
         
            +
                return state.connected;
         
     | 
| 
      
 50 
     | 
    
         
            +
              };
         
     | 
| 
      
 51 
     | 
    
         
            +
             
     | 
| 
      
 52 
     | 
    
         
            +
              self.userID = function() {
         
     | 
| 
      
 53 
     | 
    
         
            +
                return state.user.userID;
         
     | 
| 
      
 54 
     | 
    
         
            +
              };
         
     | 
| 
      
 55 
     | 
    
         
            +
             
     | 
| 
      
 56 
     | 
    
         
            +
              self.appId = function(id) {
         
     | 
| 
      
 57 
     | 
    
         
            +
                if (id) {
         
     | 
| 
      
 58 
     | 
    
         
            +
                  state.appId = id;
         
     | 
| 
      
 59 
     | 
    
         
            +
                }
         
     | 
| 
      
 60 
     | 
    
         
            +
                return state.appId;
         
     | 
| 
      
 61 
     | 
    
         
            +
              };
         
     | 
| 
      
 62 
     | 
    
         
            +
             
     | 
| 
      
 63 
     | 
    
         
            +
              self.reset = function() {
         
     | 
| 
      
 64 
     | 
    
         
            +
                initialize();
         
     | 
| 
      
 65 
     | 
    
         
            +
              };
         
     | 
| 
      
 66 
     | 
    
         
            +
             
     | 
| 
      
 67 
     | 
    
         
            +
              self.logInAndAuthorize = function() {
         
     | 
| 
      
 68 
     | 
    
         
            +
                if (!self.initialized()) return;
         
     | 
| 
      
 69 
     | 
    
         
            +
                self.loginCallback({
         
     | 
| 
      
 70 
     | 
    
         
            +
                  status: "connected",
         
     | 
| 
      
 71 
     | 
    
         
            +
                  authResponse: {
         
     | 
| 
      
 72 
     | 
    
         
            +
                    accessToken: "",
         
     | 
| 
      
 73 
     | 
    
         
            +
                    userID: "",
         
     | 
| 
      
 74 
     | 
    
         
            +
                    expiresIn: 4374,
         
     | 
| 
      
 75 
     | 
    
         
            +
                    signedRequest: ""
         
     | 
| 
      
 76 
     | 
    
         
            +
                  }
         
     | 
| 
      
 77 
     | 
    
         
            +
                });
         
     | 
| 
      
 78 
     | 
    
         
            +
              };
         
     | 
| 
      
 79 
     | 
    
         
            +
             
     | 
| 
      
 80 
     | 
    
         
            +
              self.logInAndDeny = function() {
         
     | 
| 
      
 81 
     | 
    
         
            +
                if (!self.initialized()) return;
         
     | 
| 
      
 82 
     | 
    
         
            +
                self.loginCallback({
         
     | 
| 
      
 83 
     | 
    
         
            +
                  status: "not_authorized",
         
     | 
| 
      
 84 
     | 
    
         
            +
                  authResponse: null
         
     | 
| 
      
 85 
     | 
    
         
            +
                });
         
     | 
| 
      
 86 
     | 
    
         
            +
              };
         
     | 
| 
      
 87 
     | 
    
         
            +
             
     | 
| 
      
 88 
     | 
    
         
            +
              self.abortLogIn = function() {
         
     | 
| 
      
 89 
     | 
    
         
            +
                if (!self.initialized()) return;
         
     | 
| 
      
 90 
     | 
    
         
            +
                self.loginCallback({
         
     | 
| 
      
 91 
     | 
    
         
            +
                  status: "unknown",
         
     | 
| 
      
 92 
     | 
    
         
            +
                  authResponse: null
         
     | 
| 
      
 93 
     | 
    
         
            +
                });
         
     | 
| 
      
 94 
     | 
    
         
            +
              };
         
     | 
| 
      
 95 
     | 
    
         
            +
             
     | 
| 
      
 96 
     | 
    
         
            +
              self.respondToApiRequest = function(path, response) {
         
     | 
| 
      
 97 
     | 
    
         
            +
                if (typeof(apiRequests[path]) === 'undefined') return;
         
     | 
| 
      
 98 
     | 
    
         
            +
                apiRequests[path](response);
         
     | 
| 
      
 99 
     | 
    
         
            +
              };
         
     | 
| 
      
 100 
     | 
    
         
            +
             
     | 
| 
      
 101 
     | 
    
         
            +
              self.initialized = function() {
         
     | 
| 
      
 102 
     | 
    
         
            +
                var appId = state.appId;
         
     | 
| 
      
 103 
     | 
    
         
            +
                return (typeof(appId) == 'number' || typeof(appId) == "string");
         
     | 
| 
      
 104 
     | 
    
         
            +
              };
         
     | 
| 
      
 105 
     | 
    
         
            +
             
     | 
| 
      
 106 
     | 
    
         
            +
              return self;
         
     | 
| 
      
 107 
     | 
    
         
            +
            }( ));
         
     | 
    
        data/{Users/nort/git/facebook-js-stub/vendor → vendor}/assets/javascripts/facebook-js-stub.js
    RENAMED
    
    | 
         
            File without changes
         
     | 
    
        metadata
    CHANGED
    
    | 
         @@ -1,11 +1,12 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: facebook-js-stub
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version
         
     | 
| 
       4 
     | 
    
         
            -
              version: 0.1. 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 0.1.4
         
     | 
| 
       5 
5 
     | 
    
         
             
              prerelease: 
         
     | 
| 
       6 
6 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       7 
7 
     | 
    
         
             
            authors:
         
     | 
| 
       8 
8 
     | 
    
         
             
            - Involver
         
     | 
| 
      
 9 
     | 
    
         
            +
            - Brian Norton
         
     | 
| 
       9 
10 
     | 
    
         
             
            autorequire: 
         
     | 
| 
       10 
11 
     | 
    
         
             
            bindir: bin
         
     | 
| 
       11 
12 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
         @@ -17,9 +18,23 @@ executables: [] 
     | 
|
| 
       17 
18 
     | 
    
         
             
            extensions: []
         
     | 
| 
       18 
19 
     | 
    
         
             
            extra_rdoc_files: []
         
     | 
| 
       19 
20 
     | 
    
         
             
            files:
         
     | 
| 
       20 
     | 
    
         
            -
            -  
     | 
| 
       21 
     | 
    
         
            -
            - / 
     | 
| 
       22 
     | 
    
         
            -
            - / 
     | 
| 
      
 21 
     | 
    
         
            +
            - lib/facebook-js-stub/engine.rb
         
     | 
| 
      
 22 
     | 
    
         
            +
            - lib/facebook-js-stub/version.rb
         
     | 
| 
      
 23 
     | 
    
         
            +
            - lib/facebook-js-stub.rb
         
     | 
| 
      
 24 
     | 
    
         
            +
            - spec/javascripts/api_spec.js
         
     | 
| 
      
 25 
     | 
    
         
            +
            - spec/javascripts/get_login_status_spec.js
         
     | 
| 
      
 26 
     | 
    
         
            +
            - spec/javascripts/helpers/spec_helper.js
         
     | 
| 
      
 27 
     | 
    
         
            +
            - spec/javascripts/login_spec.js
         
     | 
| 
      
 28 
     | 
    
         
            +
            - spec/javascripts/support/jasmine.yml
         
     | 
| 
      
 29 
     | 
    
         
            +
            - spec/javascripts/support/jasmine_config.rb
         
     | 
| 
      
 30 
     | 
    
         
            +
            - spec/javascripts/support/jasmine_runner.rb
         
     | 
| 
      
 31 
     | 
    
         
            +
            - src/fb.js
         
     | 
| 
      
 32 
     | 
    
         
            +
            - src/fb_stub.js
         
     | 
| 
      
 33 
     | 
    
         
            +
            - vendor/assets/javascripts/facebook-js-stub.js
         
     | 
| 
      
 34 
     | 
    
         
            +
            - Gemfile
         
     | 
| 
      
 35 
     | 
    
         
            +
            - MIT-LICENSE
         
     | 
| 
      
 36 
     | 
    
         
            +
            - Rakefile
         
     | 
| 
      
 37 
     | 
    
         
            +
            - README.md
         
     | 
| 
       23 
38 
     | 
    
         
             
            homepage: 
         
     | 
| 
       24 
39 
     | 
    
         
             
            licenses: []
         
     | 
| 
       25 
40 
     | 
    
         
             
            post_install_message: 
         
     | 
| 
         @@ -43,6 +58,6 @@ rubyforge_project: 
     | 
|
| 
       43 
58 
     | 
    
         
             
            rubygems_version: 1.8.25
         
     | 
| 
       44 
59 
     | 
    
         
             
            signing_key: 
         
     | 
| 
       45 
60 
     | 
    
         
             
            specification_version: 3
         
     | 
| 
       46 
     | 
    
         
            -
            summary:  
     | 
| 
      
 61 
     | 
    
         
            +
            summary: A mocking framework for the FB javascript library.
         
     | 
| 
       47 
62 
     | 
    
         
             
            test_files: []
         
     | 
| 
       48 
63 
     | 
    
         
             
            has_rdoc: 
         
     |