xmlss 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile CHANGED
@@ -2,3 +2,5 @@ source "http://rubygems.org"
2
2
 
3
3
  # Specify your gem's dependencies in xmlss.gemspec
4
4
  gemspec
5
+
6
+ gem 'rake', '~>0.9.2'
data/Gemfile.lock CHANGED
@@ -1,31 +1,25 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- xmlss (0.2.0)
5
- enumeration (~> 1.1.0)
4
+ xmlss (0.2.1)
5
+ enumeration (~> 1.2)
6
6
  nokogiri (~> 1.4.0)
7
7
 
8
8
  GEM
9
9
  remote: http://rubygems.org/
10
10
  specs:
11
- enumeration (1.1.0)
12
- json (1.5.1)
13
- kelredd-useful (0.4.1)
14
- json
15
- leftright (0.9.0)
16
- nokogiri (1.4.4)
17
- shoulda (2.11.3)
18
- test-belt (0.2.1)
19
- kelredd-useful (~> 0.4.0)
20
- leftright (~> 0.9.0)
21
- shoulda (~> 2.11)
11
+ ansi (1.3.0)
12
+ assert (0.3.0)
13
+ ansi (~> 1.3)
14
+ enumeration (1.2.1)
15
+ nokogiri (1.4.7)
16
+ rake (0.9.2)
22
17
 
23
18
  PLATFORMS
24
19
  ruby
25
20
 
26
21
  DEPENDENCIES
22
+ assert (~> 0.3)
27
23
  bundler (~> 1.0)
28
- enumeration (~> 1.1.0)
29
- nokogiri (~> 1.4.0)
30
- test-belt (= 0.2.1)
24
+ rake (~> 0.9.2)
31
25
  xmlss!
data/Rakefile CHANGED
@@ -1,7 +1,7 @@
1
+ require 'assert/rake_tasks'
2
+ include Assert::RakeTasks
3
+
1
4
  require 'bundler'
2
5
  Bundler::GemHelper.install_tasks
3
6
 
4
- require 'test_belt/rake_tasks'
5
- TestBelt::RakeTasks.for :test
6
-
7
7
  task :default => :build
data/lib/xmlss/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Xmlss
2
- VERSION = "0.2.0"
2
+ VERSION = "0.2.1"
3
3
  end
data/test/cell_test.rb CHANGED
@@ -1,86 +1,89 @@
1
- require "test/helper"
1
+ require "assert"
2
2
  require 'xmlss/cell'
3
3
 
4
4
  module Xmlss
5
- class CellTest < Test::Unit::TestCase
5
+ class CellTest < Assert::Context
6
+ desc "Xmlss::Cell"
7
+ subject { Cell.new }
6
8
 
7
- context "Xmlss::Cell" do
8
- subject { Cell.new }
9
+ should have_accessor :index, :data
10
+ should have_accessor :formula, :href, :merge_across, :merge_down
11
+ should have_reader :h_ref
9
12
 
10
- should_have_accessor :index, :data
11
- should_have_accessor :formula, :href, :merge_across, :merge_down
12
- should_have_reader :h_ref
13
+ should_have_style(Cell)
13
14
 
14
- should_have_style(Cell)
15
-
16
- should "set it's defaults" do
17
- [:data, :formula, :href].each do |a|
18
- assert_equal nil, subject.send(a)
19
- end
20
- assert_equal nil, subject.merge_across
21
- assert_equal nil, subject.merge_down
15
+ should "set it's defaults" do
16
+ [:data, :formula, :href].each do |a|
17
+ assert_equal nil, subject.send(a)
22
18
  end
19
+ assert_equal nil, subject.merge_across
20
+ assert_equal nil, subject.merge_down
21
+ end
23
22
 
24
- should "provide alias for :href" do
25
- c = Cell.new({:href => "http://www.google.com"})
26
- assert_equal "http://www.google.com", c.href
27
- assert_equal "http://www.google.com", c.h_ref
28
- end
23
+ should "provide alias for :href" do
24
+ c = Cell.new({:href => "http://www.google.com"})
25
+ assert_equal "http://www.google.com", c.href
26
+ assert_equal "http://www.google.com", c.h_ref
27
+ end
29
28
 
