Skip to content
This repository has been archived by the owner on Jan 10, 2023. It is now read-only.

Commit

Permalink
Added name option to plan
Browse files Browse the repository at this point in the history
  • Loading branch information
Kyle Dayton committed Aug 25, 2013
1 parent 1ff5d84 commit f660d4c
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
11 changes: 11 additions & 0 deletions lib/planify/plan.rb
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,17 @@ def price(*args)
@price ||= 0.00
end

# Sets or returns the name of this plan
# When called without arguments, it returns the name
# When called with arguments, the name is set to the first argument provided
def name(*args)
unless args.empty?
@name = args.first
end

@name ||= nil
end

# Sets or returns the description of this plan
# When called without arguments, it returns the description
# When called with arguments, the description is set to the first argument provided.
Expand Down
24 changes: 24 additions & 0 deletions spec/planify/plan_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,30 @@
end
end

describe ".name" do
context "with arguments" do
it "sets the plan name" do
subject.name "Starter Plan"

subject.name.should == "Starter Plan"
end
end

context "without arguments" do
before { subject.name("Premium Plan") }

it "returns the plan name" do
subject.name.should == "Premium Plan"
end
end

context "when no name is set" do
it "returns nil" do
Planify::Plan.new.name.should be_nil
end
end
end

describe ".merge!" do

let(:pro_plan) do
Expand Down

0 comments on commit f660d4c

Please sign in to comment.