Sha256: 6989038be38210263a3e5d9ed000fe71bbb8a400be144843fff042df8337edaa

Contents?: true

Size: 1.91 KB

Versions: 10

Compression:

Stored size: 1.91 KB

Contents

Feature: explicit subject

  Use subject() in the group scope to explicitly define the value that is
  returned by the subject() method in the example scope.

  Scenario: subject in top level group
    Given a file named "top_level_subject_spec.rb" with:
      """
      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:
      """
      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: invoke helper method from subject block
    Given a file named "helper_subject_spec.rb" with:
      """
      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

10 entries across 10 versions & 2 rubygems

Version Path
vim-jar-0.1.2.0001 bundler/ruby/1.8/gems/rspec-core-2.1.0/features/subject/explicit_subject.feature
vim-jar-0.1.2 bundler/ruby/1.8/gems/rspec-core-2.1.0/features/subject/explicit_subject.feature
vim-jar-0.1.1 bundler/ruby/1.8/gems/rspec-core-2.1.0/features/subject/explicit_subject.feature
vim-jar-0.1.0 bundler/ruby/1.8/gems/rspec-core-2.1.0/features/subject/explicit_subject.feature
vim-jar-0.0.3 bundler/ruby/1.8/gems/rspec-core-2.1.0/features/subject/explicit_subject.feature
rspec-core-2.2.1 features/subject/explicit_subject.feature
vim-jar-0.0.2 bundler/ruby/1.8/gems/rspec-core-2.1.0/features/subject/explicit_subject.feature
vim-jar-0.0.1 bundler/ruby/1.8/gems/rspec-core-2.1.0/features/subject/explicit_subject.feature
rspec-core-2.2.0 features/subject/explicit_subject.feature
rspec-core-2.1.0 features/subject/explicit_subject.feature