Class: RSpec::RailsApp::Content::Matchers::HaveGems
- Inherits:
-
Object
- Object
- RSpec::RailsApp::Content::Matchers::HaveGems
- Extended by:
- RailsAssist::UseMacro
- Includes:
- RailsAssist::File::Special
- Defined in:
- lib/rails_app_spec/matchers/special/have_gems.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#names ⇒ Object
readonly
Returns the value of attribute names.
Instance Method Summary collapse
- #failure_message ⇒ Object
-
#initialize(*names) ⇒ HaveGems
constructor
A new instance of HaveGems.
-
#matches?(root_path = nil) ⇒ Boolean
TODO: relative to root_path ?.
- #msg ⇒ Object
- #name_expr(gem_name) ⇒ Object
- #negative_failure_message ⇒ Object
- #version_txt ⇒ Object
Constructor Details
#initialize(*names) ⇒ HaveGems
Returns a new instance of HaveGems.
17 18 19 |
# File 'lib/rails_app_spec/matchers/special/have_gems.rb', line 17 def initialize *names @names = names.to_strings end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
15 16 17 |
# File 'lib/rails_app_spec/matchers/special/have_gems.rb', line 15 def name @name end |
#names ⇒ Object (readonly)
Returns the value of attribute names.
15 16 17 |
# File 'lib/rails_app_spec/matchers/special/have_gems.rb', line 15 def names @names end |
Instance Method Details
#failure_message ⇒ Object
43 44 45 |
# File 'lib/rails_app_spec/matchers/special/have_gems.rb', line 43 def "Expected #{msg}" end |
#matches?(root_path = nil) ⇒ Boolean
TODO: relative to root_path ?
22 23 24 25 26 27 28 |
# File 'lib/rails_app_spec/matchers/special/have_gems.rb', line 22 def matches?(root_path=nil) content = read_gem_file return nil if content.empty? names.each do |name| (content =~ /gem\s+#{name_expr(name)}/) end end |
#msg ⇒ Object
35 36 37 |
# File 'lib/rails_app_spec/matchers/special/have_gems.rb', line 35 def msg "the Gemfile to have a gem statement: gem '#{name}'" end |
#name_expr(gem_name) ⇒ Object
30 31 32 33 |
# File 'lib/rails_app_spec/matchers/special/have_gems.rb', line 30 def name_expr gem_name @name = gem_name "('|\")" + gem_name + '\1' end |
#negative_failure_message ⇒ Object
47 48 49 |
# File 'lib/rails_app_spec/matchers/special/have_gems.rb', line 47 def "Did not expect #{msg}" end |
#version_txt ⇒ Object
39 40 41 |
# File 'lib/rails_app_spec/matchers/special/have_gems.rb', line 39 def version_txt version ? ", '#{version}'" : "" end |