Skip to content

Commit f942b26

Browse files
committed
Tagging tutorials works on a db level
1 parent 7e33844 commit f942b26

File tree

5 files changed

+77
-0
lines changed

5 files changed

+77
-0
lines changed

config/environments/test.rb

+2
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,5 @@
2020
# The :test delivery method accumulates sent emails in the
2121
# ActionMailer::Base.deliveries array.
2222
config.action_mailer.delivery_method = :test
23+
24+
config.gem 'rspec-rails', :version => '>= 1.3.2', :lib => false unless File.directory?(File.join(Rails.root, 'vendor/plugins/rspec-rails'))

spec/rcov.opts

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
--exclude "spec/*,gems/*"
2+
--rails

spec/spec.opts

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
--colour
2+
--format progress
3+
--loadby mtime
4+
--reverse

spec/spec_helper.rb

+54
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# This file is copied to ~/spec when you run 'ruby script/generate rspec'
2+
# from the project root directory.
3+
ENV["RAILS_ENV"] ||= 'test'
4+
require File.expand_path(File.join(File.dirname(__FILE__),'..','config','environment'))
5+
require 'spec/autorun'
6+
require 'spec/rails'
7+
8+
# Uncomment the next line to use webrat's matchers
9+
#require 'webrat/integrations/rspec-rails'
10+
11+
# Requires supporting files with custom matchers and macros, etc,
12+
# in ./support/ and its subdirectories.
13+
Dir[File.expand_path(File.join(File.dirname(__FILE__),'support','**','*.rb'))].each {|f| require f}
14+
15+
Spec::Runner.configure do |config|
16+
# If you're not using ActiveRecord you should remove these
17+
# lines, delete config/database.yml and disable :active_record
18+
# in your config/boot.rb
19+
config.use_transactional_fixtures = true
20+
config.use_instantiated_fixtures = false
21+
config.fixture_path = RAILS_ROOT + '/spec/fixtures/'
22+
23+
# == Fixtures
24+
#
25+
# You can declare fixtures for each example_group like this:
26+
# describe "...." do
27+
# fixtures :table_a, :table_b
28+
#
29+
# Alternatively, if you prefer to declare them only once, you can
30+
# do so right here. Just uncomment the next line and replace the fixture
31+
# names with your fixtures.
32+
#
33+
# config.global_fixtures = :table_a, :table_b
34+
#
35+
# If you declare global fixtures, be aware that they will be declared
36+
# for all of your examples, even those that don't use them.
37+
#
38+
# You can also declare which fixtures to use (for example fixtures for test/fixtures):
39+
#
40+
# config.fixture_path = RAILS_ROOT + '/spec/fixtures/'
41+
#
42+
# == Mock Framework
43+
#
44+
# RSpec uses its own mocking framework by default. If you prefer to
45+
# use mocha, flexmock or RR, uncomment the appropriate line:
46+
#
47+
# config.mock_with :mocha
48+
# config.mock_with :flexmock
49+
# config.mock_with :rr
50+
#
51+
# == Notes
52+
#
53+
# For more information take a look at Spec::Runner::Configuration and Spec::Runner
54+
end
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
require 'spec_helper'
2+
3+
describe Tutorial do
4+
it "should have tags" do
5+
@tutorial = Tutorial.create!({
6+
:title => 'My tutorial',
7+
:description => 'blah',
8+
:category => 'Beginner',
9+
:author => 'Joe Sak',
10+
:content => 'This is how to add tags to tutorials',
11+
:tag_list => 'tutorials, theming, help, extending, open source'
12+
})
13+
Tutorial.tagged_with('help').should include(@tutorial)
14+
end
15+
end

0 commit comments

Comments
 (0)