administer 0.2.0 → 0.2.1

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.
Files changed (46) hide show
  1. data/README.rdoc +7 -0
  2. data/app/controllers/administer/models_controller.rb +11 -0
  3. data/app/helpers/administer/dashboard_helper.rb +5 -0
  4. data/app/views/administer/dashboard/index.html.haml +5 -0
  5. data/app/views/administer/models/index.html.haml +0 -0
  6. data/config/routes.rb +6 -1
  7. data/lib/administer/engine.rb +0 -2
  8. data/lib/administer/model.rb +22 -0
  9. data/lib/administer.rb +2 -3
  10. data/spec/rails_root/app/controllers/application_controller.rb +3 -0
  11. data/spec/rails_root/app/controllers/posts_controller.rb +83 -0
  12. data/spec/rails_root/app/helpers/application_helper.rb +2 -0
  13. data/spec/rails_root/app/helpers/posts_helper.rb +2 -0
  14. data/spec/rails_root/app/models/post.rb +2 -0
  15. data/spec/rails_root/autotest/discover.rb +2 -0
  16. data/spec/rails_root/config/application.rb +48 -0
  17. data/spec/rails_root/config/boot.rb +13 -0
  18. data/spec/rails_root/config/environment.rb +5 -0
  19. data/spec/rails_root/config/environments/development.rb +26 -0
  20. data/spec/rails_root/config/environments/production.rb +49 -0
  21. data/spec/rails_root/config/environments/test.rb +35 -0
  22. data/spec/rails_root/config/initializers/backtrace_silencers.rb +7 -0
  23. data/spec/rails_root/config/initializers/inflections.rb +10 -0
  24. data/spec/rails_root/config/initializers/mime_types.rb +5 -0
  25. data/spec/rails_root/config/initializers/secret_token.rb +7 -0
  26. data/spec/rails_root/config/initializers/session_store.rb +8 -0
  27. data/spec/rails_root/config/routes.rb +62 -0
  28. data/spec/rails_root/db/migrate/20101113123123_create_posts.rb +14 -0
  29. data/spec/rails_root/db/seeds.rb +7 -0
  30. data/spec/rails_root/features/step_definitions/post_steps.rb +10 -0
  31. data/spec/rails_root/features/step_definitions/web_steps.rb +230 -0
  32. data/spec/rails_root/features/support/env.rb +64 -0
  33. data/spec/rails_root/features/support/paths.rb +37 -0
  34. data/spec/rails_root/spec/controllers/administer/models_controller_spec.rb +13 -0
  35. data/spec/rails_root/spec/controllers/posts_controller_spec.rb +121 -0
  36. data/spec/rails_root/spec/factories/posts.rb +4 -0
  37. data/spec/rails_root/spec/models/administer/model_spec.rb +15 -0
  38. data/spec/rails_root/spec/routing/posts_routing_spec.rb +35 -0
  39. data/spec/rails_root/spec/spec_helper.rb +27 -0
  40. data/spec/rails_root/spec/views/posts/edit.html.haml_spec.rb +21 -0
  41. data/spec/rails_root/spec/views/posts/new.html.haml_spec.rb +20 -0
  42. data/spec/rails_root/spec/views/posts/show.html.haml_spec.rb +18 -0
  43. data/spec/rails_root/test/integration/post_test.rb +10 -0
  44. data/spec/rails_root/test/performance/browsing_test.rb +9 -0
  45. data/spec/rails_root/test/test_helper.rb +13 -0
  46. metadata +81 -6
