File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1515require "buff/datastructure"
1616require "buff/info"
1717require "buff/client"
18+ require "buff/setup"
1819
1920module Buff
2021end
Original file line number Diff line number Diff line change 11module Buff
2+ #TODO: refactor errors into Error Module and fix references
23 InvalidIdLength = Class . new ( ArgumentError )
34 InvalidIdContent = Class . new ( ArgumentError )
45 MissingStatus = Class . new ( ArgumentError )
56 APIError = Class . new ( StandardError )
67 UnauthorizeRequest = Class . new ( StandardError )
8+
9+ module Error
10+ ConfigFileMissing = Class . new ( StandardError )
11+ end
712end
Original file line number Diff line number Diff line change 1+ module Buff
2+ RC_VERSION = "0.0.1"
3+ class Setup
4+
5+ def initialize ( args = "~/.bufferapprc" )
6+ @path = Pathname . new ( args )
7+ if exists?
8+ @content = YAML . load_file ( File . expand_path path )
9+ else
10+ raise Buff ::Error ::ConfigFileMissing
11+ end
12+ end
13+
14+ def path
15+ @path . to_s
16+ end
17+
18+ def exists?
19+ File . exists? ( File . expand_path path )
20+ end
21+
22+ end
23+ end
Original file line number Diff line number Diff line change 1+ require "spec_helper"
2+
3+ describe Buff ::Setup do
4+
5+ let ( :bad_config_setup ) { Buff ::Setup . new "~/notpresentexample" }
6+ let ( :setup ) { Buff ::Setup . new }
7+
8+ context "pathname" do
9+ it "sets the default path" do
10+ expect ( setup . path ) . to eq ( "~/.bufferapprc" )
11+ end
12+ it "fails with error when specified file not found" do
13+ lambda { bad_config_setup . path } . should
14+ raise_error ( Buff ::Error ::ConfigFileMissing )
15+ end
16+ end
17+ context "verifies whether rc file exists" do
18+ it "documents when rc file not present" do
19+ expect ( bad_config_setup . exists? ) . to eq ( false )
20+ end
21+ it "documents when rc file is present" do
22+ expect ( setup . exists? ) . to eq ( true )
23+ end
24+ end
25+ context "determines if rc file is the most current version" do
26+ it "checks current RC_VERSION" do
27+ expect ( Buff ::RC_VERSION ) . to_not eq ( nil )
28+ end
29+
30+ it "reports error when file is out of date" do
31+ end
32+ it "returns true when current"
33+ end
34+ context "when rc file is current"
35+ it "exits without altering state"
36+ context "when rc file is not present"
37+ it "verifies that rc file doesn't exist"
38+ it "creates an rc file and prompts for authorization"
39+
40+ context "when rc file is out of date"
41+ end
You can’t perform that action at this time.
0 commit comments