Objective3-objective_spec 0.0.3 → 0.0.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/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.3
1
+ 0.0.5
@@ -30,31 +30,31 @@ describe <%= controller_class_name %>Controller do
30
30
 
31
31
  describe "route recognition" do
32
32
 
33
- it "should generate params { :controller => '<%= table_name %>', action => 'index' } from GET /<%= table_name %>" do
33
+ it "should generate params { :controller => '<%= table_name %>', :action => 'index' } from GET /<%= table_name %>" do
34
34
  params_from(:get, "/<%= table_name %>").should == {:controller => "<%= table_name %>", :action => "index"}
35
35
  end
36
36
 
37
- it "should generate params { :controller => '<%= table_name %>', action => 'new' } from GET /<%= table_name %>/new" do
37
+ it "should generate params { :controller => '<%= table_name %>', :action => 'new' } from GET /<%= table_name %>/new" do
38
38
  params_from(:get, "/<%= table_name %>/new").should == {:controller => "<%= table_name %>", :action => "new"}
39
39
  end
40
40
 
41
- it "should generate params { :controller => '<%= table_name %>', action => 'create' } from POST /<%= table_name %>" do
41
+ it "should generate params { :controller => '<%= table_name %>', :action => 'create' } from POST /<%= table_name %>" do
42
42
  params_from(:post, "/<%= table_name %>").should == {:controller => "<%= table_name %>", :action => "create"}
43
43
  end
44
44
 
45
- it "should generate params { :controller => '<%= table_name %>', action => 'show', id => '1' } from GET /<%= table_name %>/1" do
45
+ it "should generate params { :controller => '<%= table_name %>', :action => 'show', :id => '1' } from GET /<%= table_name %>/1" do
46
46
  params_from(:get, "/<%= table_name %>/1").should == {:controller => "<%= table_name %>", :action => "show", :id => "1"}
47
47
  end
48
48
 
49
- it "should generate params { :controller => '<%= table_name %>', action => 'edit', id => '1' } from GET /<%= table_name %>/1;edit" do
49
+ it "should generate params { :controller => '<%= table_name %>', :action => 'edit', :id => '1' } from GET /<%= table_name %>/1;edit" do
50
50
  params_from(:get, "/<%= table_name %>/1<%= resource_edit_path %>").should == {:controller => "<%= table_name %>", :action => "edit", :id => "1"}
51
51
  end
52
52
 
53
- it "should generate params { :controller => '<%= table_name %>', action => 'update', id => '1' } from PUT /<%= table_name %>/1" do
53
+ it "should generate params { :controller => '<%= table_name %>', :action => 'update', :id => '1' } from PUT /<%= table_name %>/1" do
54
54
  params_from(:put, "/<%= table_name %>/1").should == {:controller => "<%= table_name %>", :action => "update", :id => "1"}
55
55
  end
56
56
 
57
- it "should generate params { :controller => '<%= table_name %>', action => 'destroy', id => '1' } from DELETE /<%= table_name %>/1" do
57
+ it "should generate params { :controller => '<%= table_name %>', :action => 'destroy', :id => '1' } from DELETE /<%= table_name %>/1" do
58
58
  params_from(:delete, "/<%= table_name %>/1").should == {:controller => "<%= table_name %>", :action => "destroy", :id => "1"}
59
59
  end
60
60
  end
@@ -16,10 +16,11 @@ INFO
16
16
  m.directory 'spec/mailers'
17
17
  m.directory 'spec/matchers'
18
18
  m.directory 'spec/spec_helpers'
19
- m.file 'spec_helpers/common.rb', 'spec/spec_helpers/common.rb'
20
- m.file 'spec_helpers/model.rb', 'spec/spec_helpers/model.rb'
21
- m.file 'spec_helpers/view.rb', 'spec/spec_helpers/view.rb'
22
- m.file 'spec_helpers/controller.rb', 'spec/spec_helpers/controller.rb'
19
+ m.file 'spec_helpers/common.rb', 'spec/spec_helpers/common.rb'
20
+ m.file 'spec_helpers/model.rb', 'spec/spec_helpers/model.rb'
21
+ m.file 'spec_helpers/view.rb', 'spec/spec_helpers/view.rb'
22
+ m.file 'spec_helpers/controller.rb', 'spec/spec_helpers/controller.rb'
23
+ m.file 'spec_helpers/shared_examples.rb', 'spec/spec_helpers/shared_examples.rb'
23
24
  end
24
25
  end
25
26
 
