spec/unit/parser_spec.rb in transcriber-0.0.9 vs spec/unit/parser_spec.rb in transcriber-0.0.10
- old
+ new
@@ -5,21 +5,21 @@
it 'parses simple properties' do
class Example < Resource
property :login
end
- models = Example.parse({'login' => 'jackiechan2010'})
+ models = Example.parse({login: 'jackiechan2010'})
models.should be_an(Array)
models.first.login.should == 'jackiechan2010'
end
it 'uses different field name if defined' do
class Example < Resource
property :login, field: :customer_login
end
- models = Example.parse({'customer_login' => 'jackiechan2010'})
+ models = Example.parse({customer_login: 'jackiechan2010'})
models.should be_an(Array)
models.first.login.should == 'jackiechan2010'
end
context "uses type defined" do
@@ -29,38 +29,38 @@
property :can_merge, type: Boolean
end
end
it "returns true when value is 'X'" do
- models = Example.parse({'can_merge' => 'X'})
+ models = Example.parse({can_merge: 'X'})
models.first.can_merge.should be_true
end
it "returns false when value isn't 'X'" do
- models = Example.parse({'can_merge' => ''})
+ models = Example.parse({can_merge: ''})
models.first.can_merge.should be_false
end
end
context "date" do
it "parse" do
class Example < Resource
property :issue_date, type: Date
end
- models = Example.parse({'issue_date' => '2011-01-01'})
+ models = Example.parse({issue_date: '2011-01-01'})
models.first.issue_date.should == Date.parse('2011-01-01')
end
end
context "float" do
it "parse" do
class Example < Resource
property :amount, type: Float
end
- models = Example.parse({'amount' => '1234.5'})
+ models = Example.parse({amount: '1234.5'})
models.first.amount.should == 1234.5
end
end
end
@@ -70,15 +70,15 @@
property :status, values: {paid: '01', unpaid: '02'}
end
end
it "returns key when value was mapped" do
- models = Example.parse({'status' => '02'})
+ models = Example.parse({status: '02'})
models.first.status.should == :unpaid
end
it "returns nil when value wasn't mapped" do
- models = Example.parse({'status' => '03'})
+ models = Example.parse({status: '03'})
models.first.status.should be_nil
end
end
end
end