Sha256: 29c2407d6142f80a432e309bf4b0abebd8569cfd8fe96ea2d40633e7f0af073c

Contents?: true

Size: 1.23 KB

Versions: 9

Compression:

Stored size: 1.23 KB

Contents

require 'spec_helper'

shared_steps "push steps" do
  Given "empty pipe" do
    pipe.clear
  end

  When "push data" do
    pipe.push "hello"
  end

  Then "pipe should have data" do
    pipe.items.should == ["hello"]
  end
end

shared_steps "push with arguments steps" do |value|
  When "push data" do
    pipe.push value
  end
end

shared_steps "pull steps" do
  When "pull data" do
    pipe.pull
  end

  Then "pipe should be empty" do
    pipe.items.should == []
  end
end

describe "shared steps" do

  let(:pipe) do
    Class.new do
      def initialize
        @values = []
      end

      def items
        @values
      end

      def clear
        @values = []
      end

      def push(value)
        @values << value
      end

      def pull
        @values.shift
      end

    end.new
  end

  Steps "push and pull steps" do
    include_steps "push steps"
    include_steps "pull steps"
  end

  Steps "push, count and pull" do
    include_steps "push steps"
    Then "pipe should have 1 item" do
      pipe.items.size.should == 1
    end
    include_steps "pull steps"
  end

  Steps "push with arguments and pull" do
    include_steps "push with arguments steps", "hi"
    pipe.items.should == ["hi"]
    include_steps "pull steps"
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
rspec-example_steps-0.2.5 spec/shared_steps_spec.rb
rspec-example_steps-0.2.4 spec/shared_steps_spec.rb
rspec-example_steps-0.2.3 spec/shared_steps_spec.rb
rspec-example_steps-0.2.2 spec/shared_steps_spec.rb
rspec-example_steps-0.2.1 spec/shared_steps_spec.rb
rspec-example_steps-0.2.0 spec/shared_steps_spec.rb
rspec-example_steps-0.1.2 spec/shared_steps_spec.rb
rspec-example_steps-0.1.1 spec/shared_steps_spec.rb
rspec-example_steps-0.1.0 spec/shared_steps_spec.rb