Module: Uninhibited::Feature

Defined in:
lib/uninhibited/feature.rb

Overview

TODO:

complete

Features

Instance Method Summary collapse

Instance Method Details

#And(desc = nil, options = {}, &block) ⇒ Object

Defines a new And example

And "I am on the home page" do
  visit root_path
end

Parameters:

  • desc (String) (defaults to: nil)

    the description

  • options (Hash) (defaults to: {})

    the metadata for this example

  • block

    the example’s code



115
116
117
# File 'lib/uninhibited/feature.rb', line 115

def And(desc=nil, options={}, &block)
  example("And #{desc}", options, &block)
end

#Background(*args, &example_group_block) ⇒ Object

Defines a new Background group

Feature "Something" do
  Background do
    Given "I..."
  end
  Scenario "success" do
    When "I..."
  end
  Scenario "failure" do
    When "I..."
  end
end

This will be printed like so:

Feature: User signs in
  Background:
    Given I...
  Scenario: success
    When I...
  Scenario: failure
    When I...

takes.

Parameters:

  • args

    the description, metadata, etc. as RSpec’s #describe method

  • example_group_block

    the block to be executed within the feature



59
60
61
62
63
64
65
# File 'lib/uninhibited/feature.rb', line 59

def Background(*args, &example_group_block)
  describe("Background:", *args) do
    [:background] = true

    instance_eval(&example_group_block) if block_given?
  end
end

#But(desc = nil, options = {}, &block) ⇒ Object

Defines a new But example

But "I am on the home page" do
  visit root_path
end

Parameters:

  • desc (String) (defaults to: nil)

    the description

  • options (Hash) (defaults to: {})

    the metadata for this example

  • block

    the example’s code



128
129
130
# File 'lib/uninhibited/feature.rb', line 128

def But(desc=nil, options={}, &block)
  example("But #{desc}", options, &block)
end

#Given(desc = nil, options = {}, &block) ⇒ Object

Defines a new Given example

Given "I am on the home page" do
  visit root_path
end

Parameters:

  • desc (String) (defaults to: nil)

    the description

  • options (Hash) (defaults to: {})

    the metadata for this example

  • block

    the example’s code



76
77
78
# File 'lib/uninhibited/feature.rb', line 76

def Given(desc=nil, options={}, &block)
  example("Given #{desc}", options, &block)
end

#Scenario(*args, &example_group_block) ⇒ Object

Defines a new Scenario group

Feature "User signs in" do
  Scenario "success" do
    Given "I on the login page"
    When "I fill in my email and password"
  end
end

This will be printed like so:

Feature: User signs in
  Scenario: success
    Given I am on the login page
    When I fill in my email and password

takes.

Parameters:

  • args

    the description, metadata, etc. as RSpec’s #describe method

  • example_group_block

    the block to be executed within the feature



26
27
28
29
30
# File 'lib/uninhibited/feature.rb', line 26

def Scenario(*args, &example_group_block)
  describe("Scenario:", *args) do
    instance_eval(&example_group_block) if block_given?
  end
end

#skip_examples_after(example_group, example) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Skip examples after the example provided.

Parameters:

  • example_group (ExampleGroup)

    the example group of example

  • example (Example)

    the example to skip after



138
139
140
141
142
143
144
# File 'lib/uninhibited/feature.rb', line 138

def skip_examples_after(example_group, example)
  examples = example_group.descendant_filtered_examples.flatten
  examples[examples.index(example)..-1].each do |e|
    e.[:pending] = true
    e.[:skipped] = true
  end
end

#Then(desc = nil, options = {}, &block) ⇒ Object

Defines a new Then example

Then "I see a welcome message" do
  page.should have_content("Welcome!")
end

Parameters:

  • desc (String) (defaults to: nil)

    the description

  • options (Hash) (defaults to: {})

    the metadata for this example

  • block

    the example’s code



102
103
104
# File 'lib/uninhibited/feature.rb', line 102

def Then(desc=nil, options={}, &block)
  example("Then #{desc}", options, &block)
end

#When(desc = nil, options = {}, &block) ⇒ Object

Defines a new When example

When "I click Home" do
  click_link "Home"
end

Parameters:

  • desc (String) (defaults to: nil)

    the description

  • options (Hash) (defaults to: {})

    the metadata for this example

  • block

    the example’s code



89
90
91
# File 'lib/uninhibited/feature.rb', line 89

def When(desc=nil, options={}, &block)
  example("When #{desc}", options, &block)
end