diff options
Diffstat (limited to 'spec')
| -rw-r--r-- | spec/evernote/user_store_spec.rb | 20 | 
1 files changed, 16 insertions, 4 deletions
| diff --git a/spec/evernote/user_store_spec.rb b/spec/evernote/user_store_spec.rb index 04ec737..dcc33cd 100644 --- a/spec/evernote/user_store_spec.rb +++ b/spec/evernote/user_store_spec.rb @@ -6,14 +6,23 @@ describe "Evernote::UserStore" do      @env = :sandbox    end -  it "initializes an Evernote::Client" do -    Evernote::Client.should_receive(:new).with(Evernote::EDAM::UserStore::UserStore::Client, "https://sandbox.evernote.com/edam/user", {}) - +  it "initializes an Evernote::Client and validate the client code version" do +    client = mock("Evernote::Client", :checkVersion => true) +    Evernote::Client.should_receive(:new).with(Evernote::EDAM::UserStore::UserStore::Client, "https://sandbox.evernote.com/edam/user", {}).and_return(client) +        Evernote::UserStore.new("https://sandbox.evernote.com/edam/user", @auth_file, @env)    end +   +  it "should raise an error on init if the version is not up to date" do +    Evernote::Client.stub!(:new => mock("Evernote::Client", :checkVersion => false)) +   +    lambda { +      Evernote::UserStore.new("https://sandbox.evernote.com/edam/user", @auth_file, @env) +    }.should raise_error(Evernote::VersionOutOfDate, "The vendored Evernote client code is out of date and needs to be regenerated") +  end    %w(consumer_key consumer_secret username password).each do |credential| -    it "raises an exception if no #{credential} is set" do +    it "raises an exception if no #{credential} is set" do                    lambda {          Evernote::UserStore.new("https://sandbox.evernote.com/edam/user", @auth_file, :invalid)        }.should raise_error(ArgumentError, "'consumer_key', 'consumer_secret', 'username' and 'password' are required") @@ -21,6 +30,7 @@ describe "Evernote::UserStore" do    end    it "should authenticate" do +    Evernote::Client.stub!(:new => mock("Evernote::Client", :checkVersion => true))      user_store = Evernote::UserStore.new("https://sandbox.evernote.com/edam/user", @auth_file, @env)      user_store.instance_variable_get(:@client).should_receive(:authenticate).with("cgs", "password", "12345", "ABCDE").and_return(nil) @@ -28,6 +38,7 @@ describe "Evernote::UserStore" do    end    it "should wrap authentication failure" do +    Evernote::Client.stub!(:new => mock("Evernote::Client", :checkVersion => true))      user_store = Evernote::UserStore.new("https://sandbox.evernote.com/edam/user", @auth_file, @env)      user_store.instance_variable_get(:@client).should_receive(:authenticate).and_raise(Evernote::EDAM::Error::EDAMUserException) @@ -37,6 +48,7 @@ describe "Evernote::UserStore" do    end    it "should proxy methods" do +    Evernote::Client.stub!(:new => mock("Evernote::Client", :checkVersion => true))      user_store = Evernote::UserStore.new("https://sandbox.evernote.com/edam/user", @auth_file, @env)      user_store.instance_variable_get(:@client).should_receive(:foobar).and_return(nil) | 
