Class: RSpec::RailsApp::Content::Matchers::HaveAppConfig
- Inherits:
-
Object
- Object
- RSpec::RailsApp::Content::Matchers::HaveAppConfig
- Extended by:
- RailsAssist::UseMacro
- Includes:
- RailsAssist::File::Application, RailsAssist::File::Special
- Defined in:
- lib/rails_app_spec/matchers/special/have_app_config.rb
Instance Attribute Summary collapse
-
#left_side ⇒ Object
readonly
Returns the value of attribute left_side.
-
#operator ⇒ Object
readonly
Returns the value of attribute operator.
-
#right_side ⇒ Object
readonly
Returns the value of attribute right_side.
Instance Method Summary collapse
- #escape_all(*texts) ⇒ Object
- #failure_message ⇒ Object
-
#initialize(args) ⇒ HaveAppConfig
constructor
A new instance of HaveAppConfig.
-
#matches?(root_path = nil) ⇒ Boolean
TODO: relative to root_path ?.
- #msg ⇒ Object
- #negative_failure_message ⇒ Object
Constructor Details
#initialize(args) ⇒ HaveAppConfig
Returns a new instance of HaveAppConfig.
15 16 17 18 |
# File 'lib/rails_app_spec/matchers/special/have_app_config.rb', line 15 def initialize args @left_side, @right_side = *args.first @operator = last_arg_value({:op => '='}, args) end |
Instance Attribute Details
#left_side ⇒ Object (readonly)
Returns the value of attribute left_side.
13 14 15 |
# File 'lib/rails_app_spec/matchers/special/have_app_config.rb', line 13 def left_side @left_side end |
#operator ⇒ Object (readonly)
Returns the value of attribute operator.
13 14 15 |
# File 'lib/rails_app_spec/matchers/special/have_app_config.rb', line 13 def operator @operator end |
#right_side ⇒ Object (readonly)
Returns the value of attribute right_side.
13 14 15 |
# File 'lib/rails_app_spec/matchers/special/have_app_config.rb', line 13 def right_side @right_side end |
Instance Method Details
#escape_all(*texts) ⇒ Object
28 29 30 |
# File 'lib/rails_app_spec/matchers/special/have_app_config.rb', line 28 def escape_all *texts texts.map{|t| Regexp.escape(t) } end |
#failure_message ⇒ Object
36 37 38 |
# File 'lib/rails_app_spec/matchers/special/have_app_config.rb', line 36 def "Expected #{msg}" end |
#matches?(root_path = nil) ⇒ Boolean
TODO: relative to root_path ?
21 22 23 24 25 26 |
# File 'lib/rails_app_spec/matchers/special/have_app_config.rb', line 21 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 |
#msg ⇒ Object
32 33 34 |
# File 'lib/rails_app_spec/matchers/special/have_app_config.rb', line 32 def msg "there to be the Application config statement '#{left_side} #{operator} #{right_side}' in config/application.rb" end |
#negative_failure_message ⇒ Object
40 41 42 43 |
# File 'lib/rails_app_spec/matchers/special/have_app_config.rb', line 40 def super "Did not expect #{msg}" end |