Sha256: d1c1592b259e9e7fb84a0a4a953afe6837e7b6e996fd312fa1581da627951d6b

Contents?: true

Size: 1.95 KB

Versions: 20

Compression:

Stored size: 1.95 KB

Contents

Feature: explicit subject

  You can override the implicit subject using the subject() method.
  
  Scenario: subject in top level group
    Given a file named "top_level_subject_spec.rb" with:
      """
      require 'rspec/expectations'

      describe Array, "with some elements" do
        subject { [1,2,3] }
        it "should have the prescribed elements" do
          subject.should == [1,2,3]
        end
      end
      """
    When I run "rspec ./top_level_subject_spec.rb"
    Then the output should contain "1 example, 0 failures"

  Scenario: subject in a nested group
    Given a file named "nested_subject_spec.rb" with:
      """
      require 'rspec/expectations'

      describe Array do
        subject { [1,2,3] }
        describe "with some elements" do
          it "should have the prescribed elements" do
            subject.should == [1,2,3]
          end
        end
      end
      """
    When I run "rspec ./nested_subject_spec.rb"
    Then the output should contain "1 example, 0 failures"

  Scenario: access subject from before block
    Given a file named "top_level_subject_spec.rb" with:
      """
      describe Array, "with some elements" do
        subject { [] }
        before { subject.push(1,2,3) }
        it "should have the prescribed elements" do
          subject.should == [1,2,3]
        end
      end
      """
    When I run "rspec ./top_level_subject_spec.rb"
    Then the output should contain "1 example, 0 failures"

  Scenario: subject using helper method
    Given a file named "helper_subject_spec.rb" with:
      """
      require 'rspec/expectations'

      describe Array do
        def prepared_array; [1,2,3] end
        subject { prepared_array }
        describe "with some elements" do
          it "should have the prescribed elements" do
            subject.should == [1,2,3]
          end
        end
      end
      """
    When I run "rspec ./helper_subject_spec.rb"
    Then the output should contain "1 example, 0 failures"

Version data entries

20 entries across 20 versions & 2 rubygems

Version Path
rspec-core-2.0.1 features/subject/explicit_subject.feature
gemrage-1.0.0 vendor/ruby/1.8/gems/rspec-core-2.0.0/features/subject/explicit_subject.feature
gemrage-0.4.1 vendor/ruby/1.8/gems/rspec-core-2.0.0/features/subject/explicit_subject.feature
gemrage-0.4.0 vendor/ruby/1.8/gems/rspec-core-2.0.0/features/subject/explicit_subject.feature
gemrage-0.3.2 vendor/ruby/1.8/gems/rspec-core-2.0.0/features/subject/explicit_subject.feature
gemrage-0.3.1 vendor/ruby/1.8/gems/rspec-core-2.0.0/features/subject/explicit_subject.feature
gemrage-0.3.0 vendor/ruby/1.8/gems/rspec-core-2.0.0/features/subject/explicit_subject.feature
gemrage-0.2.0 vendor/ruby/1.8/gems/rspec-core-2.0.0/features/subject/explicit_subject.feature
gemrage-0.1.2 vendor/ruby/1.8/gems/rspec-core-2.0.0/features/subject/explicit_subject.feature
gemrage-0.1.1 vendor/ruby/1.8/gems/rspec-core-2.0.0/features/subject/explicit_subject.feature
gemrage-0.1.0 vendor/ruby/1.8/gems/rspec-core-2.0.0/features/subject/explicit_subject.feature
gemrage-0.0.0 vendor/ruby/1.8/gems/rspec-core-2.0.0/features/subject/explicit_subject.feature
rspec-core-2.0.0 features/subject/explicit_subject.feature
rspec-core-2.0.0.rc features/subject/explicit_subject.feature
rspec-core-2.0.0.beta.22 features/subject/explicit_subject.feature
rspec-core-2.0.0.beta.20 features/subject/explicit_subject.feature
rspec-core-2.0.0.beta.19 features/subject/explicit_subject.feature
rspec-core-2.0.0.beta.18 features/subject/explicit_subject.feature
rspec-core-2.0.0.beta.17 features/subject/explicit_subject.feature
rspec-core-2.0.0.beta.16 features/subject/explicit_subject.feature