Navigation Menu

Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Include require 'spec_helper' in README code examples, fixes #581 #582

Merged
merged 1 commit into from Aug 7, 2012
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 10 additions & 0 deletions README.md
Expand Up @@ -108,6 +108,7 @@ intent is to specify one or more request/response cycles from end to end using
a black box approach.

```ruby
require 'spec_helper'
describe "home page" do
it "displays the user's username after successful login" do
user = User.create!(:username => "jdoe", :password => "secret")
Expand All @@ -128,6 +129,7 @@ This example uses only standard Rails and RSpec API's, but many RSpec/Rails
users like to use extension libraries like FactoryGirl and Capybara:

```ruby
require 'spec_helper'
describe "home page" do
it "displays the user's username after successful login" do
user = FactoryGirl.create(:user, :username => "jdoe", :password => "secret")
Expand Down Expand Up @@ -163,6 +165,7 @@ tests.
## with fixtures

```ruby
require 'spec_helper'
describe WidgetsController do
describe "GET index" do
fixtures :widgets
Expand All @@ -178,6 +181,7 @@ end
## with a factory

```ruby
require 'spec_helper'
describe WidgetsController do
describe "GET index" do
it "assigns all widgets to @widgets" do
Expand All @@ -192,6 +196,7 @@ end
## with stubs

```ruby
require 'spec_helper'
describe WidgetsController do
describe "GET index" do
it "assigns all widgets to @widgets" do
Expand Down Expand Up @@ -236,6 +241,7 @@ functional tests, you can tell controller groups to render the views in the
app with the `render_views` declaration:

```ruby
require 'spec_helper'
describe WidgetsController do
render_views
# ...
Expand All @@ -260,6 +266,7 @@ assigns(:widgets).should eq(expected_value)
View specs live in spec/views, and mix in ActionView::TestCase::Behavior.

```ruby
require 'spec_helper'
describe "events/index" do
it "renders _event partial for each event" do
assign(:events, [stub_model(Event), stub_model(Event)])
Expand Down Expand Up @@ -360,6 +367,7 @@ rendered.should xxx
Model specs live in spec/models.

```ruby
require 'spec_helper'
describe Article do
describe ".recent" do
it "includes articles published less than one week ago" do
Expand All @@ -385,6 +393,7 @@ end
Routing specs live in spec/routing.

```ruby
require 'spec_helper'
describe "routing to profiles" do
it "routes /profile/:username to profile#show for username" do
{ :get => "/profiles/jsmith" }.should route_to(
Expand Down Expand Up @@ -412,6 +421,7 @@ Provides a `helper` object which mixes in the helper module being spec'd, along
with `ApplicationHelper` (if present).

```ruby
require 'spec_helper'
describe EventsHelper do
describe "#link_to_event" do
it "displays the title, and formatted date" do
Expand Down