spec/file/definitions_spec.rb in fit_parser-0.0.4 vs spec/file/definitions_spec.rb in fit_parser-0.0.5
- old
+ new
@@ -4,23 +4,23 @@
# with already defined fields in definitions.rb and test are
# not really independant of the code
describe FitParser::File::Definitions do
describe ".add_field" do
before :all do
- @fields = described_class.class_variable_get :@@fields
- @dyn_fields = described_class.class_variable_get :@@dyn_fields
+ @fields = described_class.fields
+ @dyn_fields = described_class.dyn_fields
end
after :all do
- FitParser::File::Definitions.class_variable_set(:@@fields, @fields)
- FitParser::File::Definitions.class_variable_set(:@@dyn_fields, @dyn_fields)
+ FitParser::File::Definitions.fields = @fields
+ FitParser::File::Definitions.dyn_fields = @dyn_fields
end
context "without additional options" do
before :each do
- FitParser::File::Definitions.class_variable_set(:@@fields, Hash.new { |h,k| h[k]={} })
- FitParser::File::Definitions.class_variable_set(:@@dyn_fields, Hash.new { |h,k| h[k]={} })
+ FitParser::File::Definitions.fields = Hash.new { |h,k| h[k]={} }
+ FitParser::File::Definitions.dyn_fields = Hash.new { |h,k| h[k]={} }
described_class.add_field(999, 999, 'rspec_test')
end
it "adds field data" do
expect(described_class.get_field(999,999)).to be_a(Hash)
@@ -32,13 +32,12 @@
end
end
context "with additional options" do
before :each do
- FitParser::File::Definitions.class_variable_set(:@@fields, Hash.new { |h,k| h[k]={} })
- FitParser::File::Definitions.class_variable_set(:@@dyn_fields, Hash.new { |h,k| h[k]={} })
-
+ FitParser::File::Definitions.fields = Hash.new { |h,k| h[k]={} }
+ FitParser::File::Definitions.dyn_fields = Hash.new { |h,k| h[k]={} }
described_class.add_field(999, 999, 'rspec_test', :scale => 100, :units => 'm')
described_class.add_field(999, 999, 'rspec_test_dyn', :type => 4, :scale => 10, :offset => 10, :ref_field_name => nil, :ref_field_values => nil)
end
it "adds field data" do
@@ -53,10 +52,10 @@
end
end
describe ".get_field" do
it "returns nil if no field exists" do
- expect(described_class.get_field(100,100)).to be_nil
+ expect(described_class.get_field(100,101)).to be_nil
end
end
describe '.get_dynamic_field' do
it 'returns nil if no dynamic field exists' do