Reputation: 3342
I am following the tutorials at http://www.railstutorial.org/ and everything development wise is going well so far. I run into a problem, however, when I get the starting to work on the unit tests.
For example, one of the tests is the following:
require 'spec_helper'
describe "Static pages" do
describe "Home page" do
it "should have the content 'Sample App'" do
visit '/static_pages/home'
expect(page).to have_content('Sample App')
end
.
.
.
end
end
In order to get the test to work, I have to change it to require 'test_helper'
but then when I try to bundle exec rake test
it gives me errors about no such describe
method.
One test that I am able to get to run successfully is the following:
require 'test_helper'
class StaticPagesTest < ActionDispatch::IntegrationTest
def test_connection
get "/about"
assert_response :success, "missing about page"
assert_select 'title', "About Us"
end
end
I am just wondering if there was some change in the way the unit testing is parsed, because it seems that the syntax is quite different. Is there something I need to do differently to get the "describe" method to work, or is there just a new way of accomplishing the same task?
Upvotes: 0
Views: 52
Reputation: 37419
The first code block uses the rspec
framework, while the second one uses Test::Unit
framework.
Both are legitimate unit-testing frameworks, each with its own strengths, and each with its own syntax...
Both have been around for quite awhile now, so, to answer your question - no, nothing has changed...
Upvotes: 1