Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
storyteller (0.4.4)
storyteller (0.5.0)
activesupport
ostruct
smart_init
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,12 +108,12 @@ user, the `after_run`s may come in handy.

Other methods are included to help define the story

**name** can be used to give the Story a more user story name
**story_name** can be used to give the Story a more user story name

**subject** can be used to define which is the main user of a story, so any other method can refer to that user as subject

class BookClosestToMe < Story
name 'As a user I want to make a reservation in a restaurant closest to me'
story_name 'As a user I want to make a reservation in a restaurant closest to me'
subject :creator

def creator = user
Expand Down
8 changes: 8 additions & 0 deletions lib/storyteller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,14 @@ def self.done_criteria(arg = nil, &block)
verify(arg, &block)
end

def self.story_name(value = nil)
value ? @story_name = value : @story_name
end

def self.subject(method_name)
define_method(:subject) { send(method_name) }
end

def success?
return true if @stage == :success

Expand Down
2 changes: 1 addition & 1 deletion lib/storyteller/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# frozen_string_literal: true

module Storyteller
VERSION = "0.4.4"
VERSION = "0.5.0"
end
29 changes: 29 additions & 0 deletions spec/storyteller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -378,5 +378,34 @@ def second_check = spy2.call
expect(spy1).to have_received(:call)
expect(spy2).to have_received(:call)
end

it "supports story_name" do
class NamedStory < Storyteller::Story
story_name "As a user I want to do something"
step -> {}
end

expect(NamedStory.story_name).to eq("As a user I want to do something")
end

it "returns nil for story_name when not set" do
class UnnamedStory < Storyteller::Story
step -> {}
end

expect(UnnamedStory.story_name).to be_nil
end

it "supports subject" do
class StoryWithSubject < Storyteller::Story
initialize_with :user
subject :user
step -> {}
end

user = double("User") # standard:disable RSpec/VerifiedDoubles
story = StoryWithSubject.new(user:)
expect(story.subject).to eq(user)
end
end
end
Loading