30
- should "bark when setting non Fixnum indices" do
31
- assert_raises ArgumentError do
32
- Cell.new({:index => "do it"})
33
- end
34
- assert_raises ArgumentError do
35
- Cell.new({:index => 2.5})
36
- end
37
- assert_nothing_raised do
38
- Cell.new({:index => 2})
39
- end
29
+ should "bark when setting non Fixnum indices" do
30
+ assert_raises ArgumentError do
31
+ Cell.new({:index => "do it"})
40
32
  end
41
-
42
- should "bark when setting non Fixnum merge attrs" do
43
- assert_raises ArgumentError do
44
- Cell.new({:merge_across => "do it"})
45
- end
46
- assert_raises ArgumentError do
47
- Cell.new({:merge_down => 2.5})
48
- end
49
- assert_nothing_raised do
50
- Cell.new({:merge_across => 2})
51
- end
52
- assert_nothing_raised do
53
- Cell.new({:merge_down => 3})
54
- end
33
+ assert_raises ArgumentError do
34
+ Cell.new({:index => 2.5})
55
35
  end
56
-
57
- should "nil out merge/index values that are <= 0" do
58
- [:index, :merge_across, :merge_down].each do |a|
59
- assert_equal nil, Cell.new({a => -1}).send(a)
60
- assert_equal nil, Cell.new({a => 0}).send(a)
61
- assert_equal 1, Cell.new({a => 1}).send(a)
62
- end
36
+ assert_nothing_raised do
37
+ Cell.new({:index => 2})
63
38
  end
39
+ end
64
40
 
65
- context "when using cell data" do
66
- subject do
67
- Cell.new({
68
- :data => Data.new(12, {:type => :number})
69
- })
70
- end
71
-
72
- should "should build a data object" do
73
- assert_kind_of Data, subject.data
74
- assert_equal 12, subject.data.value
75
- end
41
+ should "bark when setting non Fixnum merge attrs" do
42
+ assert_raises ArgumentError do
43
+ Cell.new({:merge_across => "do it"})
44
+ end
45
+ assert_raises ArgumentError do
46
+ Cell.new({:merge_down => 2.5})
47
+ end
48
+ assert_nothing_raised do
49
+ Cell.new({:merge_across => 2})
76
50
  end
51
+ assert_nothing_raised do
52
+ Cell.new({:merge_down => 3})
53
+ end
54
+ end
77
55
 
78
- context "for generating XML" do
79
- should_have_reader :xml
80
- should_build_node
56
+ should "nil out merge/index values that are <= 0" do
57
+ [:index, :merge_across, :merge_down].each do |a|
58
+ assert_equal nil, Cell.new({a => -1}).send(a)
59
+ assert_equal nil, Cell.new({a => 0}).send(a)
60
+ assert_equal 1, Cell.new({a => 1}).send(a)
81
61
  end
62
+ end
63
+
64
+ end
65
+
66
+ class CellDataTest < Assert::Context
67
+ desc "when using cell data"
68
+ subject do
69
+ Cell.new({
70
+ :data => Data.new(12, {:type => :number})
71
+ })
72
+ end
82
73
 
74
+ should "should build a data object" do
75
+ assert_kind_of Data, subject.data
76
+ assert_equal 12, subject.data.value
83
77
  end
84
78
 
85
79
  end
80
+
81
+ class CellDataXmlTest < CellDataTest
82
+ desc "for generating XML"
83
+
84
+ should have_reader :xml
85
+ should_build_node
86
+
87
+ end
88
+
86
89
  end
data/test/column_test.rb CHANGED
@@ -1,46 +1,47 @@
1
- require "test/helper"
1
+ require "assert"
2
2
  require 'xmlss/column'
3
3
 
4
4
  module Xmlss
5
- class ColumnTest < Test::Unit::TestCase
5
+ class ColumnTest < Assert::Context
6
+ desc "Xmlss::Column"
7
+ subject { Column.new }
6
8
 
