-
-
Save dchapman1988/3068542 to your computer and use it in GitHub Desktop.
spaghetti
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'use_case_helper' | |
describe UseCase::Plan::Hotel::Create do | |
describe "when executed" do | |
before do | |
params = {name: nil, hotel_id: nil} | |
# Smaller names will help on your mocks | |
# | |
# If you get an error instead of getting something like: | |
# <Mock:0x410000> you'd get <Mock:What ever string you passed into the mock() | |
# | |
# hotel_finder_usecase = mock('The use_case that will help us gather hotel info') | |
# hotel_finder_executable = mock('The initialized use case we will call `execute!` on') | |
# hotel_find_result = mock('The data returned by the hotel finder use case') | |
# suitcase_hotel_obj = mock('The hotel object returned in the use case data') | |
# Try something like this for sanity's sake :-) | |
# It will let you know in case of unexpected invocations or | |
# unsatisfied mocks which variable you called/what variable expected etc... | |
persistence_class = mock('Persistence Class') | |
persistence_object = mock('Persistence Object') | |
hotel_usecase_search_class = mock("Hotel Search UseCase Class") | |
hotel_usecase_search_object = mock("Hotel Search UseCase Object") | |
hotel_usecase_search_result = mock("Hotel Search UseCase Result") | |
hotel_usecase_search_data = mock("Hotel Search UseCase Data") | |
hotel = mock("Hotel") | |
# Start "find_hotel_for_plan" | |
hotel_usecase_search_class.expects(:new).returns(hotel_usecase_search_class).once | |
hotel_usecase_search_object.expects(:execute!).returns(hotel_usecase_search_result).once | |
hotel_usecase_search_result.expects(:data).returns(hotel_usecase_search_data).once | |
hotel_usecase_search_data.expects("[]").with("search").returns(hotel).once | |
# End "find_hotel_for_plan" | |
@use_case = UseCase::Plan::Hotel::Create.new(params: {hotel_id: 126913 }, persistence_class: persistence_class, hotel_search_usecase_class: hotel_usecase_search_class) | |
end | |
it "should initialize properly" do | |
@use_case.execute! | |
end | |
it "should return a UseCase::Result class" do | |
@use_case.execute!.must_be_kind_of UseCase::Result | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment