Sha256: 05f63f084c4cce167d5c5752a00b5fd8fdd16af919c00e296ba03987da7e83c1
Contents?: true
Size: 1.43 KB
Versions: 4
Compression:
Stored size: 1.43 KB
Contents
require "spec_helper" require_relative "../lib/Standupguy" include Standupguy::DataMethods describe Standupguy::DataMethods do describe "#date_key" do it "returns the current date formatted string when give :today" do expect(date_key(:today)).to be_a_kind_of(String) expect(date_key(:today)).to match(/\d{4}-\d{2}-\d{2}/) expect(date_key(:today)).to eq(DateTime.now.strftime("%Y-%m-%d")) end it "returns the date formatted sting when given same" do expect(date_key("2014-10-10")).to be_a_kind_of(String) expect(date_key("2014-10-10")).to match(/\d{4}-\d{2}-\d{2}/) expect(date_key("2014-10-10")).to eq("2014-10-10") end it "returns today when given a non date formatted string" do expect(date_key("foo")).to eq(DateTime.now.strftime("%Y-%m-%d")) end end describe "#filename" do it do result = File.join(Standupguy::Core::DATA_ROOT, "standup.json") expect(filename).to eq(result) end end describe "#load_data" do before do @file = Tempfile.new("foo") stubs(filename: @file.path) end it "reads an existing file" do File.write(@file, '{"foo": "bar"}') expect(load_data).to eq({"foo" => "bar"}) end it "writes the current standup" do write_data({"foo" => "bar"}) expect(File.read(@file)).to eq('{"foo":"bar"}') File.delete(@file) end after do @file.close @file.unlink end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
Standupguy-0.0.10 | spec/data_methods_spec.rb |
Standupguy-0.0.9 | spec/data_methods_spec.rb |
Standupguy-0.0.8 | spec/data_methods_spec.rb |
Standupguy-0.0.6 | spec/data_methods_spec.rb |