Sha256: e34042e9a2ccf1714f96fb2f523995228fc8e97a9c338156285ac669cd4bc4a5

Contents?: true

Size: 1.67 KB

Versions: 2

Compression:

Stored size: 1.67 KB

Contents

PROJECT_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..', '..')).freeze
APP_NAME = 'test_app'


When 'I generate a new rails application' do
  steps %{
    When I run `bundle exec rails new #{APP_NAME} --skip-bundle`
    And I cd to "#{APP_NAME}"
    And I install gems
  }
end

When /^I generate resources "([^\"]+)"$/ do |resources|
  resources.split(" ").each do |resource|
    steps %{
      When I write to "app/controllers/#{resource.pluralize}_controller.rb" with:
        """
        class #{resource.pluralize.camelcase}Controller < ApplicationController
          def index; end
          def show; end
          def edit; end
          def update; end
          def create; end
          def new; end
          def destroy; end
        end
        """
    }
  end
end

When /^I configure the application to use "([^\"]+)"$/ do |name|
  append_to_gemfile "gem '#{name}', :path => '#{PROJECT_ROOT}'"
  steps %{And I install gems}
end

When 'I configure the application to use rspec-rails' do
  append_to_gemfile %q(gem 'rspec-rails', '~> 2.14.0')
  steps %{When I install gems}
end

When /^I install gems$/ do
  steps %{When I run `bundle install --local`}
end

When 'I run the rspec generator' do
  steps %{When I successfully run `rails generate rspec:install`}
end

When 'I run routing specs' do
  steps %{When I successfully run `bundle exec rspec spec/routing/routing_spec.rb --failure-exit-code 0`}
end

module FileHelpers
  def append_to(path, contents)
    in_current_dir do
      File.open(path, 'a') do |file|
        file.puts
        file.puts contents
      end
    end
  end

  def append_to_gemfile(contents)
    append_to('Gemfile', contents)
  end
end

World(FileHelpers)

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
shoulda_routing-0.0.2 features/step_definitions/resources_steps.rb
shoulda_routing-0.0.1 features/step_definitions/resources_steps.rb