sunnytrail 0.0.1.2 → 0.0.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/lib/sunnytrail.rb CHANGED
@@ -76,6 +76,8 @@ class Sunnytrail
76
76
  end
77
77
 
78
78
  class Event < Hashie::Dash
79
+
80
+ attr_writer :action, :plan
79
81
 
80
82
  property :id
81
83
  property :name
@@ -91,8 +93,8 @@ class Sunnytrail
91
93
 
92
94
  def to_hash
93
95
  out = {}
94
- out[:action] = @action.to_hash if @action
95
- out[:plan] = @plan.to_hash if @plan
96
+ out[:action] = @action.nil? ? {} : @action.to_hash
97
+ out[:plan] = @plan.nil? ? {} : @plan.to_hash
96
98
  keys.each do |k|
97
99
  out[k] = Hashie::Hash === self[k] ? self[k].to_hash : self[k]
98
100
  end
@@ -63,6 +63,26 @@ describe Sunnytrail do
63
63
  event.to_hash.should == OPTIONS_HASH
64
64
  event.to_json.should == OPTIONS_HASH.to_json
65
65
  end
66
+
67
+ it "should set up and clear action and plan attributes properly" do
68
+ event = Sunnytrail::Event.new
69
+ event.action.name = "signup"
70
+ event.plan.name = "Basic"
71
+ event.action.name.should == "signup"
72
+ event.plan.name.should == "Basic"
73
+ event.action = nil
74
+ event.plan = nil
75
+ event.action.name.should be_nil
76
+ event.plan.name.should be_nil
77
+ end
78
+
79
+ it "should add empty plan and action node to hash when they are not specified" do
80
+ event = Sunnytrail::Event.new
81
+ hash = event.to_hash
82
+ hash[:action].should == {}
83
+ hash[:plan].should == {}
84
+ end
66
85
  end
67
86
 
87
+
68
88
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sunnytrail
3
3
  version: !ruby/object:Gem::Version
4
- hash: 79
4
+ hash: 77
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
9
  - 1
10
- - 2
11
- version: 0.0.1.2
10
+ - 3
11
+ version: 0.0.1.3
12
12
  platform: ruby
13
13
  authors:
14
14
  - Mateusz Zawisza