diff --git a/spec/controllers/modules_controller_spec.rb b/spec/controllers/modules_controller_spec.rb index eec4e10..81607f0 100644 --- a/spec/controllers/modules_controller_spec.rb +++ b/spec/controllers/modules_controller_spec.rb @@ -14,22 +14,21 @@ describe ModulesController do end describe "metric_history" do - + let (:module_id){ 1 } + let (:metric_name ){ FactoryGirl.build(:loc).name } + let (:date ){ "2011-10-20T18:26:43.151+00:00" } + let (:metric_result){ FactoryGirl.build(:metric_result) } + let (:module_result){ FactoryGirl.build(:module_result) } before :each do - @module_id = 1 - @date = "2011-10-20T18:26:43.151+00:00" - @metric_name = FactoryGirl.build(:loc).name - @metric_result = FactoryGirl.build(:metric_result) - - @module_result = FactoryGirl.build(:module_result) - ModuleResult.expects(:new).at_least_once.with({id: @module_result.id.to_s}).returns(@module_result) - @module_result.expects(:metric_history).with(@metric_name).returns({@date => @metric_result.value}) + module_result #TODO discovery why this line is fundamental, without this line the test generates a nil object for module_result + ModuleResult.expects(:new).at_least_once.with({id: module_result.id.to_s}).returns(module_result) + module_result.expects(:metric_history).with(metric_name).returns({date => metric_result.value}) end context "testing existence of the image in the response" do it "should return an image" do - get :metric_history, id: @module_result.id, metric_name: @metric_name, module_id: @module_id + get :metric_history, id: module_result.id, metric_name: metric_name, module_id: module_id response.content_type.should eq "image/png" end end @@ -42,9 +41,9 @@ describe ModulesController do end it "should return two arrays, one of dates and other of values" do - get :metric_history, id: @module_result.id, metric_name: @metric_name, module_id: @module_id - @graphic.maximum_value.should eq @metric_result.value - @graphic.labels.first[1].should eq @date + get :metric_history, id: module_result.id, metric_name: metric_name, module_id: module_id + @graphic.maximum_value.should eq metric_result.value + @graphic.labels.first[1].should eq date end end -- libgit2 0.21.2