@@ -0,0 +1 @@
1
+ # Include your shared examples in here
@@ -0,0 +1,28 @@
1
+ module Rails
2
+ module Generator
3
+ class GeneratedAttribute
4
+ def default_value
5
+ @default_value ||= case type
6
+ when :int, :integer then "1"
7
+ when :float then "1.5"
8
+ when :decimal then "9.99"
9
+ when :datetime, :timestamp, :time then "Time.now"
10
+ when :date then "Date.today"
11
+ when :string, :text then "\"value for #{@name}\""
12
+ when :boolean then "false"
13
+ when :belongs_to, :references then "1"
14
+ else
15
+ ""
16
+ end
17
+ end
18
+
19
+ def name_or_reference
20
+ if ::Rails::VERSION::STRING >= '2.2'
21
+ reference? ? :"#{name}_id" : name
22
+ else
23
+ name
24
+ end
25
+ end
26
+ end
27
+ end
28
+ end
@@ -1,6 +1,3 @@
1
- # Ensure the spec directory is on the Load Path
2
- $: << File.join(Rails.root, 'spec')
3
-
4
1
  require 'objective_spec/mailer_example_group'
5
2
  require 'objective_spec/matchers'
6
3
  require 'objective_spec/spec_helpers'
@@ -1,8 +1,31 @@
1
- # Load all files inside spec/matchers
2
- matchers_dir = File.join(Rails.root, 'spec', 'matchers')
3
- Dir.entries(matchers_dir).each do |entry|
4
- if entry =~ /_matcher.rb$/
5
- filename = entry.gsub(/.rb$/, '')
6
- require File.join(matchers_dir, filename)
1
+ module ObjectiveSpec
2
+ class Matchers
3
+ def load!
4
+ load_matchers_in_dir(bundled_matchers_dir)
5
+ load_matchers_in_dir(project_matchers_dir)
6
+ end
7
+
8
+ def load_matchers_in_dir(dir)
9
+ Dir.entries(dir).each do |entry|
10
+ if entry =~ /_matcher.rb$/
11
+ filename = entry.gsub(/.rb$/, '')
12
+ require File.join(dir, filename)
13
+ end
14
+ end
15
+ end
16
+
17
+ def bundled_matchers_dir
18
+ File.join(File.dirname(__FILE__), 'matchers')
19
+ end
20
+
21
+ def project_matchers_dir
22
+ File.join(Rails.root, 'spec', 'matchers')
23
+ end
24
+
25
+ def self.load!
26
+ self.new.load!
27
+ end
7
28
  end
8
29
  end
30
+
31
+ ObjectiveSpec::Matchers.load!
@@ -0,0 +1,25 @@
1
+ class UseLayout
2
+ attr_reader :actual, :expected
3
+
4
+ def initialize(expected)
5
+ @expected = 'layouts/' + expected
6
+ end
7
+
8
+ def matches?(controller)
9
+ @actual = controller.layout
10
+ @actual == @expected
11
+ end
12
+
13
+ def failure_message
14
+ return "use_layout expected #{@expected.inspect}, got #{@actual.inspect}"
15
+ end
16
+
17
+ def negeative_failure_message
18
+ return "use_layout expected #{@expected.inspect} not to equal #{@actual.inspect}"
19
+ end
20
+ end
21
+
22
+
23
+ def use_layout(expected)
24
+ UseLayout.new(expected)
25
+ end
@@ -1,4 +1,8 @@
1
- require 'spec_helpers/common'
2
- require 'spec_helpers/model'
3
- require 'spec_helpers/view'
4
- require 'spec_helpers/controller'
1
+ # Load all files inside spec/matchers
2
+ spec_helpers_dir = File.join(Rails.root, 'spec', 'spec_helpers')
3
+ Dir.entries(spec_helpers_dir).each do |entry|
4
+ if entry =~ /.rb$/
5
+ filename = entry.gsub(/.rb$/, '')
6
+ require File.join(spec_helpers_dir, filename)
7
+ end
8
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: Objective3-objective_spec
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Blake Watters
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-07-10 00:00:00 -07:00
12
+ date: 2009-07-16 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies: []
15
15
 
@@ -61,18 +61,21 @@ files:
61
61
  - generators/objective_spec/templates/spec_helpers/common.rb
62
62
  - generators/objective_spec/templates/spec_helpers/controller.rb
63
63
  - generators/objective_spec/templates/spec_helpers/model.rb
64
+ - generators/objective_spec/templates/spec_helpers/shared_examples.rb
64
65
  - generators/objective_spec/templates/spec_helpers/view.rb
66
+ - generators/rspec_default_values.rb
65
67
  - init.rb
66
68
  - lib/objective_spec.rb
67
69
  - lib/objective_spec/assets.rb
68
70
  - lib/objective_spec/mailer_example_group.rb
69
71
  - lib/objective_spec/matchers.rb
