spec/blather/stanza/x_spec.rb in blather-0.6.2 vs spec/blather/stanza/x_spec.rb in blather-0.7.0

- old
+ new

@@ -30,64 +30,64 @@ describe Blather::Stanza::X do it 'can be created from an XML string' do x = Blather::Stanza::X.new parse_stanza(x_xml).root - x.type.must_equal :form - x.must_be_instance_of Blather::Stanza::X + x.type.should == :form + x.should be_instance_of Blather::Stanza::X end [:cancel, :form, :result, :submit].each do |type| it "type can be set as \"#{type}\"" do x = Blather::Stanza::X.new type - x.type.must_equal type + x.type.should == type end end it 'is constructed properly' do n = Blather::Stanza::X.new :form - n.find("/ns:x[@type='form']", :ns => Blather::Stanza::X.registered_ns).wont_be_empty + n.find("/ns:x[@type='form']", :ns => Blather::Stanza::X.registered_ns).should_not be_empty end it 'has an action attribute' do n = Blather::Stanza::X.new :form - n.type.must_equal :form + n.type.should == :form n.type = :submit - n.type.must_equal :submit + n.type.should == :submit end it 'has a title attribute' do n = Blather::Stanza::X.new :form - n.title.must_equal nil + n.title.should == nil n.title = "Hello World!" - n.title.must_equal "Hello World!" + n.title.should == "Hello World!" n.title = "goodbye" - n.title.must_equal "goodbye" + n.title.should == "goodbye" end it 'has an instructions attribute' do n = Blather::Stanza::X.new :form - n.instructions.must_equal nil + n.instructions.should == nil n.instructions = "Please fill in this form" - n.instructions.must_equal "Please fill in this form" + n.instructions.should == "Please fill in this form" n.instructions = "goodbye" - n.instructions.must_equal "goodbye" + n.instructions.should == "goodbye" end it 'inherits a list of fields' do n = Blather::Stanza::Iq::Command.new n.command << parse_stanza(x_xml).root r = Blather::Stanza::X.new.inherit n.form - r.fields.size.must_equal 4 - r.fields.map { |f| f.class }.uniq.must_equal [Blather::Stanza::X::Field] + r.fields.size.should == 4 + r.fields.map { |f| f.class }.uniq.should == [Blather::Stanza::X::Field] end it 'returns a field object for a particular var' do x = Blather::Stanza::X.new parse_stanza(x_xml).root f = x.field 'field-name4' - f.must_be_instance_of Blather::Stanza::X::Field - f.value.must_equal 'field-value4' + f.should be_instance_of Blather::Stanza::X::Field + f.value.should == 'field-value4' end it 'takes a list of hashes for fields' do fields = [ {:label => 'label', :type => 'text-single', :var => 'var'}, @@ -96,21 +96,21 @@ control = [ Blather::Stanza::X::Field.new(*%w[var text-single label]), Blather::Stanza::X::Field.new(*%w[var1 text-single label1])] di = Blather::Stanza::X.new nil, fields - di.fields.size.must_equal 2 - di.fields.each { |f| control.include?(f).must_equal true } + di.fields.size.should == 2 + di.fields.each { |f| control.include?(f).should == true } end it 'takes a list of Field objects as fields' do control = [ Blather::Stanza::X::Field.new(*%w[var text-single label1]), Blather::Stanza::X::Field.new(*%w[var1 text-single label1])] di = Blather::Stanza::X.new nil, control - di.fields.size.must_equal 2 - di.fields.each { |f| control.include?(f).must_equal true } + di.fields.size.should == 2 + di.fields.each { |f| control.include?(f).should == true } end it 'takes a mix of hashes and field objects as fields' do fields = [ {:label => 'label', :type => 'text-single', :var => 'var'}, @@ -119,112 +119,112 @@ control = [ Blather::Stanza::X::Field.new(*%w[var text-single label]), Blather::Stanza::X::Field.new(*%w[var1 text-single label1])] di = Blather::Stanza::X.new nil, fields - di.fields.size.must_equal 2 - di.fields.each { |f| control.include?(f).must_equal true } + di.fields.size.should == 2 + di.fields.each { |f| control.include?(f).should == true } end it 'allows adding of fields' do di = Blather::Stanza::X.new nil - di.fields.size.must_equal 0 + di.fields.size.should == 0 di.fields = [{:label => 'label', :type => 'text-single', :var => 'var', :required => true}] - di.fields.size.must_equal 1 + di.fields.size.should == 1 di.fields += [Blather::Stanza::X::Field.new(*%w[var1 text-single label1])] - di.fields.size.must_equal 2 + di.fields.size.should == 2 end end describe Blather::Stanza::X::Field do it 'will auto-inherit nodes' do n = parse_stanza "<field type='text-single' var='music' label='Music from the time of Shakespeare' />" i = Blather::Stanza::X::Field.new n.root - i.type.must_equal 'text-single' - i.var.must_equal 'music' - i.label.must_equal 'Music from the time of Shakespeare' + i.type.should == 'text-single' + i.var.should == 'music' + i.label.should == 'Music from the time of Shakespeare' end it 'has a type attribute' do n = Blather::Stanza::X::Field.new 'var', 'text-single' - n.type.must_equal 'text-single' + n.type.should == 'text-single' n.type = 'hidden' - n.type.must_equal 'hidden' + n.type.should == 'hidden' end it 'has a var attribute' do n = Blather::Stanza::X::Field.new 'name', 'text-single' - n.var.must_equal 'name' + n.var.should == 'name' n.var = 'email' - n.var.must_equal 'email' + n.var.should == 'email' end it 'has a label attribute' do n = Blather::Stanza::X::Field.new 'subject', 'text-single', 'Music from the time of Shakespeare' - n.label.must_equal 'Music from the time of Shakespeare' + n.label.should == 'Music from the time of Shakespeare' n.label = 'Books by and about Shakespeare' - n.label.must_equal 'Books by and about Shakespeare' + n.label.should == 'Books by and about Shakespeare' end it 'has a desc attribute' do n = Blather::Stanza::X::Field.new 'subject', 'text-single', 'Music from the time of Shakespeare' - n.desc.must_equal nil + n.desc.should == nil n.desc = 'Books by and about Shakespeare' - n.desc.must_equal 'Books by and about Shakespeare' + n.desc.should == 'Books by and about Shakespeare' n.desc = 'goodbye' - n.desc.must_equal 'goodbye' + n.desc.should == 'goodbye' end it 'has a required? attribute' do n = Blather::Stanza::X::Field.new 'subject', 'text-single', 'Music from the time of Shakespeare' - n.required?.must_equal false + n.required?.should == false n.required = true - n.required?.must_equal true + n.required?.should == true n.required = false - n.required?.must_equal false + n.required?.should == false end it 'has a value attribute' do n = Blather::Stanza::X::Field.new 'subject', 'text-single', 'Music from the time of Shakespeare' - n.value.must_equal nil + n.value.should == nil n.value = 'book1' - n.value.must_equal 'book1' + n.value.should == 'book1' n.value = 'book2' - n.value.must_equal 'book2' + n.value.should == 'book2' end # Option child elements it 'allows adding of options' do di = Blather::Stanza::X::Field.new nil - di.options.size.must_equal 0 + di.options.size.should == 0 di.options += [{:label => 'Person', :value => 'person'}] - di.options.size.must_equal 1 + di.options.size.should == 1 di.options += [Blather::Stanza::X::Field::Option.new(*%w[person1 Person1])] - di.options.size.must_equal 2 + di.options.size.should == 2 end it 'can determine equality' do a = Blather::Stanza::X::Field.new('subject', 'text-single') - a.must_equal Blather::Stanza::X::Field.new('subject', 'text-single') - a.wont_equal Blather::Stanza::X::Field.new('subject1', 'text-single') + a.should == Blather::Stanza::X::Field.new('subject', 'text-single') + a.should_not equal Blather::Stanza::X::Field.new('subject1', 'text-single') end end describe Blather::Stanza::X::Field::Option do it 'has a value attribute' do n = Blather::Stanza::X::Field::Option.new 'person1', 'Person 1' - n.value.must_equal 'person1' + n.value.should == 'person1' n.value = 'book1' - n.value.must_equal 'book1' + n.value.should == 'book1' end it 'has a label attribute' do n = Blather::Stanza::X::Field::Option.new 'person1', 'Person 1' - n.label.must_equal 'Person 1' + n.label.should == 'Person 1' n.label = 'Book 1' - n.label.must_equal 'Book 1' + n.label.should == 'Book 1' n.label = 'Book 2' - n.label.must_equal 'Book 2' + n.label.should == 'Book 2' end end