@@ -0,0 +1,230 @@
1
+ # IMPORTANT: This file is generated by cucumber-rails - edit at your own peril.
2
+ # It is recommended to regenerate this file in the future when you upgrade to a
3
+ # newer version of cucumber-rails. Consider adding your own code to a new file
4
+ # instead of editing this one. Cucumber will automatically load all features/**/*.rb
5
+ # files.
6
+
7
+
8
+ require 'uri'
9
+ require 'cgi'
10
+ require File.expand_path(File.join(File.dirname(__FILE__), "..", "support", "paths"))
11
+
12
+ module WithinHelpers
13
+ def with_scope(locator)
14
+ locator ? within(locator) { yield } : yield
15
+ end
16
+ end
17
+ World(WithinHelpers)
18
+
19
+ Given /^(?:|I )am on (.+)$/ do |page_name|
20
+ visit path_to(page_name)
21
+ end
22
+
23
+ When /^(?:|I )go to (.+)$/ do |page_name|
24
+ visit path_to(page_name)
25
+ end
26
+
27
+ When /^(?:|I )press "([^"]*)"(?: within "([^"]*)")?$/ do |button, selector|
28
+ with_scope(selector) do
29
+ click_button(button)
30
+ end
31
+ end
32
+
33
+ When /^(?:|I )follow "([^"]*)"(?: within "([^"]*)")?$/ do |link, selector|
34
+ with_scope(selector) do
35
+ click_link(link)
36
+ end
37
+ end
38
+
39
+ When /^(?:|I )fill in "([^"]*)" with "([^"]*)"(?: within "([^"]*)")?$/ do |field, value, selector|
40
+ with_scope(selector) do
41
+ fill_in(field, :with => value)
42
+ end
43
+ end
44
+
45
+ When /^(?:|I )fill in "([^"]*)" for "([^"]*)"(?: within "([^"]*)")?$/ do |value, field, selector|
46
+ with_scope(selector) do
47
+ fill_in(field, :with => value)
48
+ end
49
+ end
50
+
51
+ # Use this to fill in an entire form with data from a table. Example:
52
+ #
53
+ # When I fill in the following:
54
+ # | Account Number | 5002 |
55
+ # | Expiry date | 2009-11-01 |
56
+ # | Note | Nice guy |
57
+ # | Wants Email? | |
58
+ #
59
+ # TODO: Add support for checkbox, select og option
60
+ # based on naming conventions.
61
+ #
62
+ When /^(?:|I )fill in the following(?: within "([^"]*)")?:$/ do |selector, fields|
63
+ with_scope(selector) do
64
+ fields.rows_hash.each do |name, value|
65
+ When %{I fill in "#{name}" with "#{value}"}
66
+ end
67
+ end
68
+ end
69
+
70
+ When /^(?:|I )select "([^"]*)" from "([^"]*)"(?: within "([^"]*)")?$/ do |value, field, selector|
71
+ with_scope(selector) do
72
+ select(value, :from => field)
73
+ end
74
+ end
75
+
76
+ When /^(?:|I )check "([^"]*)"(?: within "([^"]*)")?$/ do |field, selector|
77
+ with_scope(selector) do
78
+ check(field)
79
+ end
80
+ end
81
+
82
+ When /^(?:|I )uncheck "([^"]*)"(?: within "([^"]*)")?$/ do |field, selector|
83
+ with_scope(selector) do
84
+ uncheck(field)
85
+ end
86
+ end
87
+
88
+ When /^(?:|I )choose "([^"]*)"(?: within "([^"]*)")?$/ do |field, selector|
89
+ with_scope(selector) do
90
+ choose(field)
91
+ end
92
+ end
93
+
94
+ When /^(?:|I )attach the file "([^"]*)" to "([^"]*)"(?: within "([^"]*)")?$/ do |path, field, selector|
95
+ with_scope(selector) do
96
+ attach_file(field, path)
97
+ end
98
+ end
99
+
100
+ Then /^(?:|I )should see JSON:$/ do |expected_json|
101
+ require 'json'
102
+ expected = JSON.pretty_generate(JSON.parse(expected_json))
103
+ actual = JSON.pretty_generate(JSON.parse(response.body))
104
+ expected.should == actual
105
+ end
106
+
107
+ Then /^(?:|I )should see "([^"]*)"(?: within "([^"]*)")?$/ do |text, selector|
108
+ with_scope(selector) do
109
+ if page.respond_to? :should
110
+ page.should have_content(text)
111
+ else
112
+ assert page.has_content?(text)
113
+ end
114
+ end
115
+ end
116
+
117
+ Then /^(?:|I )should see \/([^\/]*)\/(?: within "([^"]*)")?$/ do |regexp, selector|
118
+ regexp = Regexp.new(regexp)
119
+ with_scope(selector) do
120
+ if page.respond_to? :should
121
+ page.should have_xpath('//*', :text => regexp)
122
+ else
123
+ assert page.has_xpath?('//*', :text => regexp)
124
+ end
125
+ end
126
+ end
127
+
128
+ Then /^(?:|I )should not see "([^"]*)"(?: within "([^"]*)")?$/ do |text, selector|
129
+ with_scope(selector) do
130
+ if page.respond_to? :should
131
+ page.should have_no_content(text)
132
+ else
133
+ assert page.has_no_content?(text)
134
+ end
135
+ end
136
+ end
137
+
138
+ Then /^(?:|I )should not see \/([^\/]*)\/(?: within "([^"]*)")?$/ do |regexp, selector|
139
+ regexp = Regexp.new(regexp)
140
+ with_scope(selector) do
141
+ if page.respond_to? :should
142
+ page.should have_no_xpath('//*', :text => regexp)
143
+ else
144
+ assert page.has_no_xpath?('//*', :text => regexp)
145
+ end
146
+ end
147
+ end
148
+
149
+ Then /^the "([^"]*)" field(?: within "([^"]*)")? should contain "([^"]*)"$/ do |field, selector, value|
150
+ with_scope(selector) do
151
+ field = find_field(field)
152
+ field_value = (field.tag_name == 'textarea') ? field.text : field.value
153
+ if field_value.respond_to? :should
154
+ field_value.should =~ /#{value}/
155
+ else
156
+ assert_match(/#{value}/, field_value)
157
+ end
158
+ end
159
+ end
160
+
161
+ Then /^the "([^"]*)" field(?: within "([^"]*)")? should not contain "([^"]*)"$/ do |field, selector, value|
162
+ with_scope(selector) do
163
+ field = find_field(field)
164
+ field_value = (field.tag_name == 'textarea') ? field.text : field.value
165
+ if field_value.respond_to? :should_not
166
+ field_value.should_not =~ /#{value}/
167
+ else
168
+ assert_no_match(/#{value}/, field_value)
169
+ end
170
+ end
171
+ end
172
+
173
+ Then /^the "([^"]*)" checkbox(?: within "([^"]*)")? should be checked$/ do |label, selector|
174
+ with_scope(selector) do
175
+ field_checked = find_field(label)['checked']
176
+ if field_checked.respond_to? :should
177
+ field_checked.should be_true
178
+ else
179
+ assert field_checked
180
+ end
181
+ end
182
+ end
183
+
184
+ Then /^the "([^"]*)" checkbox(?: within "([^"]*)")? should not be checked$/ do |label, selector|
185
+ with_scope(selector) do
186
+ field_checked = find_field(label)['checked']
187
+ if field_checked.respond_to? :should
188
+ field_checked.should be_false
189
+ else
190
+ assert !field_checked
191
+ end
192
+ end
193
+ end
194
+
195
+ Then /^(?:|I )should be on (.+)$/ do |page_name|
196
+ current_path = URI.parse(current_url).path
197
+ if current_path.respond_to? :should
198
+ current_path.should == path_to(page_name)
199
+ else
200
+ assert_equal path_to(page_name), current_path
201
+ end
202
+ end
203
+
204
+ Then /^(?:|I )should have the following query string:$/ do |expected_pairs|
205
+ query = URI.parse(current_url).query
206
+ actual_params = query ? CGI.parse(query) : {}
207
+ expected_params = {}
208
+ expected_pairs.rows_hash.each_pair{|k,v| expected_params[k] = v.split(',')}
209
+
210
+ if actual_params.respond_to? :should
211
+ actual_params.should == expected_params
212
+ else
213
+ assert_equal expected_params, actual_params
214
+ end
215
+ end
216
+
217
+ Then /^show me the page$/ do
218
+ save_and_open_page
219
+ end
220
+
221
+ Then /^(?:|I )press "([^"]*)" and confirm$/ do |button|
222
+ page.evaluate_script("window.confirm = function(msg) { return true; }")
223
+ When %{I press "#{button}"}
224
+ end
225
+
226
+ Then /^(?:|I )press "([^"]*)" and not confirm$/ do |button|
227
+ page.evaluate_script("window.confirm = function(msg) { return false; }")
228
+ When %{I press "#{button}"}
229
+ end
230
+
@@ -0,0 +1,64 @@
1
+ # IMPORTANT: This file is generated by cucumber-rails - edit at your own peril.
2
+ # It is recommended to regenerate this file in the future when you upgrade to a
3
+ # newer version of cucumber-rails. Consider adding your own code to a new file
4
+ # instead of editing this one. Cucumber will automatically load all features/**/*.rb
5
+ # files.
6
+
7
+ ENV["RAILS_ENV"] ||= "test"
8
+ require File.expand_path(File.dirname(__FILE__) + '/../../config/environment')
9
+
10
+ require 'cucumber/formatter/unicode' # Remove this line if you don't want Cucumber Unicode support
11
+ require 'cucumber/rails/rspec'
12
+ require 'cucumber/rails/world'
13
+ require 'cucumber/rails/active_record'
14
+ require 'cucumber/web/tableish'
15
+
16
+ require 'capybara/rails'
17
+ require 'capybara/cucumber'
18
+ require 'capybara/session'
19
+ # require 'cucumber/rails/capybara_javascript_emulation' # Lets you click links with onclick javascript handlers without using @culerity or @javascript
20
+ # Capybara defaults to XPath selectors rather than Webrat's default of CSS3. In
21
+ # order to ease the transition to Capybara we set the default here. If you'd
22
+ # prefer to use XPath just remove this line and adjust any selectors in your
23
+ # steps to use the XPath syntax.
24
+ Capybara.default_selector = :css
25
+ Capybara.javascript_driver = :selenium
26
+ Capybara.ignore_hidden_elements = true
27
+
28
+ # If you set this to false, any error raised from within your app will bubble
29
+ # up to your step definition and out to cucumber unless you catch it somewhere
30
+ # on the way. You can make Rails rescue errors and render error pages on a
31
+ # per-scenario basis by tagging a scenario or feature with the @allow-rescue tag.
32
+ #
33
+ # If you set this to true, Rails will rescue all errors and render error
34
+ # pages, more or less in the same way your application would behave in the
35
+ # default production environment. It's not recommended to do this for all
36
+ # of your scenarios, as this makes it hard to discover errors in your application.
37
+ ActionController::Base.allow_rescue = false
38
+
39
+ # If you set this to true, each scenario will run in a database transaction.
40
+ # You can still turn off transactions on a per-scenario basis, simply tagging
41
+ # a feature or scenario with the @no-txn tag. If you are using Capybara,
42
+ # tagging with @culerity or @javascript will also turn transactions off.
43
+ #
44
+ # If you set this to false, transactions will be off for all scenarios,
45
+ # regardless of whether you use @no-txn or not.
46
+ #
47
+ # Beware that turning transactions off will leave data in your database
48
+ # after each scenario, which can lead to hard-to-debug failures in
49
+ # subsequent scenarios. If you do this, we recommend you create a Before
50
+ # block that will explicitly put your database in a known state.
51
+ Cucumber::Rails::World.use_transactional_fixtures = true
52
+ # How to clean your database when transactions are turned off. See
53
+ # http://github.com/bmabey/database_cleaner for more info.
54
+ if defined?(ActiveRecord::Base)
55
+ begin
56
+ require 'database_cleaner'
57
+ DatabaseCleaner.strategy = :truncation
58
+ rescue LoadError => ignore_if_database_cleaner_not_present
59
+ end
60
+ end
61
+
62
+ # factory_girl setup
63
+ require 'factory_girl'
64
+ Dir["#{File.dirname(__FILE__)}/../../spec/factories/*.rb"].each {|f| require f}
@@ -0,0 +1,37 @@
1
+ module NavigationHelpers
2
+ # Maps a name to a path. Used by the
3
+ #
4
+ # When /^I go to (.+)$/ do |page_name|
5
+ #
6
+ # step definition in web_steps.rb
7
+ #
8
+ def path_to(page_name)
9
+ case page_name
10
+
11
+ when /the home\s?page/
12
+ '/'
13
+ when /the administer dashboard page/
14
+ '/administer'
15
+ when /posts list/
16
+ '/posts'
17
+
18
+ # Add more mappings here.
19
+ # Here is an example that pulls values out of the Regexp:
20
+ #
21
+ # when /^(.*)'s profile page$/i
22
+ # user_profile_path(User.find_by_login($1))
23
+
24
+ else
25
+ begin
26
+ page_name =~ /the (.*) page/
27
+ path_components = $1.split(/\s+/)
28
+ self.send(path_components.push('path').join('_').to_sym)
29
+ rescue Object => e
30
+ raise "Can't find mapping from \"#{page_name}\" to a path.\n" +
31
+ "Now, go and add a mapping in #{__FILE__}"
32
+ end
33
+ end
34
+ end
35
+ end
36
+
37
+ World(NavigationHelpers)
@@ -0,0 +1,13 @@
1
+ require 'spec_helper'
2
+
3
+ describe Administer::ModelsController do
4
+ describe "GET /index" do
5
+ it "should lookup for proper collection" do
6
+ Administer::Model.should_receive(:lookup).with('post').and_return(Post)
7
+ posts = mock_model(Post)
8
+ Post.should_receive(:all).and_return(posts)
9
+ get :index, :model_name => 'post'
10
+ assigns[:collection].should == posts
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,121 @@
1
+ require 'spec_helper'
2
+
3
+ describe PostsController do
4
+
5
+ def mock_post(stubs={})
6
+ (@mock_post ||= mock_model(Post).as_null_object).tap do |post|
7
+ post.stub(stubs) unless stubs.empty?
8
+ end
9
+ end
10
+
11
+ describe "GET index" do
12
+ it "assigns all posts as @posts" do
13
+ Post.stub(:all) { [mock_post] }
14
+ get :index
15
+ assigns(:posts).should eq([mock_post])
16
+ end
17
+ end
18
+
19
+ describe "GET show" do
20
+ it "assigns the requested post as @post" do
21
+ Post.stub(:find).with("37") { mock_post }
22
+ get :show, :id => "37"
23
+ assigns(:post).should be(mock_post)
24
+ end
25
+ end
26
+
27
+ describe "GET new" do
28
+ it "assigns a new post as @post" do
29
+ Post.stub(:new) { mock_post }
30
+ get :new
31
+ assigns(:post).should be(mock_post)
32
+ end
33
+ end
34
+
35
+ describe "GET edit" do
36
+ it "assigns the requested post as @post" do
37
+ Post.stub(:find).with("37") { mock_post }
38
+ get :edit, :id => "37"
39
+ assigns(:post).should be(mock_post)
40
+ end
41
+ end
42
+
43
+ describe "POST create" do
44
+
45
+ describe "with valid params" do
46
+ it "assigns a newly created post as @post" do
47
+ Post.stub(:new).with({'these' => 'params'}) { mock_post(:save => true) }
48
+ post :create, :post => {'these' => 'params'}
49
+ assigns(:post).should be(mock_post)
50
+ end
51
+ end
52
+
53
+ describe "with invalid params" do
54
+ it "assigns a newly created but unsaved post as @post" do
55
+ Post.stub(:new).with({'these' => 'params'}) { mock_post(:save => false) }
56
+ post :create, :post => {'these' => 'params'}
57
+ assigns(:post).should be(mock_post)
58
+ end
59
+
60
+ it "re-renders the 'new' template" do
61
+ Post.stub(:new) { mock_post(:save => false) }
62
+ post :create, :post => {}
63
+ response.should render_template("new")
64
+ end
65
+ end
66
+
67
+ end
68
+
69
+ describe "PUT update" do
70
+
71
+ describe "with valid params" do
72
+ it "updates the requested post" do
73
+ Post.should_receive(:find).with("37") { mock_post }
74
+ mock_post.should_receive(:update_attributes).with({'these' => 'params'})
75
+ put :update, :id => "37", :post => {'these' => 'params'}
76
+ end
77
+
78
+ it "assigns the requested post as @post" do
79
+ Post.stub(:find) { mock_post(:update_attributes => true) }
80
+ put :update, :id => "1"
81
+ assigns(:post).should be(mock_post)
82
+ end
83
+
84
+ it "redirects to the post" do
85
+ Post.stub(:find) { mock_post(:update_attributes => true) }
86
+ put :update, :id => "1"
87
+ response.should redirect_to(posts_url)
88
+ end
89
+ end
90
+
91
+ describe "with invalid params" do
92
+ it "assigns the post as @post" do
93
+ Post.stub(:find) { mock_post(:update_attributes => false) }
94
+ put :update, :id => "1"
95
+ assigns(:post).should be(mock_post)
96
+ end
97
+
98
+ it "re-renders the 'edit' template" do
99
+ Post.stub(:find) { mock_post(:update_attributes => false) }
100
+ put :update, :id => "1"
101
+ response.should render_template("edit")
102
+ end
103
+ end
104
+
105
+ end
106
+
107
+ describe "DELETE destroy" do
108
+ it "destroys the requested post" do
109
+ Post.should_receive(:find).with("37") { mock_post }
110
+ mock_post.should_receive(:destroy)
111
+ delete :destroy, :id => "37"
112
+ end
113
+
114
+ it "redirects to the posts list" do
115
+ Post.stub(:find) { mock_post }
116
+ delete :destroy, :id => "1"
117
+ response.should redirect_to(posts_url)
118
+ end
119
+ end
120
+
121
+ end
@@ -0,0 +1,4 @@
1
+ Factory.define :post do |p|
2
+ p.title "New post"
3
+ p.body "Post body"
4
+ end
@@ -0,0 +1,15 @@
1
+ require 'spec_helper'
2
+
3
+ describe Administer::Model do
4
+ it "should lookup for model given its name" do
5
+ Administer::Model.lookup('post').should == Post
6
+ end
7
+
8
+ it "should return all models defined within ROOT/app/models/, using lookup" do
9
+ Rails.root.should_receive(:join).with('app/models/**/*.rb').and_return('models_path')
10
+ Dir.should_receive(:[]).with('models_path').and_return(['ROOT/app/models/post.rb'])
11
+ Administer::Model.should_receive(:lookup).with('post').and_return('PostStub')
12
+ Administer::Model.all.should == ['PostStub']
13
+ end
14
+
15
+ end
@@ -0,0 +1,35 @@
1
+ require "spec_helper"
2
+
3
+ describe PostsController do
4
+ describe "routing" do
5
+
6
+ it "recognizes and generates #index" do
7
+ { :get => "/posts" }.should route_to(:controller => "posts", :action => "index")
8
+ end
9
+
10
+ it "recognizes and generates #new" do
11
+ { :get => "/posts/new" }.should route_to(:controller => "posts", :action => "new")
12
+ end
13
+
14
+ it "recognizes and generates #show" do
15
+ { :get => "/posts/1" }.should route_to(:controller => "posts", :action => "show", :id => "1")
16
+ end
17
+
18
+ it "recognizes and generates #edit" do
19
+ { :get => "/posts/1/edit" }.should route_to(:controller => "posts", :action => "edit", :id => "1")
20
+ end
21
+
22
+ it "recognizes and generates #create" do
23
+ { :post => "/posts" }.should route_to(:controller => "posts", :action => "create")
24
+ end
25
+
26
+ it "recognizes and generates #update" do
27
+ { :put => "/posts/1" }.should route_to(:controller => "posts", :action => "update", :id => "1")
28
+ end
29
+
30
+ it "recognizes and generates #destroy" do
31
+ { :delete => "/posts/1" }.should route_to(:controller => "posts", :action => "destroy", :id => "1")
32
+ end
33
+
34
+ end
35
+ end
@@ -0,0 +1,27 @@
1
+ # This file is copied to spec/ when you run 'rails generate rspec:install'
2
+ ENV["RAILS_ENV"] ||= 'test'
3
+ require File.expand_path("../../config/environment", __FILE__)
4
+ require 'rspec/rails'
5
+
6
+ # Requires supporting ruby files with custom matchers and macros, etc,
7
+ # in spec/support/ and its subdirectories.
8
+ Dir[Rails.root.join("spec/support/**/*.rb")].each {|f| require f}
9
+
10
+ RSpec.configure do |config|
11
+ # == Mock Framework
12
+ #
13
+ # If you prefer to use mocha, flexmock or RR, uncomment the appropriate line:
14
+ #
15
+ # config.mock_with :mocha
16
+ # config.mock_with :flexmock
17
+ # config.mock_with :rr
18
+ config.mock_with :rspec
19
+
20
+ # Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
21
+ config.fixture_path = "#{::Rails.root}/spec/fixtures"
22
+
23
+ # If you're not using ActiveRecord, or you'd prefer not to run each of your
24
+ # examples within a transaction, remove the following line or assign false
25
+ # instead of true.
26
+ config.use_transactional_fixtures = true
27
+ end
@@ -0,0 +1,21 @@
1
+ require 'spec_helper'
2
+
3
+ describe "posts/edit.html.haml" do
4
+ before(:each) do
5
+ @post = assign(:post, stub_model(Post,
6
+ :new_record? => false,
7
+ :title => "MyString",
8
+ :body => "MyText"
9
+ ))
10
+ end
11
+
12
+ it "renders the edit post form" do
13
+ render
14
+
15
+ # Run the generator again with the --webrat-matchers flag if you want to use webrat matchers
16
+ assert_select "form", :action => post_path(@post), :method => "post" do
17
+ assert_select "input#post_title", :name => "post[title]"
18
+ assert_select "textarea#post_body", :name => "post[body]"
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,20 @@
1
+ require 'spec_helper'
2
+
3
+ describe "posts/new.html.haml" do
4
+ before(:each) do
5
+ assign(:post, stub_model(Post,
6
+ :title => "MyString",
7
+ :body => "MyText"
8
+ ).as_new_record)
9
+ end
10
+
11
+ it "renders new post form" do
12
+ render
13
+
14
+ # Run the generator again with the --webrat-matchers flag if you want to use webrat matchers
15
+ assert_select "form", :action => posts_path, :method => "post" do
16
+ assert_select "input#post_title", :name => "post[title]"
17
+ assert_select "textarea#post_body", :name => "post[body]"
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,18 @@
1
+ require 'spec_helper'
2
+
3
+ describe "posts/show.html.haml" do
4
+ before(:each) do
5
+ @post = assign(:post, stub_model(Post,
6
+ :title => "Title",
7
+ :body => "MyText"
8
+ ))
9
+ end
10
+
11
+ it "renders attributes in <p>" do
12
+ render
13
+ # Run the generator again with the --webrat-matchers flag if you want to use webrat matchers
14
+ rendered.should match(/Title/)
15
+ # Run the generator again with the --webrat-matchers flag if you want to use webrat matchers
16
+ rendered.should match(/MyText/)
17
+ end
18
+ end
@@ -0,0 +1,10 @@
1
+ require 'test_helper'
2
+
3
+ class PostTest < ActionDispatch::IntegrationTest
4
+ fixtures :all
5
+
6
+ # Replace this with your real tests.
7
+ test "the truth" do
8
+ assert true
9
+ end
10
+ end
@@ -0,0 +1,9 @@
1
+ require 'test_helper'
2
+ require 'rails/performance_test_help'
3
+
4
+ # Profiling results for each test method are written to tmp/performance.
5
+ class BrowsingTest < ActionDispatch::PerformanceTest
6
+ def test_homepage
7
+ get '/'
8
+ end
9
+ end
@@ -0,0 +1,13 @@
1
+ ENV["RAILS_ENV"] = "test"
2
+ require File.expand_path('../../config/environment', __FILE__)
3
+ require 'rails/test_help'
4
+
5
+ class ActiveSupport::TestCase
6
+ # Setup all fixtures in test/fixtures/*.(yml|csv) for all tests in alphabetical order.
7
+ #
8
+ # Note: You'll currently still have to declare fixtures explicitly in integration tests
9
+ # -- they do not yet inherit this setting
10
+ fixtures :all
11
+
12
+ # Add more helper methods to be used by all tests here...
13
+ end