72
+ - lib/objective_spec/matchers/use_layout_matcher.rb
70
73
  - lib/objective_spec/spec_helpers.rb
71
- - objective_spec.gemspec
72
74
  - spec/objective_spec_spec.rb
73
75
  - spec/spec_helper.rb
74
76
  has_rdoc: true
75
77
  homepage: http://github.com/Objective3/objective_spec
78
+ licenses:
76
79
  post_install_message:
77
80
  rdoc_options:
78
81
  - --charset=UTF-8
@@ -93,7 +96,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
93
96
  requirements: []
94
97
 
95
98
  rubyforge_project:
96
- rubygems_version: 1.2.0
99
+ rubygems_version: 1.3.5
97
100
  signing_key:
98
101
  specification_version: 2
99
102
  summary: TODO
@@ -1,85 +0,0 @@
1
- # -*- encoding: utf-8 -*-
2
-
3
- Gem::Specification.new do |s|
4
- s.name = %q{objective_spec}
5
- s.version = "0.0.3"
6
-
7
- s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
- s.authors = ["Blake Watters"]
9
- s.date = %q{2009-07-10}
10
- s.email = %q{blake@objective3.com}
11
- s.extra_rdoc_files = [
12
- "LICENSE",
13
- "README.rdoc"
14
- ]
15
- s.files = [
16
- ".gitignore",
17
- "LICENSE",
18
- "README.rdoc",
19
- "Rakefile",
20
- "TODO",
21
- "VERSION",
22
- "generators/objective_controller/USAGE",
23
- "generators/objective_controller/objective_controller_generator.rb",
24
- "generators/objective_controller/templates/controller_spec.rb",
25
- "generators/objective_controller/templates/helper_spec.rb",
26
- "generators/objective_controller/templates/view.html.haml",
27
- "generators/objective_controller/templates/view_spec.rb",
28
- "generators/objective_model/objective_model_generator.rb",
29
- "generators/objective_model/templates/model_spec.rb",
30
- "generators/objective_resource/.DS_Store",
31
- "generators/objective_resource/objective_resource_generator.rb",
32
- "generators/objective_resource/templates/.DS_Store",
33
- "generators/objective_resource/templates/controller.rb",
34
- "generators/objective_resource/templates/helper.rb",
35
- "generators/objective_resource/templates/migration.rb",
36
- "generators/objective_resource/templates/model.rb",
37
- "generators/objective_resource/templates/rspec/functional_spec.rb",
38
- "generators/objective_resource/templates/rspec/helper_spec.rb",
39
- "generators/objective_resource/templates/rspec/routing_spec.rb",
40
- "generators/objective_resource/templates/rspec/unit_spec.rb",
41
- "generators/objective_resource/templates/rspec/views/edit_spec.rb",
42
- "generators/objective_resource/templates/rspec/views/index_spec.rb",
43
- "generators/objective_resource/templates/rspec/views/new_spec.rb",
44
- "generators/objective_resource/templates/rspec/views/show_spec.rb",
45
- "generators/objective_resource/templates/view__form.haml",
46
- "generators/objective_resource/templates/view_edit.haml",
47
- "generators/objective_resource/templates/view_index.haml",
48
- "generators/objective_resource/templates/view_new.haml",
49
- "generators/objective_resource/templates/view_show.haml",
50
- "generators/objective_spec/objective_spec_generator.rb",
51
- "generators/objective_spec/templates/spec_helpers/common.rb",
52
- "generators/objective_spec/templates/spec_helpers/controller.rb",
53
- "generators/objective_spec/templates/spec_helpers/model.rb",
54
- "generators/objective_spec/templates/spec_helpers/view.rb",
55
- "init.rb",
56
- "lib/objective_spec.rb",
57
- "lib/objective_spec/assets.rb",
58
- "lib/objective_spec/mailer_example_group.rb",
59
- "lib/objective_spec/matchers.rb",
60
- "lib/objective_spec/spec_helpers.rb",
61
- "objective_spec.gemspec",
62
- "spec/objective_spec_spec.rb",
63
- "spec/spec_helper.rb"
64
- ]
65
- s.has_rdoc = true
66
- s.homepage = %q{http://github.com/Objective3/objective_spec}
67
- s.rdoc_options = ["--charset=UTF-8"]
68
- s.require_paths = ["lib"]
69
- s.rubygems_version = %q{1.3.1}
70
- s.summary = %q{TODO}
71
- s.test_files = [
72
- "spec/objective_spec_spec.rb",
73
- "spec/spec_helper.rb"
74
- ]
75
-
76
- if s.respond_to? :specification_version then
77
- current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
78
- s.specification_version = 2
79
-
80
- if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
81
- else
82
- end
83
- else
84
- end
85
- end