test/unit/garb/management/goal_test.rb in garb-0.9.1 vs test/unit/garb/management/goal_test.rb in garb-0.9.7

- old
+ new

@@ -6,16 +6,16 @@ context "the Goal class" do should "turn entries for path into array of goals" do feed = stub(:entries => ["entry1"]) Feed.stubs(:new).returns(feed) - Goal.stubs(:new_from_entry) + Goal.stubs(:new) Goal.all assert_received(Feed, :new) {|e| e.with(Session, '/accounts/~all/webproperties/~all/profiles/~all/goals')} assert_received(feed, :entries) - assert_received(Goal, :new_from_entry) {|e| e.with("entry1", Session)} + assert_received(Goal, :new) {|e| e.with("entry1", Session)} end should "find all goals for a given account" do Goal.stubs(:all) Goal.for_account(stub(:session => 'session', :path => '/accounts/123')) @@ -35,41 +35,27 @@ end end context "a Goal" do setup do - entry = { - "link" => [{"rel" => "self", "href" => Feed::BASE_URL+"/accounts/1189765/webproperties/UA-1189765-1/profiles/98765"}], - "ga:goal" => { - "ga:destination"=>{"caseSensitive"=>"false","expression"=>"/blog.html","matchType"=>"head"}, - "active"=>"true", - "name"=>"Read Blog", - "number"=>"1", - "value"=>"10.0" - } - } - - @goal = Goal.new_from_entry(entry, Session) + entry = MultiJson.load(read_fixture("goal_management.json"))["items"].first + @goal = Goal.new(entry, Session) end should "have a name" do - assert_equal "Read Blog", @goal.name + assert_equal "the goal", @goal.name end - should "have a number" do - assert_equal 1, @goal.number - end - should "have a value" do - assert_equal 10.0, @goal.value + assert_equal 1.0, @goal.value end should "know if it is active" do assert_equal true, @goal.active? end should "know if it is not active" do - @goal.active = false + @goal.instance_variable_set("@active", false) assert_equal false, @goal.active? end should "have a destination" do assert_equal true, @goal.destination.is_a?(Destination)