Sha256: be46073dcd1becfa53dc09cb1557dbc978769ea31672bce43e782a55c64d7f8d
Contents?: true
Size: 1.7 KB
Versions: 3
Compression:
Stored size: 1.7 KB
Contents
require 'spec_helper' require 'action_controller' describe GiveyRuby::Controller do before(:all) do class CharityController include GiveyRuby::Controller end GiveyRuby.configure do |config| config.client({token_file: "#{SPEC_ROOT}/tmp/givey_token_file"}) end end let(:charity_controller) { CharityController.new } describe "access_token" do let(:api_token) { stub('api_token', token: 'udhs7gf7ssg') } it "should get new token and update session if it doesn't exist" do charity_controller.stub(:session).and_return({}) charity_controller.stub_chain(:api_client, :client_credentials, :get_token).and_return(api_token) charity_controller.stub(:token_to_file) # Because token_to_file cannot find the file/folder in a full test run charity_controller.access_token.should == api_token charity_controller.session[:access_token].should == 'udhs7gf7ssg' end it "should get token from existing session" do charity_controller.should_receive(:session).twice.and_return({access_token: '8h7g6f5fjshd'}) OAuth2::AccessToken.should_receive(:new).and_return(api_token) charity_controller.access_token.should == api_token end end describe "get_token_response" do let(:api_token) { stub('api_token', token: 'udhs7gf7ssg') } it "returns hash for requested URL" do charity_controller.should_receive(:session).twice.and_return({access_token: '8h7g6f5fjshd'}) OAuth2::AccessToken.should_receive(:new).and_return(api_token) charity_controller.access_token.stub_chain(:get, :body).and_return({this: 'that'}.to_json) charity_controller.get_token_response("/this").should == {"this" => 'that'} end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
givey_ruby-0.0.6 | spec/givey_ruby/controller_spec.rb |
givey_ruby-0.0.5 | spec/givey_ruby/controller_spec.rb |
givey_ruby-0.0.3 | spec/givey_ruby/controller_spec.rb |