rails-app-spec 0.2.3 → 0.2.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/README.markdown CHANGED
@@ -8,7 +8,7 @@ RSpec 2 matchers to spec the structure of your Rails 3 app
8
8
 
9
9
  ## Usage
10
10
 
11
- See specs for details on the API.
11
+ See specs for more details on how to use the API.
12
12
 
13
13
  Usage example (teaser):
14
14
  <pre>
@@ -27,6 +27,8 @@ Usage example (teaser):
27
27
  end
28
28
  </pre>
29
29
 
30
+ This library takes advantage of *code-spec*, *file-spec* and other essential spec extensions I have created ;)
31
+
30
32
  ## Note on Patches/Pull Requests
31
33
 
32
34
  * Fork the project.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.3
1
+ 0.2.4
@@ -12,6 +12,7 @@ require_all File.dirname(__FILE__) + '/rails_app_spec/matchers'
12
12
  RSpec.configure do |config|
13
13
  config.include RSpec::RailsApp::File::Matchers
14
14
  config.include RSpec::RailsApp::Dir::Matchers
15
+ config.include RSpec::RailsApp::Content::Matchers
15
16
  config.include RSpec::RailsApp::Artifact::Matchers
16
17
  config.include RSpec::RailsApp::ArtifactClass::Matchers
17
18
  config.include RSpec::RailsApp::ArtifactFile::Matchers
@@ -3,12 +3,12 @@ module RSpec::RailsApp::ArtifactClass
3
3
  class HaveArtifactSubclass < RSpec::RubyContentMatchers::HaveSubclass
4
4
  def failure_message
5
5
  super
6
- "Expected the code to have a #{postfix} subclass called #{name}"
6
+ "Expected the code to have a #{superclass} subclass called #{full_class}"
7
7
  end
8
8
 
9
9
  def negative_failure_message
10
10
  super
11
- "Did not expect he code to have a #{type} subclass called #{name}"
11
+ "Did not expect he code to have a #{superclass} subclass called #{full_class}"
12
12
  end
13
13
  end
14
14
 
@@ -0,0 +1,50 @@
1
+ # open application_file
2
+ # see if there is the config.[statement] = [expr]
3
+
4
+ module RSpec::RailsApp::Content
5
+ module Matchers
6
+ class HaveAppConfig
7
+ extend Rails3::Assist::UseMacro
8
+ use_helpers :file
9
+
10
+ attr_reader :left_side, :right_side, :operator
11
+
12
+ def initialize statement_hash
13
+ @left_side, @right_side = *statement.first
14
+ @operator = statement.last[:op] || '='
15
+ end
16
+
17
+ # TODO: relative to root_path ?
18
+ def matches?(root_path=nil)
19
+ content = read_application_file
20
+ return nil if content.empty?
21
+
22
+ ls, rs, op = escape_all(left_side, right_side, operator)
23
+ (content =~ /config.#{ls}\s*#{op}\s*#{rs}/)
24
+ end
25
+
26
+ def escape_all *texts
27
+ texts.map{|t| Regexp.escape(t) }
28
+ end
29
+
30
+ def msg
31
+ "there to be the Application config statement '#{left_side} #{operator} #{right_side}' in config/application.rb"
32
+ end
33
+
34
+ def failure_message
35
+ "Expected #{msg}"
36
+ end
37
+
38
+ def negative_failure_message
39
+ super
40
+ "Did not expect #{msg}"
41
+ end
42
+ end
43
+
44
+ # config.autoload_paths += %W(#{Rails.root}/lib)
45
+ # have_app_config :autoload_paths => '%W(#{Rails.root}/lib)', :op => '+='
46
+ def have_app_config statement_hash
47
+ HaveAppConfig.new statement_hash
48
+ end
49
+ end
50
+ end
@@ -1,5 +1,5 @@
1
1
  module RSpec
2
2
  module RailsApp
3
- modules :artifact, :artifact_class, :artifact_file, :file, :dir
3
+ modules :artifact, :artifact_class, :artifact_file, :file, :dir, :content
4
4
  end
5
5
  end
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{rails-app-spec}
8
- s.version = "0.2.3"
8
+ s.version = "0.2.4"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Kristian Mandrup"]
12
- s.date = %q{2010-09-11}
12
+ s.date = %q{2010-09-13}
13
13
  s.description = %q{RSpec 2 matchers to spec the structure of your Rails 3 app}
14
14
  s.email = %q{kmandrup@gmail.com}
15
15
  s.extra_rdoc_files = [
@@ -32,6 +32,7 @@ Gem::Specification.new do |s|
32
32
  "lib/rails_app_spec/matchers/artifact/have_rails_artifact_file.rb",
33
33
  "lib/rails_app_spec/matchers/file/have_rails_dir.rb",
34
34
  "lib/rails_app_spec/matchers/file/have_rails_file.rb",
35
+ "lib/rails_app_spec/matchers/special/have_app_config.rb",
35
36
  "lib/rails_app_spec/namespaces.rb",
36
37
  "rails-app-spec.gemspec",
37
38
  "sandbox/dir_logic.rb",
@@ -1,5 +1,7 @@
1
1
  require 'spec_helper'
2
2
 
3
+ root_dir = Rails3::Assist::Directory.rails_root
4
+
3
5
  describe 'model helper' do
4
6
  use_orm :active_record
5
7
 
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 2
8
- - 3
9
- version: 0.2.3
8
+ - 4
9
+ version: 0.2.4
10
10
  platform: ruby
11
11
  authors:
12
12
  - Kristian Mandrup
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-09-11 00:00:00 +02:00
17
+ date: 2010-09-13 00:00:00 +02:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
@@ -119,6 +119,7 @@ files:
119
119
  - lib/rails_app_spec/matchers/artifact/have_rails_artifact_file.rb
120
120
  - lib/rails_app_spec/matchers/file/have_rails_dir.rb
121
121
  - lib/rails_app_spec/matchers/file/have_rails_file.rb
122
+ - lib/rails_app_spec/matchers/special/have_app_config.rb
122
123
  - lib/rails_app_spec/namespaces.rb
123
124
  - rails-app-spec.gemspec
124
125
  - sandbox/dir_logic.rb