7
- context "Xmlss::Column" do
8
- subject { Column.new }
9
+ should_have_style(Column)
10
+ should have_accessor :width, :auto_fit_width, :hidden
9
11
 
10
- should_have_style(Column)
11
- should_have_accessor :width, :auto_fit_width, :hidden
12
-
13
- should "set it's defaults" do
14
- assert_equal nil, subject.width
15
- assert_equal false, subject.auto_fit_width
16
- assert_equal false, subject.hidden
17
- end
12
+ should "set it's defaults" do
13
+ assert_equal nil, subject.width
14
+ assert_equal false, subject.auto_fit_width
15
+ assert_equal false, subject.hidden
16
+ end
18
17
 
19
- should "bark when setting non Numeric width" do
20
- assert_raises ArgumentError do
21
- Column.new({:width => "do it"})
22
- end
23
- assert_nothing_raised do
24
- Column.new({:width => 2})
25
- end
26
- assert_nothing_raised do
27
- Column.new({:width => 3.5})
28
- end
18
+ should "bark when setting non Numeric width" do
19
+ assert_raises ArgumentError do
20
+ Column.new({:width => "do it"})
29
21
  end
30
-
31
- should "nil out height values that are < 0" do
32
- assert_equal nil, Column.new({:width => -1.2}).width
33
- assert_equal nil, Column.new({:width => -1}).width
34
- assert_equal 0, Column.new({:width => 0}).width
35
- assert_equal 1.2, Column.new({:width => 1.2}).width
22
+ assert_nothing_raised do
23
+ Column.new({:width => 2})
36
24
  end
37
-
38
- context "for generating XML" do
39
- should_have_reader :xml
40
- should_build_node
25
+ assert_nothing_raised do
26
+ Column.new({:width => 3.5})
41
27
  end
28
+ end
42
29
 
30
+ should "nil out height values that are < 0" do
31
+ assert_equal nil, Column.new({:width => -1.2}).width
32
+ assert_equal nil, Column.new({:width => -1}).width
33
+ assert_equal 0, Column.new({:width => 0}).width
34
+ assert_equal 1.2, Column.new({:width => 1.2}).width
43
35
  end
44
36
 
45
37
  end
38
+
39
+ class ColumnXmlTest < ColumnTest
40
+ desc "for generating XML"
41
+
42
+ should have_reader :xml
43
+ should_build_node
44
+
45
+ end
46
+
46
47
  end
data/test/data_test.rb CHANGED
@@ -1,75 +1,82 @@
1
- require "test/helper"
1
+ require "assert"
2
2
  require 'xmlss/data'
3
3
 
4
4
  module Xmlss
