ruby on rails - NameError: undefined local variable or method `logger' -
when run 'script/server' works fine, when run unit tests (rake test:units
), error below, , not sure how solve this.
error
nameerror: undefined local variable or method `logger' #<giveawayeligiblemembertest:0x10477dff8> /users/kamilski81/sites/pe/vitality_mall/vendor/rails/actionpack/lib/action_controller/test_process.rb:471:in `method_missing' /users/kamilski81/sites/pe/vitality_mall/lib/update_giveaway_eligible_members.rb:17:in `is_valid_checksum?' /users/kamilski81/sites/pe/vitality_mall/test/unit/giveaway_eligible_member_test.rb:26:in `test_that_checksum_is_valid' /users/kamilski81/sites/pe/vitality_mall/vendor/rails/activesupport/lib/active_support/testing/setup_and_teardown.rb:60:in `__send__' /users/kamilski81/sites/pe/vitality_mall/vendor/rails/activesupport/lib/active_support/testing/setup_and_teardown.rb:60:in `run'
i tried putting:
class test::unit::testcase rails_default_logger = logger.new(stdout) rails_default_logger.level = logger::warn logger = logger.new(stdout) logger.level = logger::warn end
here code using logger:
def is_valid_checksum?(csv_arr) expected_row_count = csv_arr[0][3].to_i logger.debug "expected record count: #{expected_row_count}" actual_row_count = csv_arr.nitems - 1 logger.debug "actual record count: #{actual_row_count}" checksum_valid = false if expected_row_count == actual_row_count logger.debug "checksum valid" checksum_valid = true end return checksum_valid end
but still not solve error
Comments
Post a Comment