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 +3 -1
- data/VERSION +1 -1
- data/lib/rails-app-spec.rb +1 -0
- data/lib/rails_app_spec/matchers/artifact/class/have_artifact_subclass.rb +2 -2
- data/lib/rails_app_spec/matchers/special/have_app_config.rb +50 -0
- data/lib/rails_app_spec/namespaces.rb +1 -1
- data/rails-app-spec.gemspec +3 -2
- data/spec/rails_app_spec/matchers/artifact/model_spec.rb +2 -0
- metadata +4 -3
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.
|
1
|
+
0.2.4
|
data/lib/rails-app-spec.rb
CHANGED
@@ -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 #{
|
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 #{
|
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
|
data/rails-app-spec.gemspec
CHANGED
@@ -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.
|
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-
|
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",
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 2
|
8
|
-
-
|
9
|
-
version: 0.2.
|
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-
|
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
|