simple_token_authentication 1.0.0.beta.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/LICENSE +674 -0
- data/README.md +134 -0
- data/Rakefile +32 -0
- data/lib/simple_token_authentication.rb +5 -0
- data/lib/simple_token_authentication/acts_as_token_authenticatable.rb +33 -0
- data/lib/simple_token_authentication/acts_as_token_authentication_handler.rb +68 -0
- data/lib/simple_token_authentication/version.rb +3 -0
- data/lib/tasks/simple_token_authentication_tasks.rake +4 -0
- data/test/dummy/README.rdoc +28 -0
- data/test/dummy/Rakefile +6 -0
- data/test/dummy/app/assets/javascripts/application.js +13 -0
- data/test/dummy/app/assets/javascripts/posts.js +2 -0
- data/test/dummy/app/assets/javascripts/private_posts.js +2 -0
- data/test/dummy/app/assets/stylesheets/application.css +13 -0
- data/test/dummy/app/assets/stylesheets/posts.css +4 -0
- data/test/dummy/app/assets/stylesheets/private_posts.css +4 -0
- data/test/dummy/app/assets/stylesheets/scaffold.css +56 -0
- data/test/dummy/app/controllers/application_controller.rb +21 -0
- data/test/dummy/app/controllers/posts_controller.rb +62 -0
- data/test/dummy/app/controllers/private_posts_controller.rb +63 -0
- data/test/dummy/app/helpers/application_helper.rb +2 -0
- data/test/dummy/app/helpers/posts_helper.rb +2 -0
- data/test/dummy/app/helpers/private_posts_helper.rb +2 -0
- data/test/dummy/app/models/post.rb +3 -0
- data/test/dummy/app/models/private_post.rb +3 -0
- data/test/dummy/app/models/user.rb +2 -0
- data/test/dummy/app/views/layouts/application.html.erb +14 -0
- data/test/dummy/app/views/posts/_form.html.erb +29 -0
- data/test/dummy/app/views/posts/edit.html.erb +6 -0
- data/test/dummy/app/views/posts/index.html.erb +31 -0
- data/test/dummy/app/views/posts/new.html.erb +5 -0
- data/test/dummy/app/views/posts/show.html.erb +19 -0
- data/test/dummy/app/views/private_posts/_form.html.erb +29 -0
- data/test/dummy/app/views/private_posts/edit.html.erb +6 -0
- data/test/dummy/app/views/private_posts/index.html.erb +31 -0
- data/test/dummy/app/views/private_posts/new.html.erb +5 -0
- data/test/dummy/app/views/private_posts/show.html.erb +19 -0
- data/test/dummy/bin/bundle +3 -0
- data/test/dummy/bin/rails +4 -0
- data/test/dummy/bin/rake +4 -0
- data/test/dummy/config.ru +4 -0
- data/test/dummy/config/application.rb +23 -0
- data/test/dummy/config/boot.rb +5 -0
- data/test/dummy/config/database.yml +25 -0
- data/test/dummy/config/environment.rb +5 -0
- data/test/dummy/config/environments/development.rb +29 -0
- data/test/dummy/config/environments/production.rb +80 -0
- data/test/dummy/config/environments/test.rb +36 -0
- data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/test/dummy/config/initializers/filter_parameter_logging.rb +4 -0
- data/test/dummy/config/initializers/indefinite_articlerize.rb +4 -0
- data/test/dummy/config/initializers/inflections.rb +16 -0
- data/test/dummy/config/initializers/mime_types.rb +5 -0
- data/test/dummy/config/initializers/secret_token.rb +12 -0
- data/test/dummy/config/initializers/session_store.rb +3 -0
- data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/test/dummy/config/locales/en.yml +23 -0
- data/test/dummy/config/routes.rb +60 -0
- data/test/dummy/db/development.sqlite3 +0 -0
- data/test/dummy/db/migrate/20140107041016_create_posts.rb +11 -0
- data/test/dummy/db/migrate/20140107053025_create_users.rb +6 -0
- data/test/dummy/db/migrate/20140107064508_create_private_posts.rb +11 -0
- data/test/dummy/db/schema.rb +35 -0
- data/test/dummy/db/test.sqlite3 +0 -0
- data/test/dummy/lib/generators/rspec/controller/controller_generator.rb +33 -0
- data/test/dummy/lib/generators/rspec/helper/helper_generator.rb +15 -0
- data/test/dummy/lib/generators/rspec/model/model_generator.rb +22 -0
- data/test/dummy/lib/generators/rspec/scaffold/scaffold_generator.rb +192 -0
- data/test/dummy/lib/templates/rspec/controller/controller_spec.rb +16 -0
- data/test/dummy/lib/templates/rspec/controller/view_spec.rb +5 -0
- data/test/dummy/lib/templates/rspec/helper/helper_spec.rb +0 -0
- data/test/dummy/lib/templates/rspec/model/model_spec.rb +65 -0
- data/test/dummy/lib/templates/rspec/model/model_spec_backup.rb +19 -0
- data/test/dummy/lib/templates/rspec/scaffold/controller_spec.rb +168 -0
- data/test/dummy/lib/templates/rspec/scaffold/edit_spec.rb +31 -0
- data/test/dummy/lib/templates/rspec/scaffold/index_spec.rb +32 -0
- data/test/dummy/lib/templates/rspec/scaffold/new_spec.rb +30 -0
- data/test/dummy/lib/templates/rspec/scaffold/routing_spec.rb +39 -0
- data/test/dummy/lib/templates/rspec/scaffold/show_spec.rb +28 -0
- data/test/dummy/log/development.log +3437 -0
- data/test/dummy/log/test.log +22013 -0
- data/test/dummy/public/404.html +58 -0
- data/test/dummy/public/422.html +58 -0
- data/test/dummy/public/500.html +57 -0
- data/test/dummy/public/favicon.ico +0 -0
- data/test/dummy/spec/controllers/posts_controller_spec.rb +161 -0
- data/test/dummy/spec/controllers/private_posts_controller_spec.rb +41 -0
- data/test/dummy/spec/factories/posts.rb +11 -0
- data/test/dummy/spec/factories/private_posts.rb +11 -0
- data/test/dummy/spec/helpers/posts_helper_spec.rb +0 -0
- data/test/dummy/spec/helpers/private_posts_helper_spec.rb +0 -0
- data/test/dummy/spec/models/post_spec.rb +65 -0
- data/test/dummy/spec/models/private_post_spec.rb +65 -0
- data/test/dummy/spec/models/user_spec.rb +61 -0
- data/test/dummy/spec/requests/posts_spec.rb +16 -0
- data/test/dummy/spec/requests/private_posts_spec.rb +17 -0
- data/test/dummy/spec/routing/posts_routing_spec.rb +35 -0
- data/test/dummy/spec/routing/private_posts_routing_spec.rb +35 -0
- data/test/dummy/spec/spec_helper.rb +42 -0
- data/test/dummy/spec/support/factory_girl.rb +6 -0
- data/test/dummy/spec/views/posts/edit.html.erb_spec.rb +22 -0
- data/test/dummy/spec/views/posts/index.html.erb_spec.rb +26 -0
- data/test/dummy/spec/views/posts/new.html.erb_spec.rb +22 -0
- data/test/dummy/spec/views/posts/show.html.erb_spec.rb +19 -0
- data/test/dummy/spec/views/private_posts/edit.html.erb_spec.rb +22 -0
- data/test/dummy/spec/views/private_posts/index.html.erb_spec.rb +26 -0
- data/test/dummy/spec/views/private_posts/new.html.erb_spec.rb +22 -0
- data/test/dummy/spec/views/private_posts/show.html.erb_spec.rb +19 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/13fe41fee1fe35b49d145bcc06610705 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/2f5173deea6c795b8fdde723bb4b63af +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/357970feca3ac29060c1e3861e2c0953 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/371bf96e99717688ed7313a0c53f4212 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/4050a4e5062ab95c9f32e9b6940821ea +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/416150dc3ac35079c94273cc46e90aa6 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/5384ad85f52d3272dbc64d46ef3876a4 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/5f1a0d05e77ca8b9a1fc2a47e17a8174 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/6fc757c2c8329244ca95d6909865bbc2 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/87b209c0c9da28094a8d5581a21262c6 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/c85016e7bbd4f3adbb7635d01f85d39b +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/cffd775d018f68ce5dba1ee0d951a994 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/d066c004d1fd26ae76a61303a7a18145 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/d771ace226fc8215a3572e0aa35bb0d6 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/f56253b5f374fff1a33fbbc9881c9124 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/f7cbd26ba1d28d48de824f0e94586655 +0 -0
- data/test/simple_token_authentication_test.rb +7 -0
- data/test/test_helper.rb +15 -0
- metadata +384 -0
@@ -0,0 +1,65 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe PrivatePost do
|
4
|
+
|
5
|
+
# attributes
|
6
|
+
|
7
|
+
it "has a title" do
|
8
|
+
should respond_to :title
|
9
|
+
end
|
10
|
+
|
11
|
+
it "has a body" do
|
12
|
+
should respond_to :body
|
13
|
+
end
|
14
|
+
|
15
|
+
it "has a published" do
|
16
|
+
should respond_to :published
|
17
|
+
end
|
18
|
+
|
19
|
+
# associations
|
20
|
+
|
21
|
+
# Uncomment if your model has associations.
|
22
|
+
# See https://github.com/thoughtbot/shoulda
|
23
|
+
#
|
24
|
+
# it "belongs to a 'model'" do
|
25
|
+
# should belong_to :model
|
26
|
+
# end
|
27
|
+
|
28
|
+
# validations
|
29
|
+
|
30
|
+
# See https://github.com/thoughtbot/factory_girl
|
31
|
+
# This factory should only set the REQUIRED attributes.
|
32
|
+
it "has a valid factory" do
|
33
|
+
FactoryGirl.build(:private_post).should be_valid
|
34
|
+
end
|
35
|
+
#
|
36
|
+
# Uncomment if your model has required attributes.
|
37
|
+
# This factory should set no attributes and is useful when invalid
|
38
|
+
# attributes or objects are required.
|
39
|
+
# See FactoryGirl.attributes_for() documentation
|
40
|
+
#
|
41
|
+
it "has an invalid factory" do
|
42
|
+
FactoryGirl.build(:invalid_private_post).should_not be_valid
|
43
|
+
end
|
44
|
+
|
45
|
+
# Uncomment if your model has required attributes
|
46
|
+
#
|
47
|
+
# This is the BDD way of testing attributes presence validation
|
48
|
+
# See https://www.relishapp.com/rspec/rspec-rails/docs/model-specs/errors-on
|
49
|
+
#
|
50
|
+
# it "fails validation with no 'attribute'" do
|
51
|
+
# expect(PrivatePost.new).to have(1).error_on(:attribute)
|
52
|
+
# end
|
53
|
+
#
|
54
|
+
# And this is an alternative way, which takes advantage of factories,
|
55
|
+
# it's up to you to chose one, the other, or use both together.
|
56
|
+
#
|
57
|
+
it "requires a 'title'" do
|
58
|
+
FactoryGirl.build(:private_post, title: "").should_not be_valid
|
59
|
+
end
|
60
|
+
|
61
|
+
# methods
|
62
|
+
|
63
|
+
# Describe here you model methods behaviour.
|
64
|
+
|
65
|
+
end
|
@@ -0,0 +1,61 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe User do
|
4
|
+
|
5
|
+
# attributes
|
6
|
+
|
7
|
+
it "is defined" do
|
8
|
+
should respond_to :id
|
9
|
+
end
|
10
|
+
|
11
|
+
# it "has a name" do
|
12
|
+
# should respond_to :name
|
13
|
+
# end
|
14
|
+
|
15
|
+
# associations
|
16
|
+
|
17
|
+
# Uncomment if your model has associations.
|
18
|
+
# See https://github.com/thoughtbot/shoulda
|
19
|
+
#
|
20
|
+
# it "belongs to a 'model'" do
|
21
|
+
# should belong_to :model
|
22
|
+
# end
|
23
|
+
|
24
|
+
# validations
|
25
|
+
|
26
|
+
# See https://github.com/thoughtbot/factory_girl
|
27
|
+
# This factory should only set the REQUIRED attributes.
|
28
|
+
# it "has a valid factory" do
|
29
|
+
# FactoryGirl.build(:user).should be_valid
|
30
|
+
# end
|
31
|
+
#
|
32
|
+
# Uncomment if your model has required attributes.
|
33
|
+
# This factory should set no attributes and is useful when invalid
|
34
|
+
# attributes or objects are required.
|
35
|
+
# See FactoryGirl.attributes_for() documentation
|
36
|
+
#
|
37
|
+
# it "has an invalid factory" do
|
38
|
+
# FactoryGirl.build(:invalid_user).should_not be_valid
|
39
|
+
# end
|
40
|
+
|
41
|
+
# Uncomment if your model has required attributes
|
42
|
+
#
|
43
|
+
# This is the BDD way of testing attributes presence validation
|
44
|
+
# See https://www.relishapp.com/rspec/rspec-rails/docs/model-specs/errors-on
|
45
|
+
#
|
46
|
+
# it "fails validation with no 'attribute'" do
|
47
|
+
# expect(Post.new).to have(1).error_on(:attribute)
|
48
|
+
# end
|
49
|
+
#
|
50
|
+
# And this is an alternative way, which takes advantage of factories,
|
51
|
+
# it's up to you to chose one, the other, or use both together.
|
52
|
+
#
|
53
|
+
# it "requires a 'name'" do
|
54
|
+
# FactoryGirl.build(:user, name: "").should_not be_valid
|
55
|
+
# end
|
56
|
+
|
57
|
+
# methods
|
58
|
+
|
59
|
+
# Describe here you model methods behaviour.
|
60
|
+
|
61
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe "Posts" do
|
4
|
+
describe "GET /posts" do
|
5
|
+
|
6
|
+
context "since ApplicationController#acts_as_authentication_handler was NOT called" do
|
7
|
+
|
8
|
+
# See est/dummy/app/controllers/posts_controller.rb
|
9
|
+
|
10
|
+
it "does not require authentication" do
|
11
|
+
get posts_path
|
12
|
+
response.status.should be(200)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe "PrivatePosts" do
|
4
|
+
describe "GET /private_posts" do
|
5
|
+
|
6
|
+
context "since ApplicationController#acts_as_authentication_handler WAS called" do
|
7
|
+
|
8
|
+
# See est/dummy/app/controllers/private_posts_controller.rb
|
9
|
+
|
10
|
+
it "does require authentication" do
|
11
|
+
# `authenticate_user!` is configured to raise an exception when called,
|
12
|
+
# see test/dummy/app/controllers/application_controller.rb
|
13
|
+
lambda { get private_posts_path }.should raise_exception(RuntimeError)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe PostsController do
|
4
|
+
describe "routing" do
|
5
|
+
|
6
|
+
it "routes to #index" do
|
7
|
+
expect(:get => "/posts").to route_to("posts#index")
|
8
|
+
end
|
9
|
+
|
10
|
+
it "routes to #new" do
|
11
|
+
expect(:get => "/posts/new").to route_to("posts#new")
|
12
|
+
end
|
13
|
+
|
14
|
+
it "routes to #show" do
|
15
|
+
expect(:get => "/posts/1").to route_to("posts#show", :id => "1")
|
16
|
+
end
|
17
|
+
|
18
|
+
it "routes to #edit" do
|
19
|
+
expect(:get => "/posts/1/edit").to route_to("posts#edit", :id => "1")
|
20
|
+
end
|
21
|
+
|
22
|
+
it "routes to #create" do
|
23
|
+
expect(:post => "/posts").to route_to("posts#create")
|
24
|
+
end
|
25
|
+
|
26
|
+
it "routes to #update" do
|
27
|
+
expect(:put => "/posts/1").to route_to("posts#update", :id => "1")
|
28
|
+
end
|
29
|
+
|
30
|
+
it "routes to #destroy" do
|
31
|
+
expect(:delete => "/posts/1").to route_to("posts#destroy", :id => "1")
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe PrivatePostsController do
|
4
|
+
describe "routing" do
|
5
|
+
|
6
|
+
it "routes to #index" do
|
7
|
+
expect(:get => "/private_posts").to route_to("private_posts#index")
|
8
|
+
end
|
9
|
+
|
10
|
+
it "routes to #new" do
|
11
|
+
expect(:get => "/private_posts/new").to route_to("private_posts#new")
|
12
|
+
end
|
13
|
+
|
14
|
+
it "routes to #show" do
|
15
|
+
expect(:get => "/private_posts/1").to route_to("private_posts#show", :id => "1")
|
16
|
+
end
|
17
|
+
|
18
|
+
it "routes to #edit" do
|
19
|
+
expect(:get => "/private_posts/1/edit").to route_to("private_posts#edit", :id => "1")
|
20
|
+
end
|
21
|
+
|
22
|
+
it "routes to #create" do
|
23
|
+
expect(:post => "/private_posts").to route_to("private_posts#create")
|
24
|
+
end
|
25
|
+
|
26
|
+
it "routes to #update" do
|
27
|
+
expect(:put => "/private_posts/1").to route_to("private_posts#update", :id => "1")
|
28
|
+
end
|
29
|
+
|
30
|
+
it "routes to #destroy" do
|
31
|
+
expect(:delete => "/private_posts/1").to route_to("private_posts#destroy", :id => "1")
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,42 @@
|
|
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
|
+
require 'rspec/autorun'
|
6
|
+
|
7
|
+
# Requires supporting ruby files with custom matchers and macros, etc,
|
8
|
+
# in spec/support/ and its subdirectories.
|
9
|
+
Dir[Rails.root.join("spec/support/**/*.rb")].each { |f| require f }
|
10
|
+
|
11
|
+
# Checks for pending migrations before tests are run.
|
12
|
+
# If you are not using ActiveRecord, you can remove this line.
|
13
|
+
ActiveRecord::Migration.check_pending! if defined?(ActiveRecord::Migration)
|
14
|
+
|
15
|
+
RSpec.configure do |config|
|
16
|
+
# ## Mock Framework
|
17
|
+
#
|
18
|
+
# If you prefer to use mocha, flexmock or RR, uncomment the appropriate line:
|
19
|
+
#
|
20
|
+
# config.mock_with :mocha
|
21
|
+
# config.mock_with :flexmock
|
22
|
+
# config.mock_with :rr
|
23
|
+
|
24
|
+
# Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
|
25
|
+
config.fixture_path = "#{::Rails.root}/spec/fixtures"
|
26
|
+
|
27
|
+
# If you're not using ActiveRecord, or you'd prefer not to run each of your
|
28
|
+
# examples within a transaction, remove the following line or assign false
|
29
|
+
# instead of true.
|
30
|
+
config.use_transactional_fixtures = true
|
31
|
+
|
32
|
+
# If true, the base class of anonymous controllers will be inferred
|
33
|
+
# automatically. This will be the default behavior in future versions of
|
34
|
+
# rspec-rails.
|
35
|
+
config.infer_base_class_for_anonymous_controllers = false
|
36
|
+
|
37
|
+
# Run specs in random order to surface order dependencies. If you find an
|
38
|
+
# order dependency and want to debug it, you can fix the order by providing
|
39
|
+
# the seed, which is printed after each run.
|
40
|
+
# --seed 1234
|
41
|
+
config.order = "random"
|
42
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe "posts/edit" do
|
4
|
+
before(:each) do
|
5
|
+
@post = assign(:post, stub_model(Post,
|
6
|
+
:title => "MyString",
|
7
|
+
:body => "MyText",
|
8
|
+
:published => false
|
9
|
+
))
|
10
|
+
end
|
11
|
+
|
12
|
+
it "renders the edit post form" do
|
13
|
+
render
|
14
|
+
|
15
|
+
# Run the generator again with the --webrat flag if you want to use webrat matchers
|
16
|
+
assert_select "form[action=?][method=?]", post_path(@post), "post" do
|
17
|
+
assert_select "input#post_title[name=?]", "post[title]"
|
18
|
+
assert_select "textarea#post_body[name=?]", "post[body]"
|
19
|
+
assert_select "input#post_published[name=?]", "post[published]"
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe "posts/index" do
|
4
|
+
before(:each) do
|
5
|
+
assign(:posts, [
|
6
|
+
stub_model(Post,
|
7
|
+
:title => "Title",
|
8
|
+
:body => "MyText",
|
9
|
+
:published => false
|
10
|
+
),
|
11
|
+
stub_model(Post,
|
12
|
+
:title => "Title",
|
13
|
+
:body => "MyText",
|
14
|
+
:published => false
|
15
|
+
)
|
16
|
+
])
|
17
|
+
end
|
18
|
+
|
19
|
+
it "renders a list of posts" do
|
20
|
+
render
|
21
|
+
# Run the generator again with the --webrat flag if you want to use webrat matchers
|
22
|
+
assert_select "tr>td", :text => "Title".to_s, :count => 2
|
23
|
+
assert_select "tr>td", :text => "MyText".to_s, :count => 2
|
24
|
+
assert_select "tr>td", :text => false.to_s, :count => 2
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe "posts/new" do
|
4
|
+
before(:each) do
|
5
|
+
assign(:post, stub_model(Post,
|
6
|
+
:title => "MyString",
|
7
|
+
:body => "MyText",
|
8
|
+
:published => false
|
9
|
+
).as_new_record)
|
10
|
+
end
|
11
|
+
|
12
|
+
it "renders new post form" do
|
13
|
+
render
|
14
|
+
|
15
|
+
# Run the generator again with the --webrat flag if you want to use webrat matchers
|
16
|
+
assert_select "form[action=?][method=?]", posts_path, "post" do
|
17
|
+
assert_select "input#post_title[name=?]", "post[title]"
|
18
|
+
assert_select "textarea#post_body[name=?]", "post[body]"
|
19
|
+
assert_select "input#post_published[name=?]", "post[published]"
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe "posts/show" do
|
4
|
+
before(:each) do
|
5
|
+
@post = assign(:post, stub_model(Post,
|
6
|
+
:title => "Title",
|
7
|
+
:body => "MyText",
|
8
|
+
:published => false
|
9
|
+
))
|
10
|
+
end
|
11
|
+
|
12
|
+
it "renders attributes in <p>" do
|
13
|
+
render
|
14
|
+
# Run the generator again with the --webrat flag if you want to use webrat matchers
|
15
|
+
rendered.should match(/Title/)
|
16
|
+
rendered.should match(/MyText/)
|
17
|
+
rendered.should match(/false/)
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe "private_posts/edit" do
|
4
|
+
before(:each) do
|
5
|
+
@private_post = assign(:private_post, stub_model(PrivatePost,
|
6
|
+
:title => "MyString",
|
7
|
+
:body => "MyText",
|
8
|
+
:published => false
|
9
|
+
))
|
10
|
+
end
|
11
|
+
|
12
|
+
it "renders the edit private_post form" do
|
13
|
+
render
|
14
|
+
|
15
|
+
# Run the generator again with the --webrat flag if you want to use webrat matchers
|
16
|
+
assert_select "form[action=?][method=?]", private_post_path(@private_post), "post" do
|
17
|
+
assert_select "input#private_post_title[name=?]", "private_post[title]"
|
18
|
+
assert_select "textarea#private_post_body[name=?]", "private_post[body]"
|
19
|
+
assert_select "input#private_post_published[name=?]", "private_post[published]"
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe "private_posts/index" do
|
4
|
+
before(:each) do
|
5
|
+
assign(:private_posts, [
|
6
|
+
stub_model(PrivatePost,
|
7
|
+
:title => "Title",
|
8
|
+
:body => "MyText",
|
9
|
+
:published => false
|
10
|
+
),
|
11
|
+
stub_model(PrivatePost,
|
12
|
+
:title => "Title",
|
13
|
+
:body => "MyText",
|
14
|
+
:published => false
|
15
|
+
)
|
16
|
+
])
|
17
|
+
end
|
18
|
+
|
19
|
+
it "renders a list of private_posts" do
|
20
|
+
render
|
21
|
+
# Run the generator again with the --webrat flag if you want to use webrat matchers
|
22
|
+
assert_select "tr>td", :text => "Title".to_s, :count => 2
|
23
|
+
assert_select "tr>td", :text => "MyText".to_s, :count => 2
|
24
|
+
assert_select "tr>td", :text => false.to_s, :count => 2
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe "private_posts/new" do
|
4
|
+
before(:each) do
|
5
|
+
assign(:private_post, stub_model(PrivatePost,
|
6
|
+
:title => "MyString",
|
7
|
+
:body => "MyText",
|
8
|
+
:published => false
|
9
|
+
).as_new_record)
|
10
|
+
end
|
11
|
+
|
12
|
+
it "renders new private_post form" do
|
13
|
+
render
|
14
|
+
|
15
|
+
# Run the generator again with the --webrat flag if you want to use webrat matchers
|
16
|
+
assert_select "form[action=?][method=?]", private_posts_path, "post" do
|
17
|
+
assert_select "input#private_post_title[name=?]", "private_post[title]"
|
18
|
+
assert_select "textarea#private_post_body[name=?]", "private_post[body]"
|
19
|
+
assert_select "input#private_post_published[name=?]", "private_post[published]"
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|