spec/wordnik_spec.rb in wordnik-0.3.8 vs spec/wordnik_spec.rb in wordnik-0.3.9
- old
+ new
@@ -3,10 +3,13 @@
describe Wordnik do
before(:each) do
configure_wordnik
end
+
+ after(:each) do
+ end
context "initialization" do
context "resources" do
it "instantiates resources from cached JSON" do
@@ -47,14 +50,25 @@
config.api_key = CREDENTIALS[:api_key]
config.username = CREDENTIALS[:username]
config.password = 'wrong!'
config.base_uri = "beta.wordnik.com/v4"
end
+ lambda { Wordnik.authenticate }.should raise_error(ApiServerError)
Wordnik.authenticated?.should == false
end
- it "fails if username and/or password are absent"
+ it "fails if username and/or password are absent" do
+ Wordnik.de_authenticate
+ Wordnik.configure do |config|
+ config.api_key = CREDENTIALS[:api_key]
+ config.username = nil
+ config.password = nil
+ config.base_uri = "beta.wordnik.com/v4"
+ end
+ lambda { Wordnik.authenticate }.should raise_error(ConfigurationError, /username and password are required/i)
+ Wordnik.authenticated?.should == false
+ end
end
end
@@ -88,18 +102,39 @@
it "passes optional key-value arguments to the query string" do
@request.query_string.should == "?limit=10&skip=2"
end
+ it "puts key-value arguments in the request body instead of the query params"
+
end
context "wordlists" do
+ before do
+ configure_wordnik
+ Wordnik.authenticate
+ end
+
it "creates a wordlist" do
-
+ body = {
+ :name=> "Wordnik Ruby Test List #{RAND}",
+ :description => 'This is created by the test suite.',
+ :type => 'PUBLIC',
+ :user_id => Wordnik.configuration.user_id
+ }
+ request = Wordnik::Request.new(:post, "wordLists", :body => body)
+ request.response.body.should be_a_kind_of(Hash)
+ request.response.body.should have_key('permalink')
end
- it "adds words"
+ it "finds the new wordlist" do
+ lists = Wordnik.account.get_word_lists
+ permalinks = lists.map { |list| list['permalink'] }
+ permalinks.should include("wordnik-ruby-test-list-#{RAND}")
+ end
+
+ it "finds the new wordlist and adds words to it"
it "updates words"
it "get all the words"
\ No newline at end of file