Sha256: 730640ef4cc9bbf3fca5d1503589448433524b7cc566d754900451f51224f59f

Contents?: true

Size: 1.22 KB

Versions: 32

Compression:

Stored size: 1.22 KB

Contents

Feature: Define example attribute

  In order to streamline process
  As an RSpec user
  I want to easily define helper methods that act as a variable assignment
  
  It is fairly common to start with a local variable in one example, use the same
  local variable in the next, and then extract the declaration of that variable
  to before(:each). This requires converting the locals to instance variables.
  
  This feature streamlines the process by defining a helper method so you can extract
  the duplication without having to change other references to the same variables
  to @instance_variables.

  Scenario: 
    Given a file named "counter_spec.rb" with:
    """
    require 'spec/autorun'
    
    class Counter
      def initialize
        @count = 0
      end
      def count
        @count += 1
      end
    end

    describe Counter do
      let(:counter) { Counter.new }
      it "returns 1 the first time" do
        counter.count.should == 1
      end
      it "returns 2 the second time because the counter itself is cached by the 'assign' method" do
        counter.count
        counter.count.should == 2
      end
    end
    """
    When I run "spec counter_spec.rb"
    Then the stdout should include "2 examples, 0 failures"

Version data entries

32 entries across 32 versions & 11 rubygems

Version Path
rspec-instructure-1.3.3 features/example_groups/define_example_attribute.feature
radiant-1.0.0 ruby-debug/ruby/1.8/gems/rspec-1.3.2/features/example_groups/define_example_attribute.feature
rspec-1.3.2 features/example_groups/define_example_attribute.feature
rspec-1.3.1 features/example_groups/define_example_attribute.feature
rspec-1.3.1.rc features/example_groups/define_example_attribute.feature
rspec-1.3.0 features/example_groups/define_example_attribute.feature
hubbub-0.0.11 lib/vendor/plugins/rspec/features/example_groups/define_example_attribute.feature
hubbub-0.0.10 lib/vendor/plugins/rspec/features/example_groups/define_example_attribute.feature
hubbub-0.0.9 lib/vendor/plugins/rspec/features/example_groups/define_example_attribute.feature
hubbub-0.0.8 lib/vendor/plugins/rspec/features/example_groups/define_example_attribute.feature
hubbub-0.0.6 lib/vendor/plugins/rspec/features/example_groups/define_example_attribute.feature
simple-templater-0.0.1.4 gems/gems/rspec-1.2.9/features/example_groups/define_example_attribute.feature
media-path-0.1.2 vendor/rspec/features/example_groups/define_example_attribute.feature
simple-templater-0.0.1.3 vendor/rspec/features/example_groups/define_example_attribute.feature
pupu-0.0.2.pre vendor/rspec/features/example_groups/define_example_attribute.feature
media-path-0.1.1.pre vendor/rspec/features/example_groups/define_example_attribute.feature
simple-templater-0.0.1.2 vendor/rspec/features/example_groups/define_example_attribute.feature
media-path-0.1.1 vendor/rspec/features/example_groups/define_example_attribute.feature
simple-templater-0.0.1.1 vendor/rspec/features/example_groups/define_example_attribute.feature
pupu-0.0.2 vendor/rspec/features/example_groups/define_example_attribute.feature