This repository has been archived by the owner on Feb 6, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
update Document#id= to handle values that are (or can be converted to…
…) Strings and are compliant
- Loading branch information
Showing
2 changed files
with
33 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,38 @@ | ||
require 'spec_helper' | ||
|
||
describe AwsCloudSearch::Document do | ||
before(:each) do | ||
@doc = AwsCloudSearch::Document.new | ||
end | ||
let (:doc) { AwsCloudSearch::Document.new } | ||
|
||
it "should accept values of the proper type" do | ||
expect { @doc.id='123abc' }.to_not raise_error | ||
expect { @doc.lang='en' }.to_not raise_error | ||
expect { @doc.version=123 }.to_not raise_error | ||
end | ||
context "#id=" do | ||
it "should accept a String-able value (Integer)" do | ||
expect { doc.id = 123456789 }.to_not raise_error | ||
end | ||
|
||
it "should accept a compliant String" do | ||
expect { doc.id = "abcdef" }.to_not raise_error | ||
end | ||
|
||
it "should throw an exception when given values of the wrong type" do | ||
expect { @doc.id=123 }.to raise_error(Exception) | ||
expect { @doc.lang=123 }.to raise_error(Exception) | ||
expect { @doc.version='abc123' }.to raise_error(Exception) | ||
it "should not accept a non-compliant String" do | ||
expect { doc.id = 'AZ12' }.to raise_error(ArgumentError) | ||
expect { doc.id = '!@#$%^&*()AZ' }.to raise_error(ArgumentError) | ||
expect { doc.id = '_abc123' }.to raise_error(ArgumentError) | ||
end | ||
|
||
it "should not accept nil" do | ||
expect { doc.id = nil }.to raise_error(ArgumentError) | ||
end | ||
end | ||
|
||
it "should reject an incorrectly formatted id" do | ||
expect { @doc.id='AZ12'}.to raise_error(Exception) | ||
expect { @doc.id='!@#$%^&*()AZ'}.to raise_error(Exception) | ||
expect { @doc.id= '_abc123'}.to raise_error(Exception) | ||
context "#type_attr_accessor attributes" do | ||
it "should accept values of proper type" do | ||
expect { doc.lang = 'abcd' }.to_not raise_error | ||
expect { doc.version = 1234 }.to_not raise_error | ||
end | ||
|
||
it "should not accept values of incorrect type" do | ||
expect { doc.lang = 1234 }.to raise_error(ArgumentError) | ||
expect { doc.version "abcd" }.to raise_error(ArgumentError) | ||
end | ||
end | ||
|
||
end | ||
end |