This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Defines the matching rules for Guard. | |
guard :minitest, spring: true, all_on_start: false do | |
watch(%r{^test/(.*)/?(.*)_test\.rb$}) | |
watch('test/test_helper.rb') { 'test' } | |
watch('config/routes.rb') { integration_tests } | |
watch(%r{^app/models/(.*?)\.rb$}) do |matches| | |
"test/models/#{matches[1]}_test.rb" | |
end | |
watch(%r{^app/controllers/(.*?)_controller\.rb$}) do |matches| | |
resource_tests(matches[1]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ENV['RAILS_ENV'] ||= 'test' | |
require File.expand_path('../../config/environment', __FILE__) | |
require 'rails/test_help' | |
require "minitest/reporters" | |
Minitest::Reporters.use! | |
class ActiveSupport::TestCase | |
# Setup all fixtures in test/fixtures/*.yml for all tests in alphabetical order. | |
fixtures :all |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "json" | |
def temp() | |
number = Dir.glob('/sys/bus/w1/devices/*').count-1 | |
if number>0 | |
@temperatures = Array.new | |
Dir.glob('/sys/bus/w1/devices/*').each_with_index {|folder, index| | |
values = Hash.new | |
foldername = folder.gsub('/sys/bus/w1/devices/','') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Message.joins(:department_targets).joins(:user).where("department_targets.department_id = ? OR users.department_id = ?", department_id, department_id) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
MessagesController /action /create | |
def create | |
message = current_user.messages.build(params[:message]) | |
message.created_at = Time.now # HACK | |
message.save! | |
respond_with(@messages, :location => messages_url) | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#acho que da pra fazer assim, veja se funciona. | |
class RandomPasswords | |
def generate(size = 8) | |
chars = ('a'..'z').to_a + ('A'..'Z').to_a + ('1'..'9').to_a | |
(1..size).collect {|c| chars[ rand(chars.size) ]}.join | |
end | |
end | |
#nesse caso uma senha com 8 caracteres, se precisar ser maior ou menor mude o parâmetro ... dohhhh! |
NewerOlder