Skip to content

Commit

Permalink
Cleanup ConversionTable spec
Browse files Browse the repository at this point in the history
  • Loading branch information
halogenandtoast committed Feb 1, 2014
1 parent 573564d commit add97c6
Showing 1 changed file with 6 additions and 20 deletions.
26 changes: 6 additions & 20 deletions spec/conversion_table_spec.rb
Expand Up @@ -2,27 +2,17 @@

module Alchemist
describe ConversionTable do
after(:each) do
load_file default_file
end

it "should use the new file" do
load_file good_file
expect(conversion_table[:volume]).to eq({ litre: 1.0, swallow: 0.006, pint: 0.5506105 })
end

it "should use the defaults when it fails to load" do
load_file bad_file
expect(5280.feet).to eq(1.mile.to.feet)
it "loads a properly formed file" do
conversion_table = ConversionTable.new
expect(conversion_table.load_all(good_file)).not_to be_nil
end

def conversion_table
Alchemist.library.conversion_table
it "fails to load a improperly formed file" do
conversion_table = ConversionTable.new
expect(conversion_table.load_all(bad_file)).to be_nil
end

def load_file file
Alchemist.library.load_conversion_table file
end

def good_file
File.join(File.dirname(__FILE__), "fixtures", "good_test.yml")
Expand All @@ -31,9 +21,5 @@ def good_file
def bad_file
File.join(File.dirname(__FILE__), "fixtures", "bad_test.yml")
end

def default_file
Configuration::DEFAULT_UNITS_FILE
end
end
end

0 comments on commit add97c6

Please sign in to comment.