Sha256: 5a5c3efab76c88e130e358b9b0f3b02011ec3a67d9803aea7da8ba1a534c9938

Contents?: true

Size: 1.88 KB

Versions: 2

Compression:

Stored size: 1.88 KB

Contents

require File.expand_path(File.dirname(__FILE__) + "/rails_helper")

class TestsController < ApplicationController
  def index; render :text => "<p>Hello there!</p>" end
end
# Not sure why the following line needs to exist, I would think it'd just use the default routes from routes.rb,
# but apparently not. Need to figure out why, but not now.
ActionController::Routing::Routes.add_route "/tests/:action", :controller => "tests"

module Spectie
  describe "Rails Stories" do

    track_example_run_state

    it "is registered by default for the 'integration' behavior type" do
      created_example_group = Spec::Example::ExampleGroupFactory.create_example_group(:type => :integration) {}
      created_example_group.superclass.should == RailsStoryExampleGroup
    end

    it "can include a helper module that defines method_missing" do
      (example_group = Class.new(RailsStoryExampleGroup)).class_eval do
        Scenario "I'm going to call a method that doesn't exist in the integration session" do
          i_dont_exist_in_the_integration_session
        end
      end

      @options.run_examples

      example.should be_successful
    end

    it "can make a controller request and inspect the response" do
      example_group = Class.new(RailsStoryExampleGroup)
      example_group.Scenario "Make a request to a controller" do
        Given :i_want_to_write_an_integration_test_for_rails
        When  :i_make_a_controller_request
        Then  :i_can_assert_the_response
      end
      
      example_group.class_eval do
        def i_want_to_write_an_integration_test_for_rails; end
        
        def i_make_a_controller_request
          get "/tests"
        end

        def i_can_assert_the_response
          response.should be_success
          response.should have_tag("p", "Hello there!")
        end
      end

      example_group.run(@options)

      example.should_not be_failed
    end

  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
spectie-0.0.4 spec/spectie/rails_story_example_group_spec.rb
spectie-0.0.3 spec/spectie/rails_story_example_group_spec.rb