lib/generators/rspec/templates/oauth2_verifier_spec.rb in oauth-plugin-0.4.0.pre7 vs lib/generators/rspec/templates/oauth2_verifier_spec.rb in oauth-plugin-0.4.0.rc1

- old
+ new

@@ -1,11 +1,11 @@ require File.dirname(__FILE__) + '/../spec_helper' describe Oauth2Verifier do fixtures :client_applications, :users, :oauth_tokens before(:each) do - @verifier = Oauth2Verifier.create :client_application => client_applications(:one), :user=>users(:aaron) + @verifier = Oauth2Verifier.create :client_application => client_applications(:one), :user=>users(:aaron), :scope => "bbbb aaaa" end it "should be valid" do @verifier.should be_valid end @@ -24,31 +24,21 @@ it "should not be invalidated" do @verifier.should_not be_invalidated end - describe "exchange for oauth2 token" do - before(:each) do - @token = @verifier.exchange! - end + it "should generate query string" do + @verifier.to_query.should == "code=#{@verifier.code}" + @verifier.state="bbbb aaaa" + @verifier.to_query.should == "code=#{@verifier.code}&state=bbbb%20aaaa" + end - it "should invalidate verifier" do - @verifier.should be_invalidated - end - - it "should set user on token" do - @token.user.should==@verifier.user - end - - it "should set client application on token" do - @token.client_application.should == @verifier.client_application - end - - it "should be authorized" do - @token.should be_authorized - end - - it "should not be invalidated" do - @token.should_not be_invalidated - end + it "should properly exchange for token" do + @token = @verifier.exchange! + @verifier.should be_invalidated + @token.user.should==@verifier.user + @token.client_application.should == @verifier.client_application + @token.should be_authorized + @token.should_not be_invalidated + @token.scope.should == @verifier.scope end -end +end \ No newline at end of file