Sha256: 65aa92e3cd6c69441b53400d11772847b46f2da801ffbab9f084fcaadfe2ca92
Contents?: true
Size: 1.23 KB
Versions: 1
Compression:
Stored size: 1.23 KB
Contents
# open application_file # see if there is the config.[statement] = [expr] module RSpec::Rails::ContentMatchers class HaveAppConfig use_rails_file_helpers :special # TODO !!! attr_reader :left_side, :right_side, :operator def initialize statement_hash @left_side, @right_side = *statement.first @operator = statement.last[:op] || '=' end # TODO: relative to root_path ? def matches?(root_path=nil) content = read_application_file return nil if content.empty? ls, rs, op = escape_all(left_side, right_side, operator) (content =~ /config.#{ls}\s*#{op}\s*#{rs}/) end def escape_all *texts texts.map{|t| Regexp.escape(t) } end def msg "there to be the Application config statement '#{left_side} #{operator} #{right_side}' in config/application.rb" end def failure_message "Expected #{msg}" end def negative_failure_message super "Did not expect #{msg}" end end # config.autoload_paths += %W(#{Rails.root}/lib) # have_app_config :autoload_paths => '%W(#{Rails.root}/lib)', :op => '+=' def have_app_config statement_hash HaveAppConfig.new statement_hash end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
rails3_assist-0.2.5 | lib/rails3_assist/rspec/matchers/have_app_config.rb |