5
- class DataTest < Test::Unit::TestCase
6
-
7
- context "Xmlss::Data" do
8
- subject { Data.new }
9
-
10
- should_have_accessor :type, :value
11
- should_have_instance_method :xml_value
12
-
13
- should "set it's defaults" do
14
- assert_equal Data.type(:string), subject.type
15
- assert_equal "", subject.value
16
- end
17
-
18
- should "generate it's xml value" do
19
- assert_equal "12", Data.new(12).xml_value
20
- assert_equal "string", Data.new("string").xml_value
21
- assert_equal "line#{Data::LB}break", Data.new("line\nbreak").xml_value
22
- assert_equal "return#{Data::LB}break", Data.new("return\rbreak").xml_value
23
- assert_equal "returnline#{Data::LB}break", Data.new("returnline\r\nbreak").xml_value
24
- assert_equal "2011-03-01T00:00:00", Data.new(DateTime.parse('03/01/2011')).xml_value
25
- assert_equal "2011-03-01T00:00:00", Data.new(Date.parse('03/01/2011')).xml_value
26
- time = Time.now
27
- assert_equal time.strftime("%Y-%m-%dT%H:%M:%S"), Data.new(time).xml_value
28
- end
29
-
30
- context "when using explicit type" do
31
- subject do
32
- Data.new(12, {:type => :string})
33
- end
34
-
35
- should "should ignore the value type" do
36
- assert_equal Data.type(:string), subject.type
37
- end
38
- end
39
-
40
- context "when no type is specified" do
41
- should "cast types for Number, DateTime, Boolean, String" do
42
- assert_equal Data.type(:number), Data.new(12).type
43
- assert_equal Data.type(:number), Data.new(123.45).type
44
- assert_equal Data.type(:date_time), Data.new(Time.now).type
45
- assert_equal Data.type(:boolean), Data.new(true).type
46
- assert_equal Data.type(:boolean), Data.new(false).type
47
- assert_equal Data.type(:string), Data.new("a string").type
48
- assert_equal Data.type(:string), Data.new(:symbol).type
49
- end
50
- end
51
-
52
- context "dealing with line breaks and leading space" do
53
- subject do
54
- Data.new(%s{
5
+ class DataTest < Assert::Context
6
+ desc "Xmlss::Data"
7
+ subject { Data.new }
8
+
9
+ should have_accessor :type, :value
10
+ should have_instance_method :xml_value
11
+
12
+ should "set it's defaults" do
13
+ assert_equal Data.type(:string), subject.type
14
+ assert_equal "", subject.value
15
+ end
16
+
17
+ should "generate it's xml value" do
18
+ assert_equal "12", Data.new(12).xml_value
19
+ assert_equal "string", Data.new("string").xml_value
20
+ assert_equal "line#{Data::LB}break", Data.new("line\nbreak").xml_value
21
+ assert_equal "return#{Data::LB}break", Data.new("return\rbreak").xml_value
22
+ assert_equal "returnline#{Data::LB}break", Data.new("returnline\r\nbreak").xml_value
23
+ assert_equal "2011-03-01T00:00:00", Data.new(DateTime.parse('2011/03/01')).xml_value
24
+ assert_equal "2011-03-01T00:00:00", Data.new(Date.parse('2011/03/01')).xml_value
25
+ time = Time.now
26
+ assert_equal time.strftime("%Y-%m-%dT%H:%M:%S"), Data.new(time).xml_value
27
+ end
28
+
29
+ end
30
+
31
+ class ExplicitDataTest < DataTest
32
+ desc "when using explicit type"
33
+ subject do
34
+ Data.new(12, {:type => :string})
35
+ end
36
+
37
+ should "should ignore the value type" do
38
+ assert_equal Data.type(:string), subject.type
39
+ end
40
+
41
+ end
42
+
43
+ class NoTypeDataTest < DataTest
44
+ desc "when no type is specified"
45
+
46
+ should "cast types for Number, DateTime, Boolean, String" do
47
+ assert_equal Data.type(:number), Data.new(12).type
48
+ assert_equal Data.type(:number), Data.new(123.45).type
49
+ assert_equal Data.type(:date_time), Data.new(Time.now).type
50
+ assert_equal Data.type(:boolean), Data.new(true).type
51
+ assert_equal Data.type(:boolean), Data.new(false).type
52
+ assert_equal Data.type(:string), Data.new("a string").type
53
+ assert_equal Data.type(:string), Data.new(:symbol).type
54
+ end
55
+
56
+ end
57
+
58
+ class WhitespaceDataTest < DataTest
59
+ desc "dealing with line breaks and leading space"
60
+ subject do
61
+ Data.new(%s{
55
62
  Should
56
63
  honor
57
64
  this
58
- })
59
- end
65
+ })
66
+ end
60
67
 
61
- should "honor them when generating xml" do
62
- reg = /#{Data::LB}Should#{Data::LB}\s{2}honor#{Data::LB}\s{4}this#{Data::LB}/
63
- assert_match reg, subject.xml_value
64
- end
65
- end
68
+ should "honor them when generating xml" do
69
+ reg = /#{Data::LB}Should#{Data::LB}\s{2}honor#{Data::LB}\s{4}this#{Data::LB}/
70
+ assert_match reg, subject.xml_value
71
+ end
66
72
 
67
- context "for generating XML" do
68
- should_have_reader :xml
69
- should_build_node
70
- end
73
+ end
71
74
 
72
- end
75
+ class XmlDataTest < DataTest
76
+ desc "for generating XML"
73
77
 
78
+ should have_reader :xml
79
+ should_build_node
74
80
  end
81
+
75
82
  end