cell_set 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README +5 -0
- data/Rakefile +1 -0
- data/lib/cell_set/attributes.rb +62 -0
- data/lib/cell_set/cell.rb +24 -0
- data/lib/cell_set/cell_set.rb +152 -0
- data/lib/cell_set/cell_set_axis.rb +79 -0
- data/lib/cell_set/member.rb +75 -0
- data/lib/cell_set/model.rb +5 -0
- data/lib/cell_set/position.rb +60 -0
- data/lib/cell_set/result.rb +9 -0
- data/lib/cell_set/version.rb +3 -0
- data/lib/cell_set.rb +25 -0
- data/lib/mondrian/olap/cell_set/ruby.rb +61 -0
- data/spec/factories/cell_set_axis_factory.rb +4 -0
- data/spec/factories/cell_set_factory.rb +3 -0
- data/spec/factories/member_factory.rb +5 -0
- data/spec/factories/position_factory.rb +4 -0
- data/spec/factories/sequences.rb +7 -0
- data/spec/fixtures/FoodMart.xml +778 -0
- data/spec/fixtures/database.yml +19 -0
- data/spec/fixtures/postgresql-9.0-801.jdbc4.jar +0 -0
- data/spec/models/cell_set_axis_spec.rb +86 -0
- data/spec/models/cell_set_spec.rb +160 -0
- data/spec/models/member_spec.rb +68 -0
- data/spec/models/mondrian/olap/mondrian_olap4j_cell_set_spec.rb +109 -0
- data/spec/models/mondrian/olap/result_spec.rb +17 -0
- data/spec/models/position_spec.rb +83 -0
- data/spec/spec_helper.rb +26 -0
- data/spec/support/matchers/have_accessor.rb +7 -0
- metadata +166 -0
@@ -0,0 +1,19 @@
|
|
1
|
+
development:
|
2
|
+
adapter: postgresql
|
3
|
+
database: foodmart
|
4
|
+
password: foodmart
|
5
|
+
pool: 5
|
6
|
+
timeout: 5000
|
7
|
+
username: foodmart
|
8
|
+
host: localhost
|
9
|
+
jdbcDriver: org.postgresql.Driver
|
10
|
+
|
11
|
+
test:
|
12
|
+
adapter: postgresql
|
13
|
+
database: foodmart
|
14
|
+
password: foodmart
|
15
|
+
pool: 5
|
16
|
+
timeout: 5000
|
17
|
+
username: foodmart
|
18
|
+
host: localhost
|
19
|
+
jdbcDriver: org.postgresql.Driver
|
Binary file
|
@@ -0,0 +1,86 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe CellSet::CellSetAxis do
|
4
|
+
|
5
|
+
context "attributes" do
|
6
|
+
it { should have_accessor(:axis_ordinal) }
|
7
|
+
it { should have_accessor(:cell_set) }
|
8
|
+
it { should have_accessor(:positions) }
|
9
|
+
|
10
|
+
context "initialize" do
|
11
|
+
before(:each) do
|
12
|
+
@axis = Factory.build(:cell_set_axis)
|
13
|
+
end
|
14
|
+
|
15
|
+
it "should set positions to empty array" do
|
16
|
+
@axis.instance_variable_get(:@positions).should == []
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
context "positions" do
|
21
|
+
before(:each) do
|
22
|
+
@axis = Factory.build(:cell_set_axis)
|
23
|
+
end
|
24
|
+
|
25
|
+
let(:position) do
|
26
|
+
Factory.build(:position, :ordinal => 0)
|
27
|
+
end
|
28
|
+
|
29
|
+
it "should accept an array of Positions" do
|
30
|
+
positions = [position]
|
31
|
+
lambda{@axis.positions = positions}.should_not raise_error
|
32
|
+
end
|
33
|
+
|
34
|
+
it "should not accept Position or any other object" do
|
35
|
+
lambda{@axis.positions = position}.should raise_error
|
36
|
+
end
|
37
|
+
|
38
|
+
it "should not accept an array with items that are not a Position" do
|
39
|
+
positions = [position, Object.new]
|
40
|
+
lambda{@axis.positions = positions}.should raise_error
|
41
|
+
end
|
42
|
+
|
43
|
+
it "should accept a Hash as would be assigned by CellSetAxis#from_json" do
|
44
|
+
other_position = Factory.build(:position, :ordinal => 1)
|
45
|
+
hsh = [
|
46
|
+
position.as_json,
|
47
|
+
other_position.as_json
|
48
|
+
]
|
49
|
+
lambda{@axis.positions = hsh}.should_not raise_error
|
50
|
+
@axis.positions[0].should == position
|
51
|
+
@axis.positions[1].should == other_position
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
context "Serialization" do
|
57
|
+
let(:position1) do
|
58
|
+
Factory.build(:position, :ordinal => 0)
|
59
|
+
end
|
60
|
+
|
61
|
+
let(:position2) do
|
62
|
+
Factory.build(:position, :ordinal => 1)
|
63
|
+
end
|
64
|
+
|
65
|
+
let(:axis) do
|
66
|
+
Factory.build(:cell_set_axis, :positions => [position1, position2])
|
67
|
+
end
|
68
|
+
|
69
|
+
context "JSON" do
|
70
|
+
it "should serialize" do
|
71
|
+
axis.as_json.should == {
|
72
|
+
"axis_ordinal" => 0,
|
73
|
+
"positions" => [position1, position2]
|
74
|
+
}
|
75
|
+
end
|
76
|
+
|
77
|
+
it "should deserialize" do
|
78
|
+
::CellSet::CellSetAxis.new.from_json(axis.to_json).should == axis
|
79
|
+
end
|
80
|
+
|
81
|
+
it "should de-serialize frozen" do
|
82
|
+
::CellSet::CellSetAxis.new.from_json(axis.to_json).frozen?.should be_true
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
@@ -0,0 +1,160 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe CellSet::CellSet do
|
4
|
+
|
5
|
+
context "attributes" do
|
6
|
+
it { should have_accessor(:axes) }
|
7
|
+
|
8
|
+
context "axes" do
|
9
|
+
before(:each) do
|
10
|
+
@cell_set = Factory.build(:cell_set)
|
11
|
+
end
|
12
|
+
|
13
|
+
let(:column_axis) do
|
14
|
+
Factory.build(:cell_set_axis, :axis_ordinal => 0)
|
15
|
+
end
|
16
|
+
|
17
|
+
let(:row_axis) do
|
18
|
+
Factory.build(:cell_set_axis, :axis_ordinal => 1)
|
19
|
+
end
|
20
|
+
|
21
|
+
it "should accept an array of CellSetAxis" do
|
22
|
+
axes = [column_axis, row_axis]
|
23
|
+
lambda{@cell_set.axes = axes}.should_not raise_error
|
24
|
+
end
|
25
|
+
|
26
|
+
it "should not accept CellSetAxis or any other object" do
|
27
|
+
lambda{@cell_set.axes = column_axis}.should raise_error
|
28
|
+
end
|
29
|
+
|
30
|
+
it "should not accept an array with items that are not a CellSetAxis" do
|
31
|
+
axes = [column_axis, Object.new]
|
32
|
+
lambda{@cell_set.axes = axes}.should raise_error
|
33
|
+
end
|
34
|
+
|
35
|
+
it "should accept a Hash as would be assigned by CellSet#from_json" do
|
36
|
+
hsh = [
|
37
|
+
column_axis.as_json,
|
38
|
+
row_axis.as_json
|
39
|
+
]
|
40
|
+
lambda{@cell_set.axes = hsh}.should_not raise_error
|
41
|
+
@cell_set.axes[0].should == column_axis
|
42
|
+
@cell_set.axes[0].should_not == row_axis
|
43
|
+
@cell_set.axes[1].should == row_axis
|
44
|
+
@cell_set.axes[1].should_not == column_axis
|
45
|
+
end
|
46
|
+
|
47
|
+
it "should accept a Hash as would be assigned by CellSet#from_json and assign cell_set" do
|
48
|
+
hsh = [
|
49
|
+
column_axis.as_json,
|
50
|
+
row_axis.as_json
|
51
|
+
]
|
52
|
+
lambda{@cell_set.axes = hsh}.should_not raise_error
|
53
|
+
@cell_set.axes.each do |axis|
|
54
|
+
axis.cell_set.should == @cell_set
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
it "should accept an array of CellSetAxis and assign cell_set" do
|
59
|
+
axes = [column_axis, row_axis]
|
60
|
+
lambda{@cell_set.axes = axes}.should_not raise_error
|
61
|
+
@cell_set.axes.each do |axis|
|
62
|
+
axis.cell_set.should == @cell_set
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
context "initialize" do
|
68
|
+
let(:cell_set) do
|
69
|
+
Factory.build(:cell_set)
|
70
|
+
end
|
71
|
+
|
72
|
+
it "should set axes to an empty array" do
|
73
|
+
cell_set.instance_variable_get(:@axes).should == []
|
74
|
+
end
|
75
|
+
|
76
|
+
it "should set cellHash to empty hash" do
|
77
|
+
cell_set.instance_variable_get(:@cellHash).should == {}
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
context "Serialization" do
|
83
|
+
let(:column_position) do
|
84
|
+
Factory.build(:position, :ordinal => 0)
|
85
|
+
end
|
86
|
+
|
87
|
+
let(:row_position) do
|
88
|
+
Factory.build(:position, :ordinal => 1)
|
89
|
+
end
|
90
|
+
|
91
|
+
let(:column_axis) do
|
92
|
+
Factory.build(:cell_set_axis, :axis_ordinal => 0, :positions => [column_position])
|
93
|
+
end
|
94
|
+
|
95
|
+
let(:row_axis) do
|
96
|
+
Factory.build(:cell_set_axis, :axis_ordinal => 1, :positions => [row_position])
|
97
|
+
end
|
98
|
+
|
99
|
+
let(:cell_set) do
|
100
|
+
Factory.build(:cell_set, :axes => [column_axis, row_axis])
|
101
|
+
end
|
102
|
+
|
103
|
+
context "JSON" do
|
104
|
+
it "should serialize" do
|
105
|
+
cell_set.as_json.should == {
|
106
|
+
"cell_set" => {
|
107
|
+
"axes" => [column_axis, row_axis],
|
108
|
+
"cells" => {}
|
109
|
+
}
|
110
|
+
}
|
111
|
+
end
|
112
|
+
|
113
|
+
it "should serialize only cells" do
|
114
|
+
cell_set.as_json(:only => "cells").should == {
|
115
|
+
"cell_set" => {
|
116
|
+
"cells" => {}
|
117
|
+
}
|
118
|
+
}
|
119
|
+
end
|
120
|
+
|
121
|
+
it "should serialize excluding cells" do
|
122
|
+
cell_set.as_json(:except => "cells").should == {
|
123
|
+
"cell_set" => {
|
124
|
+
"axes" => [column_axis, row_axis]
|
125
|
+
}
|
126
|
+
}
|
127
|
+
end
|
128
|
+
|
129
|
+
it "should serialize only axes" do
|
130
|
+
cell_set.as_json(:only => "axes").should == {
|
131
|
+
"cell_set" => {
|
132
|
+
"axes" => [column_axis, row_axis]
|
133
|
+
}
|
134
|
+
}
|
135
|
+
end
|
136
|
+
|
137
|
+
it "should de-serialize" do
|
138
|
+
json = cell_set.to_json
|
139
|
+
::CellSet::CellSet.new.from_json(json).to_json.should == json
|
140
|
+
end
|
141
|
+
|
142
|
+
it "should de-serialize frozen" do
|
143
|
+
::CellSet::CellSet.new.from_json(cell_set.to_json).frozen?.should be_true
|
144
|
+
end
|
145
|
+
end
|
146
|
+
end
|
147
|
+
|
148
|
+
if RUBY_PLATFORM == "java"
|
149
|
+
#context "Mondrian::OLAP::Result" do
|
150
|
+
# it "should respond to to_cell_set" do
|
151
|
+
# Mondrian
|
152
|
+
# end
|
153
|
+
#end
|
154
|
+
|
155
|
+
context "Java::Mondrian::olap4j::MondrianOlap4jCellSet" do
|
156
|
+
|
157
|
+
end
|
158
|
+
end
|
159
|
+
|
160
|
+
end
|
@@ -0,0 +1,68 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe CellSet::Member do
|
4
|
+
|
5
|
+
context "attributes" do
|
6
|
+
it { should have_accessor(:caption) }
|
7
|
+
it { should have_accessor(:childMembers) }
|
8
|
+
it { should have_accessor(:depth) }
|
9
|
+
it { should have_accessor(:description) }
|
10
|
+
it { should have_accessor(:dimension) }
|
11
|
+
it { should have_accessor(:expression) }
|
12
|
+
it { should have_accessor(:hierarchy) }
|
13
|
+
it { should have_accessor(:level) }
|
14
|
+
it { should have_accessor(:memberType) }
|
15
|
+
it { should have_accessor(:name) }
|
16
|
+
it { should have_accessor(:ordinal) }
|
17
|
+
it { should have_accessor(:parentMember) }
|
18
|
+
it { should have_accessor(:uniqueName) }
|
19
|
+
|
20
|
+
context "initialize" do
|
21
|
+
before(:each) do
|
22
|
+
@member = Factory.build(:member)
|
23
|
+
end
|
24
|
+
|
25
|
+
it "should set childMembers to empty array" do
|
26
|
+
@member.instance_variable_get(:@childMembers).should == []
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
context "Serialization" do
|
32
|
+
let(:name) { "Member" }
|
33
|
+
|
34
|
+
let(:unique_name) { "[All].[Member]"}
|
35
|
+
|
36
|
+
let(:member) do
|
37
|
+
Factory.build(:member, :ordinal => 0, :name => name, :uniqueName => unique_name)
|
38
|
+
end
|
39
|
+
|
40
|
+
context "JSON" do
|
41
|
+
it "should serialize" do
|
42
|
+
member.as_json.should == {
|
43
|
+
"caption" => nil,
|
44
|
+
"childMembers" => [],
|
45
|
+
"depth" => nil,
|
46
|
+
"description" => nil,
|
47
|
+
"dimension" => nil,
|
48
|
+
"expression" => nil,
|
49
|
+
"hierarchy" => nil,
|
50
|
+
"level" => nil,
|
51
|
+
"memberType" => nil,
|
52
|
+
"name" => name,
|
53
|
+
"ordinal" => 0,
|
54
|
+
"parentMember" => nil,
|
55
|
+
"uniqueName" => unique_name
|
56
|
+
}
|
57
|
+
end
|
58
|
+
|
59
|
+
it "should deserialize" do
|
60
|
+
::CellSet::Member.new.from_json(member.to_json).should == member
|
61
|
+
end
|
62
|
+
|
63
|
+
it "should de-serialize frozen" do
|
64
|
+
::CellSet::Member.new.from_json(member.to_json).frozen?.should be_true
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
@@ -0,0 +1,109 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), "../../..", "spec_helper")
|
2
|
+
|
3
|
+
if RUBY_PLATFORM == "java"
|
4
|
+
require File.join(RSpec.configuration.fixture_path, 'postgresql-9.0-801.jdbc4.jar')
|
5
|
+
include_class 'mondrian.olap4j.MondrianOlap4jCellSet'
|
6
|
+
|
7
|
+
def foodmart_yaml
|
8
|
+
@yaml ||= YAML::load(File.open(File.join(RSpec.configuration.fixture_path, "database.yml")))["test"]
|
9
|
+
end
|
10
|
+
|
11
|
+
describe MondrianOlap4jCellSet do
|
12
|
+
it "responds to to_ruby" do
|
13
|
+
described_class.instance_methods.should include(:to_ruby)
|
14
|
+
end
|
15
|
+
|
16
|
+
context "to_ruby" do
|
17
|
+
let(:column_name) do
|
18
|
+
"Store Sales"
|
19
|
+
end
|
20
|
+
|
21
|
+
let(:column_unique_name) do
|
22
|
+
"[Measures].[Store Sales]"
|
23
|
+
end
|
24
|
+
|
25
|
+
let(:row_name) do
|
26
|
+
"All Products"
|
27
|
+
end
|
28
|
+
|
29
|
+
let(:row_unique_name) do
|
30
|
+
"[Product].[All Products]"
|
31
|
+
end
|
32
|
+
|
33
|
+
let(:cell_set) do
|
34
|
+
cons = Java::MondrianOlap4j::MondrianOlap4jDriver.java_class.declared_constructor
|
35
|
+
cons.accessible = true
|
36
|
+
driver = cons.new_instance.to_java
|
37
|
+
props = java.util.Properties.new
|
38
|
+
props.setProperty('JdbcUser', foodmart_yaml['username'])
|
39
|
+
props.setProperty('JdbcPassword', foodmart_yaml['password'])
|
40
|
+
conn_string = "jdbc:mondrian:Jdbc='jdbc:postgresql://#{foodmart_yaml['host']}/#{foodmart_yaml['database']}';JdbcDrivers=#{foodmart_yaml['jdbcDriver']};UseContentChecksum=true;Catalog=#{RSpec.configuration.fixture_path}/FoodMart.xml"
|
41
|
+
@raw_jdbc_connection = driver.connect(conn_string, props)
|
42
|
+
@raw_connection = @raw_jdbc_connection.unwrap(Java::OrgOlap4j::OlapConnection.java_class)
|
43
|
+
statement = @raw_connection.prepareOlapStatement("Select #{column_unique_name} ON COLUMNS, #{row_unique_name} ON ROWS from Sales")
|
44
|
+
cell_set = statement.executeQuery
|
45
|
+
cell_set.to_ruby
|
46
|
+
end
|
47
|
+
|
48
|
+
it "creates a cell_set" do
|
49
|
+
cell_set.should be_a(::CellSet::CellSet)
|
50
|
+
end
|
51
|
+
|
52
|
+
it "has 2 axes" do
|
53
|
+
cell_set.axes.length.should == 2
|
54
|
+
end
|
55
|
+
|
56
|
+
it "has 1 cell" do
|
57
|
+
cell_set.instance_variable_get(:@cellHash).keys.length.should == 1
|
58
|
+
end
|
59
|
+
|
60
|
+
it "has a cell with ordinal 0" do
|
61
|
+
cell_set.cell(0).value.should == 565238.13
|
62
|
+
end
|
63
|
+
|
64
|
+
context "column axis" do
|
65
|
+
let(:axis) do
|
66
|
+
cell_set.axes[0]
|
67
|
+
end
|
68
|
+
|
69
|
+
it "should have an axis ordinal 0" do
|
70
|
+
axis.axis_ordinal.should == 0
|
71
|
+
end
|
72
|
+
|
73
|
+
it "should have 1 position" do
|
74
|
+
axis.positions.length.should == 1
|
75
|
+
end
|
76
|
+
|
77
|
+
it "should have 1 member" do
|
78
|
+
axis.positions[0].members.length.should == 1
|
79
|
+
end
|
80
|
+
|
81
|
+
it "should have 1 member with uniqueName" do
|
82
|
+
axis.positions[0].members[0].uniqueName.should == column_unique_name
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
context "row axis" do
|
87
|
+
let(:axis) do
|
88
|
+
cell_set.axes[1]
|
89
|
+
end
|
90
|
+
|
91
|
+
it "should have an axis ordinal 0" do
|
92
|
+
axis.axis_ordinal.should == 1
|
93
|
+
end
|
94
|
+
|
95
|
+
it "should have 1 position" do
|
96
|
+
axis.positions.length.should == 1
|
97
|
+
end
|
98
|
+
|
99
|
+
it "should have 1 member" do
|
100
|
+
axis.positions[0].members.length.should == 1
|
101
|
+
end
|
102
|
+
|
103
|
+
it "should have 1 member with uniqueName" do
|
104
|
+
axis.positions[0].members[0].uniqueName.should == row_unique_name
|
105
|
+
end
|
106
|
+
end
|
107
|
+
end
|
108
|
+
end
|
109
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
if RUBY_PLATFORM == "java"
|
4
|
+
describe Mondrian::OLAP::Result do
|
5
|
+
it "responds to to_cell_set" do
|
6
|
+
described_class.new(nil, nil).should respond_to(:to_cell_set)
|
7
|
+
end
|
8
|
+
|
9
|
+
context "to_cell_set" do
|
10
|
+
it "returns to_ruby of @raw_cell_set" do
|
11
|
+
raw_cell_set = mock("RawCellSet")
|
12
|
+
raw_cell_set.should_receive(:to_ruby)
|
13
|
+
described_class.new(nil, raw_cell_set).to_cell_set
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,83 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe CellSet::Position do
|
4
|
+
|
5
|
+
context "attributes" do
|
6
|
+
it { should have_accessor(:members) }
|
7
|
+
it { should have_accessor(:ordinal) }
|
8
|
+
|
9
|
+
context "initialize" do
|
10
|
+
before(:each) do
|
11
|
+
@position = Factory.build(:position)
|
12
|
+
end
|
13
|
+
|
14
|
+
it "should set members to empty array" do
|
15
|
+
@position.instance_variable_get(:@members).should == []
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
context "members" do
|
20
|
+
before(:each) do
|
21
|
+
@position = Factory.build(:position)
|
22
|
+
end
|
23
|
+
|
24
|
+
let(:member) do
|
25
|
+
Factory.build(:member, :ordinal => 0)
|
26
|
+
end
|
27
|
+
|
28
|
+
it "should accept an array of Members" do
|
29
|
+
lambda{@position.members = [member]}.should_not raise_error
|
30
|
+
end
|
31
|
+
|
32
|
+
it "should not accept Member or any other object" do
|
33
|
+
lambda{@position.members = member}.should raise_error
|
34
|
+
end
|
35
|
+
|
36
|
+
it "should not accept an array with items that are not a Member" do
|
37
|
+
lambda{@position.members = [member, Object.new]}.should raise_error
|
38
|
+
end
|
39
|
+
|
40
|
+
it "should accept a Hash as would be assigned by Position#from_json" do
|
41
|
+
other_member = Factory.build(:member, :ordinal => 1)
|
42
|
+
hsh = [
|
43
|
+
member.as_json,
|
44
|
+
other_member.as_json
|
45
|
+
]
|
46
|
+
lambda{@position.members = hsh}.should_not raise_error
|
47
|
+
@position.members[0].should == member
|
48
|
+
@position.members[1].should == other_member
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
context "Serialization" do
|
54
|
+
let(:member1) do
|
55
|
+
Factory.build(:member, :ordinal => 0)
|
56
|
+
end
|
57
|
+
|
58
|
+
let(:member2) do
|
59
|
+
Factory.build(:member, :ordinal => 1)
|
60
|
+
end
|
61
|
+
|
62
|
+
let(:position) do
|
63
|
+
Factory.build(:position, :members => [member1, member2])
|
64
|
+
end
|
65
|
+
|
66
|
+
context "JSON" do
|
67
|
+
it "should serialize" do
|
68
|
+
position.as_json.should == {
|
69
|
+
"ordinal" => 0,
|
70
|
+
"members" => [member1, member2]
|
71
|
+
}
|
72
|
+
end
|
73
|
+
|
74
|
+
it "should deserialize" do
|
75
|
+
::CellSet::Position.new.from_json(position.to_json).should == position
|
76
|
+
end
|
77
|
+
|
78
|
+
it "should de-serialize frozen" do
|
79
|
+
::CellSet::Position.new.from_json(position.to_json).frozen?.should be_true
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
# This file was generated by the `rspec --init` command. Conventionally, all
|
2
|
+
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
|
3
|
+
# Require this file using `require "spec_helper.rb"` to ensure that it is only
|
4
|
+
# loaded once.
|
5
|
+
#
|
6
|
+
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
|
7
|
+
require 'rubygems'
|
8
|
+
require 'bundler/setup'
|
9
|
+
|
10
|
+
Bundler.require :default, :development
|
11
|
+
|
12
|
+
require 'active_model'
|
13
|
+
require 'cell_set'
|
14
|
+
require 'factory_girl'
|
15
|
+
require 'java' if RUBY_PLATFORM == "java"
|
16
|
+
|
17
|
+
RSpec.configure do |config|
|
18
|
+
config.treat_symbols_as_metadata_keys_with_true_values = true
|
19
|
+
config.run_all_when_everything_filtered = true
|
20
|
+
config.filter_run :focus
|
21
|
+
config.add_setting :fixture_path, :default => File.join(File.dirname(__FILE__), "fixtures")
|
22
|
+
config.before(:suite) do
|
23
|
+
Dir[File.join(File.dirname(__FILE__), '/support/**/*.rb')].each { |f| require f }
|
24
|
+
Dir[File.join(File.dirname(__FILE__), '/factories/*.rb')].each { |f| require f }
|
25
|
+
end
|
26
|
+
end
|